设置apt代理需要修改/etc/apt/apt.conf
脚本内容如下:
# file 1.sh
#!/bin/bash
PROXY_IP_PORT=$1
if [ -z ${/etc/apt/apt.conf} ];then
echo "Please enter the Proxy IP and Port."
exit 1
fi
sudo sh -c 'echo "
Acquire::http::proxy \"http://127.0.0.1:8000/\";
Acquire::ftp::proxy \"ftp://127.0.0.1:8000/\";
Acquire::https::proxy \"https://127.0.0.1:8000/\";
">>/etc/apt/apt.conf'
sudo sed -i "s/127.0.0.1:8000/${PROXY_IP_PORT}/" /etc/apt/apt.conf
echo
echo "--------file:/etc/apt/apt.conf---------"
cat /etc/apt/apt.conf
echo "---------------------------------------"
exit 0
直接运行bash 1.sh IP:PORT
即可完成配置