ubuntu-18.04自动配置脚本
使用ubuntu server的alternate installer版本
#!/bin/bash
echo "blacklist i2c_piix4" >> /etc/modprobe.d/blacklist.conf
currentTime=$(date +"%Y-%m-%d_%H:%M:%S")
sed -i '/UseDNS yes/s/^/#/' /etc/ssh/sshd_config
sed -i '/#UseDNS yes/a UseDNS no' /etc/ssh/sshd_config
sed -i '/#PubkeyAuthentication yes/s/^#//' /etc/ssh/sshd_config
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak@$currentTime
sudo 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
touch /etc/sudoers.d/nopasswd4sudo
echo "ubuntu ALL=(ALL) NOPASSWD : ALL" >> /etc/sudoers.d/nopasswd4sudo
##network_config
NIC_CONF="/etc/netplan/01-netcfg.yaml"
NIC_NAME="ens32"
HOST_NAME="vhost"
NIC_IP="192.168.127.20"
GATWAY="192.168.127.254"
DNS1="114.114.114.114"
DNS2="8.8.8.8"
SUBNET="24"
mv $NIC_CONF $NIC_CONF'.bak@'$currentTime
cat > $NIC_CONF <<EOF
network:
ethernets:
ens32:
addresses:
- $NIC_IP/$SUBNET
dhcp4: false
dhcp6: false
gateway4: $GATWAY
nameservers:
addresses:
- $DNS1
- $DNS2
search: []
version: 2
EOF
mv /etc/hosts /etc/host.bak@$currentTime
cat > /etc/hosts << EOF
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1 localhost
EOF
echo "$NIC_IP $HOST_NAME " >> /etc/hosts
hostnamectl set-hostname $HOST_NAME
# netplan apply
# apt-get update
# apt-get upgrade
# apt-get install build-essential
· 用 C# 插值字符串处理器写一个 sscanf
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· C# 深度学习:对抗生成网络(GAN)训练头像生成模型
· 手把手教你更优雅的享受 DeepSeek
· AI工具推荐:领先的开源 AI 代码助手——Continue
· 探秘Transformer系列之(2)---总体架构
· V-Control:一个基于 .NET MAUI 的开箱即用的UI组件库
· 乌龟冬眠箱湿度监控系统和AI辅助建议功能的实现