rocky9.x版本系统初始化配置
更换yum源
sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' -i.bak /etc/yum.repos.d/rocky*.repo
dnf makecache
vim init.sh
#!bin/sh
LOGINFO=init_install.log
function info(){
echo "已为您退出!若想继续请重新执行命令:'bash $0' 继续操作! "
return 2
}
function setNetwork(){
netfile=/etc/NetworkManager/system-connections/ens160.nmconnection
#找出系统发行版是什么
RELEASE=`cat /etc/redhat-release|awk '{print $1,$4}'|sed 's/[ .]//p' -n`
RELEASE_1=`echo ${
RELEASE/.*/}`
#如果发行版为Rocky9版本,则开始设置ip
if [ "${RELEASE_1}" == "Rocky9" ]; then
read -p "确定更改网络配置信息么,是:y 按其他任意键退出: " yn
if [ "${yn}" == "y" ]; then
read -p "请输入你要设置的ip及掩码地址‘格式如 192.168.10.23/24 ’:" IP_netmask
read -p "请输入您要设置的网关‘ 格式如:192.168.10.1’:" GATWAY
read -p "请输入您要设置的DNS‘格式如 114.114.114.114': " DNS
#查看网络配置文件中ipv4 在哪一行
ipv4InNum=$( grep '\[ipv4\]' -n ${
netfile} |awk -F ':' '{print $1}')
#根据ipv4所在行 即可知道ipv4下的method所在行
#删除method=auto
sed "$((${ipv4InNum}+1))d" ${netfile} -i
#在ipv4所在行下插入网络配置信息
sed "${ipv4InNum}a method=manual" ${netfile} -i
sed "$((${ipv4InNum}

最低0.47元/天 解锁文章
1788

被折叠的 条评论
为什么被折叠?



