离线下载安装工具包

#方法一前提:有网的系统未安装目标软件
# 有网的系统下载
apt install -d net-tools 
mv /var/cache/apt/archives/*.deb ~/net-tools
#或者直接下载到指定目录
mkdir -p /root/net_tools
apt install -y -o dir::cache::archives="/root/net_tools/" -d net-tools


# 有网/离线的系统安装
apt install ./net-tools/*.deb 
#或者
dpkg -i ./net_tools/*.deb


#方法二前提:离线的系统必须安装有apt-offline软件
#离线的系统产生安装包信息sig文件,
#eg:apt-offline set --install-packages chrpath libfuse2 automake libnl-3-dev quilt debhelper gfortran libltdl-dev autotools-dev --update apt-offline-pkgs.sig
apt-offline set --install-packages 安装包名称 --update apt-offline-pkgs.sig
#有网机器上利用sig文件打包
apt-get update && apt-offline get apt-offline-pkgs.sig --bundle bundle-pkgs.zip --threads 10
#离线系统将压缩包的软件放进本地仓库
apt-offline install bundle-pkgs.zip
#离线系统取本地包安装,eg: apt-get install -y chrpath libfuse2 automake libnl-3-dev quilt debhelper gfortran libltdl-dev autotools-dev dpatch autoconf libnl-route-3-dev tk libgfortran5
apt-get install -y 安装包名称

 更新国内源

1./etc/apt/sources.list

将系统 /etc/apt/sources.list 软件包仓库位置的原始默认配置文件备份,修改为 Debian系统源(阿里云源)和中科大proxmox源【https://mirrors.ustc.edu.cn/proxmox/】

"""/etc/apt/sources.list"""
#deb http://ftp.debian.org/debian buster main contrib
#deb http://ftp.debian.org/debian buster-updates main contrib
# security updates
#deb http://security.debian.org buster/updates main contrib

# debian aliyun source
deb https://mirrors.aliyun.com/debian buster main contrib non-free
deb https://mirrors.aliyun.com/debian buster-updates main contrib non-free
deb https://mirrors.aliyun.com/debian-security buster/updates main contrib non-free

# proxmox source
# deb http://download.proxmox.com/debian/pve buster pve-no-subscription
deb https://mirrors.ustc.edu.cn/proxmox/debian/pve buster pve-no-subscription

脚本操作:

2./etc/apt/sources.list.d/pve-enterprise.list

如果你没有订阅 Proxmox VE 企业版,可以将企业版软件源配置信息在软件源配置文件中注释掉(在该行开头插入一个 # 字符),以避免系统发出错误提示信息。这种情况下可以配置使用 pve-no-subscriptin 软件源。

因为没有订阅 Proxmox VE 企业版服务,所以这里对Proxmox VE 企业版更新源进行注释操作。

"""/etc/apt/sources.list.d/pve-enterprise.list"""
## deb https://enterprise.proxmox.com/debian/pve buster pve-enterprise

3.脚本操作

#!/bin/bash
#scripts name:change_apt_mirror.sh
NOW=$(date +%Y%m%d-%H%M);
if ! grep -q "tsinghua" /etc/apt/sources.list; then
    # 需要换成清华源
    mv /etc/apt/sources.list /etc/apt/sources.list.${NOW}
    sh -c 'echo "# debian aliyun source
deb https://mirrors.aliyun.com/debian buster main contrib non-free
deb https://mirrors.aliyun.com/debian buster-updates main contrib non-free
deb https://mirrors.aliyun.com/debian-security buster/updates main contrib non-free

# proxmox source
# deb http://download.proxmox.com/debian/pve buster pve-no-subscription
deb https://mirrors.ustc.edu.cn/proxmox/debian/pve buster pve-no-subscription" > /etc/apt/sources.list'
 
    echo "更换apt源为清华源"
fi
sed -i 's/deb/#deb/g' /etc/apt/sources.list.d/pve-enterprise.list;

apt update

最后执行上述命令来更新源。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐