Ubuntu使用apt-mirror制作本地源
#版本对应:
12.04.5 LTS Precise Pangolin
14.04.6 LTS Trusty Tahr
16.04.6 LTS Xerial Xerus
18.04.2 LTS Bionic Beaver
#创建路径
mkdir -p /data/16.04
mkdir -p /data/16.04/mirror
mkdir -p /data/16.04/var
mkdir -p /data/16.04/skel
mkdir -p /data/18.04
mkdir -p /data/18.04/mirror
mkdir -p /data/18.04/var
mkdir -p /data/18.04/skel
#安装应用软件
apt install apt-mirror
#配置文件(如果不需要i386软件可以删除deb-i386的行)
cp /etc/apt/mirror.list /etc/apt/mirror.list.bak.`date +%Y%m%d%H%M`
cat<<EOF>/etc/apt/mirror.list.16.04
set base_path /data/16.04
set defaultarch amd64
set nthreads 20
set _tilde 0
deb-i386 http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-amd64 http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-amd64 http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-amd64 http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-amd64 http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-amd64 http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
clean http://mirrors.aliyun.com/ubuntu
EOF
cat<<EOF> /etc/apt/mirror.list.18.04
set base_path /data/18.04
set defaultarch amd64
set nthreads 20
set _tilde 0
deb-i386 http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-amd64 http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-amd64 http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-amd64 http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-amd64 http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-amd64 http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
clean http://mirrors.aliyun.com/ubuntu
EOF
#开始下载(分别200G左右,可以写入crontab定时执行,需要修改命令为绝对路径)
cp -f /etc/apt/mirror.list.16.04 /etc/apt/mirror.list
apt-mirror
cp -f /etc/apt/mirror.list.18.04 /etc/apt/mirror.list
apt-mirror
#配置apache
apt install apache2
ln -s /data/16.04 /var/www/html/16.04
ln -s /data/18.04 /var/www/html/18.04
systemctl restart apache2
systemctl enable apache2
#客户16.04系统配置(i386修改对应的arch,地址修改为实际ip加端口)
cp /etc/apt/source.list /etc/apt/source.list.bak.`date +%Y%m%d%H%M`
cat<<EOF> /etc/apt/source.list
# Local Source
deb [arch=amd64] http://192.168.31.200/16.04/ trusty main restricted universe multiverse
deb [arch=amd64] http://192.168.31.200/16.04/ trusty-security main restricted universe multiverse
deb [arch=amd64] http://192.168.31.200/16.04/ trusty-updates main restricted universe multiverse
deb [arch=amd64] http://192.168.31.200/16.04/ trusty-proposed main restricted universe multiverse
deb [arch=amd64] http://192.168.31.200/16.04/ trusty-backports main restricted universe multiverse
EOF
#客户18.04系统配置(i386修改对应的arch,地址修改为实际ip加端口)
cp /etc/apt/source.list /etc/apt/source.list.bak.`date +%Y%m%d%H%M`
cat<<EOF> /etc/apt/source.list
# Local Source
deb [arch=amd64] http://192.168.31.200/18.04/ trusty main restricted universe multiverse
deb [arch=amd64] http://192.168.31.200/18.04/ trusty-security main restricted universe multiverse
deb [arch=amd64] http://192.168.31.200/18.04/ trusty-updates main restricted universe multiverse
deb [arch=amd64] http://192.168.31.200/18.04/ trusty-proposed main restricted universe multiverse
deb [arch=amd64] http://192.168.31.200/18.04/ trusty-backports main restricted universe multiverse
EOF
#更新apt列表
apt update
本文来自博客园,作者:LEAUS,转载请注明原文链接:https://www.cnblogs.com/leaus/p/13603183.html