Merge branch 'modify-apt-mirror-article' of kazu634/blog into master

This commit is contained in:
Kazuhiro MUSASHI 2020-10-13 00:39:18 +09:00 committed by Gitea
commit 9d8977adc6
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,13 +21,16 @@ 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
# #
@ -64,17 +61,21 @@ deb-src http://archive.ubuntu.com/ubuntu precise-updates main restricted univers
deb-src http://archive.ubuntu.com/ubuntu precise-proposed 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 deb-src http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu</pre> clean http://archive.ubuntu.com/ubuntu
```
私の場合デフォルトのミラー作成先 (/var/spool/apt-mirror) から変更 (/share/apt-mirror)したかったため、以下のコマンドを実行しています。 私の場合デフォルトのミラー作成先 (`/var/spool/apt-mirror`) から変更 (`/share/apt-mirror`)したかったため、以下のコマンドを実行しています。
<pre class="lang:sh decode:true" title="/var/spool/apt-mirror をコピー">sudo cp -pr /var/spool/apt-mirror/ /share/</pre> ```
# 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 { ```
server {
listen 80; listen 80;
root /share/apt-mirror/mirror/archive.ubuntu.com; root /share/apt-mirror/mirror/archive.ubuntu.com;
@ -87,17 +88,17 @@ clean http://archive.ubuntu.com/ubuntu</pre>
autoindex on; autoindex on;
gzip on; gzip on;
}</pre> }
```
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;