Modify article to use markdown.

This commit is contained in:
Kazuhiro MUSASHI 2020-10-13 00:35:44 +09:00
parent fdb30e9646
commit c6558a143f
1 changed files with 65 additions and 64 deletions

View File

@ -2,12 +2,6 @@
title: apt-mirrorを使ってネットワークインストール可能なレポジトリを作成する title: apt-mirrorを使ってネットワークインストール可能なレポジトリを作成する
author: kazu634 author: kazu634
date: 2013-02-09 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: categories:
- apt - apt
- インフラ - インフラ
@ -27,77 +21,84 @@ Windowsでいうところの、WSUSサーバをイントラネット内部に設
## どうすればレポジトリを作成できるの? ## どうすればレポジトリを作成できるの?
apt-mirrorを使います。 `apt-mirror`を使います。
<pre class="lang:sh decode:true" title="aptitudeによるインストール方法">aptitude install apt-mirror</pre> ```
# aptitude install apt-mirror
```
設定ファイルは /etc/apt/mirror.list です。debian-installの設定を追加する必要があります。私の設定はこのようになりました: 設定ファイルは`/etc/apt/mirror.list`です。debian-installの設定を追加する必要があります。私の設定はこのようになりました:
<pre class="lang:default decode:true" title="/etc/apt/mirror.list">############# config ################## ```
# ############# config ##################
set base_path /share/apt-mirror #
# set base_path /share/apt-mirror
# set mirror_path $base_path/mirror #
# set skel_path $base_path/skel # set mirror_path $base_path/mirror
# set var_path $base_path/var # set skel_path $base_path/skel
# set cleanscript $var_path/clean.sh # set var_path $base_path/var
# set defaultarch &lt;running host architecture&gt; # set cleanscript $var_path/clean.sh
# set postmirror_script $var_path/postmirror.sh # set defaultarch &lt;running host architecture&gt;
# set run_postmirror 0 # set postmirror_script $var_path/postmirror.sh
set nthreads 20 # set run_postmirror 0
set _tilde 0 set nthreads 20
# set _tilde 0
############# end config ############## #
############# 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</pre>
私の場合デフォルトのミラー作成先 (/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
<pre class="lang:sh decode:true" title="/var/spool/apt-mirror をコピー">sudo cp -pr /var/spool/apt-mirror/ /share/</pre> # 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の設定 ## Nginxの設定
レポジトリを公開するためには、HTTPでインデックスを表示できなければいけません。私は以下の設定を実施しています: レポジトリを公開するためには、HTTPでインデックスを表示できなければいけません。私は以下の設定を実施しています:
<pre class="lang:default decode:true" title="/etc/nginx/sites-available/repository">server { ```
listen 80; server {
listen 80;
root /share/apt-mirror/mirror/archive.ubuntu.com;
index index.html index.htm; root /share/apt-mirror/mirror/archive.ubuntu.com;
index index.html index.htm;
server_name repository.kazu634.lan;
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; 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;
}</pre> gzip on;
}
```
autoindexをonにするのがポイントです。 autoindexをonにするのがポイントです。
## レポジトリの内容を定期的に更新する ## レポジトリの内容を定期的に更新する
以下の設定ファイルを更新します。コメントアウトを外して、cronの書式で好きな頻度で実行できるようにしてください。 以下の設定ファイルを更新します。コメントアウトを外して、cronの書式で好きな頻度で実行できるようにしてください。
<pre class="lang:default decode:true" title="/etc/cron.d/apt-mirror"># ```
# Regular cron jobs for the apt-mirror package #
# # Regular cron jobs for the apt-mirror package
0 4 * * * apt-mirror /usr/bin/apt-mirror &gt; /var/spool/apt-mirror/var/cron.log</pre> #
0 4 * * * apt-mirror /usr/bin/apt-mirror &gt; /var/spool/apt-mirror/var/cron.log
&nbsp; ```