初始化脚本

noteId: 89D54D7B765D40E393915B5D0538015E · 原始路径:/ALL/Linux - A模块/初始化脚本.note

#! /bin/bashecho "Pleace write your want parameter:Network card:as: (ens33)"read cardecho "Network type:(static or DHCP)"read typeecho "Network address: "read addressecho "Network mask:  as: (/24)"read maskecho "hostname:"read hostnamehostnamectl set-hostname $hostnametimedatectl set-timezone Asia/Shanghaicat > /etc/network/interfaces <<EOF auto $cardiface $card inet $typeaddress $address$maskgateway 192.168.10.254EOFcat > /etc/resolv.conf <<EOFnameserver 114.114.114.114EOFsystemctl restart networkingifup $cardrm /etc/apt/sources.listcat > /etc/apt/sources.list <<EOF deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-freedeb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-freedeb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-freedeb http://security.debian.org/debian-security bullseye-security main contrib non-freeEOFapt-cdrom addapt updateapt install -y openssh-server vimcat >> /etc/ssh/sshd_config <<EOFpermitrootlogin yesEOFsystemctl restart sshd