#!/bin/bash
currentTime=$(date +"%Y-%m-%d_%H:%M:%S")
##network_config
net_conf="/etc/netplan/50-cloud-init.yaml"
net_device_name="ens32"
host_name="vhost"
domain_name="local"
host_ip="192.168.127.22"
gateway="192.168.127.254"
dns1="114.114.114.114"
dns2="8.8.8.8"
netmask="24"
echo "blacklist i2c_piix4" >> /etc/modprobe.d/blacklist.conf
ufw disable
service apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils
sed -i '/UseDNS yes/s/^/#/' /etc/ssh/sshd_config
sed -i '/#UseDNS yes/a UseDNS no' /etc/ssh/sshd_config
sed -i '/preserve_hostname: false/s/^/#/' /etc/cloud/cloud.cfg
sed -i '/#preserve_hostname: false/a preserve_hostname: yes' /etc/cloud/cloud.cfg
echo "$host_ip $host_name $host_name.$domain_name" >> /etc/hosts
hostnamectl set-hostname $host_name'.'$domain_name
mv $net_conf $net_conf'.bak@'$currentTime
cat > demo.yaml <<EOF
network:
ethernets:
$net_device_name:
addresses: [$host_ip/$netmask]
gateway4: $gateway
nameservers:
addresses: [$dns1,$dns2]
search: []
optional: true
dhcp4: false
dhcp6: false
version: 2
EOF
netplan apply
mv /etc/apt/sources.list /etc/apt/sources.list.bak@$currentTime
cat /etc/apt/sources.list <<EOF
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
EOF
apt-get update
apt-get upgrade
apt-get install build-essential
ubuntu-18.04自动配置脚本
猜你喜欢
转载自www.cnblogs.com/javaite/p/9833976.html
今日推荐
周排行