diff --git a/content/labs/misc/2013-02-09-make_network-installable_repository_by_apt-mirror.md b/content/labs/misc/2013-02-09-make_network-installable_repository_by_apt-mirror.md index 6bd4ec9..0c234c4 100644 --- a/content/labs/misc/2013-02-09-make_network-installable_repository_by_apt-mirror.md +++ b/content/labs/misc/2013-02-09-make_network-installable_repository_by_apt-mirror.md @@ -2,12 +2,6 @@ title: apt-mirrorを使ってネットワークインストール可能なレポジトリを作成する author: kazu634 date: 2013-02-09 -has_been_twittered: - - yes -tmac_last_id: - - 314310983340421120 -wordtwit_post_info: - - 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";s:1:"1";s:5:"delay";s:1:"0";s:7:"enabled";s:1:"1";s:10:"separation";i:60;s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:3;s:6:"result";a:0:{}s:13:"tweet_counter";i:1;s:13:"tweet_log_ids";a:0:{}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}' categories: - apt - インフラ @@ -27,77 +21,84 @@ Windowsでいうところの、WSUSサーバをイントラネット内部に設 ## どうすればレポジトリを作成できるの? -apt-mirrorを使います。 +`apt-mirror`を使います。 -
aptitude install apt-mirror
+``` +# aptitude install apt-mirror +``` -設定ファイルは /etc/apt/mirror.list です。debian-installの設定を追加する必要があります。私の設定はこのようになりました: +設定ファイルは`/etc/apt/mirror.list`です。debian-installの設定を追加する必要があります。私の設定はこのようになりました: -
############# config ##################
-#
-set base_path    /share/apt-mirror
-#
-# set mirror_path  $base_path/mirror
-# set skel_path    $base_path/skel
-# set var_path     $base_path/var
-# set cleanscript $var_path/clean.sh
-# set defaultarch  <running host architecture>
-# set postmirror_script $var_path/postmirror.sh
-# set run_postmirror 0
-set nthreads     20
-set _tilde 0
-#
-############# end config ##############
-
-deb http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
-deb http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
-deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
-deb http://archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse
-deb http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse
-
-# debian installer here
-deb http://archive.ubuntu.com/ubuntu precise main/debian-installer restricted/debian-installer
-
-deb-src http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
-deb-src http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
-deb-src http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
-deb-src http://archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse
-deb-src http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse
-
-clean http://archive.ubuntu.com/ubuntu
+``` +############# config ################## +# +set base_path /share/apt-mirror +# +# set mirror_path $base_path/mirror +# set skel_path $base_path/skel +# set var_path $base_path/var +# set cleanscript $var_path/clean.sh +# set defaultarch <running host architecture> +# set postmirror_script $var_path/postmirror.sh +# set run_postmirror 0 +set nthreads 20 +set _tilde 0 +# +############# end config ############## -私の場合デフォルトのミラー作成先 (/var/spool/apt-mirror) から変更 (/share/apt-mirror)したかったため、以下のコマンドを実行しています。 +deb http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse -
sudo cp -pr /var/spool/apt-mirror/ /share/
+# debian installer here +deb http://archive.ubuntu.com/ubuntu precise main/debian-installer restricted/debian-installer + +deb-src http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse + +clean http://archive.ubuntu.com/ubuntu +``` + +私の場合デフォルトのミラー作成先 (`/var/spool/apt-mirror`) から変更 (`/share/apt-mirror`)したかったため、以下のコマンドを実行しています。 + +``` +# sudo cp -pr /var/spool/apt-mirror/ /share/ +``` ## Nginxの設定 レポジトリを公開するためには、HTTPでインデックスを表示できなければいけません。私は以下の設定を実施しています: -
server {
-    listen   80;
-
-    root /share/apt-mirror/mirror/archive.ubuntu.com;
-    index index.html index.htm;
-
-    server_name repository.kazu634.lan;
-
-    access_log  /var/log/nginx/repository.kazu634.lan.access.log;
-    error_log   /var/log/nginx/repository.kazu634.lan.error.log;
-
-    autoindex on;
-    gzip on;
-}
+``` +server { + listen 80; + + root /share/apt-mirror/mirror/archive.ubuntu.com; + index index.html index.htm; + + server_name repository.kazu634.lan; + + access_log /var/log/nginx/repository.kazu634.lan.access.log; + error_log /var/log/nginx/repository.kazu634.lan.error.log; + + autoindex on; + gzip on; +} +``` autoindexをonにするのがポイントです。 ## レポジトリの内容を定期的に更新する - 以下の設定ファイルを更新します。コメントアウトを外して、cronの書式で好きな頻度で実行できるようにしてください。 -
#
-# Regular cron jobs for the apt-mirror package
-#
-0 4	* * *	apt-mirror	/usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log
- -  +``` +# +# Regular cron jobs for the apt-mirror package +# +0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log +```