Ubuntu 16.04 163 Netease source settings (automatic configuration script)

1, introduction

1.1 INTRODUCTION

In many cases, in order to facilitate the operation and if conditions permit, install directly online, but the url address of apt source configured by the system is not domestic, so it is very slow to obtain resources, so it needs to be configured as domestic source. I like 163 Netease source, and I choose it according to my own preference
    

1.2 operating system

## Ubuntu 16.04 amd64, the operating system of this article 
## Release number xenial
# lsb_release -a

    

2, apt source

2.1 source backup

## Back up the original source profile
# cd /etc/apt
# mv -v source.list{,.bak}

    

2.3 setting 163 sources

## Set the local source. The file path in the baseurl corresponds to the path of the mount
# cat /etc/apt/source.list
deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse

    

3. apt source operation

3.1 clear original records

# apt-get clean all

    

3.2 update apt source

# apt-get update

    

3.3 get installation list

# apt-cache dump | grep Package

    

4. Automatic configuration script

My test environment needs to recover the pure environment continuously for relevant test operations, so it's really hard to manually configure each time. I simply wrote a configuration script, and I hope to leave a message for optimization, hehe!
    

4.1 decompression

# tar -zxvf set_apt_source.tar.gz -C .

    

4.2 installation

## Once the installation is complete, you can install the required software packages directly online
# cd set_apt_source/
# ./modify_apt_source.sh

    

4.3 code

# cat modify_apt_source.sh
#!/bin/bash

# file name :
# date :
# description :

deb_1="deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse"
deb_2="deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse"
deb_3="deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse"
deb_4="deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse"
deb_5="deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse"
deb_src1="deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse"
deb_src2="deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse"
deb_src3="deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse"
deb_src4="deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse"
deb_src5="deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse"
DEB_SOURCE="${deb_1}\n${deb_2}\n${deb_3}\n${deb_4}\n${deb_5}\n${deb_src1}\n${deb_src2}\n${deb_src3}\n${deb_src4}\n${deb_src5}\n"

APT_FILE="/etc/apt/sources.list"

[ -f ${APT_FILE} ] && mv ${APT_FILE}{,.bak}
printf "${DEB_SOURCE}" >> ${APT_FILE} && apt-get update

    

Tags: Operation & Maintenance Ubuntu

Posted on Mon, 02 Dec 2019 22:17:49 -0500 by evaoparah