Linux网卡与软件仓库快捷配置脚本
网卡配置脚本
rhel9:
vim /usr/bin/vmset.sh
chmod +x /usr/bin/vmset.sh
#!/bin/bash
ifconfig $1 &> /dev/null || {echo "net decive $1 is not exist"exit
}
ping -c1 -w1 $2 &> /dev/null && {echo "$2 is exist"exit
}grep $1 -r /etc/NetworkManager/system-connections/ | awk -F : '{system("rm -fr " $1)}'cat >/etc/NetworkManager/system-connections/$1.nmconnection <<EOF
[connection]
id=$1
type=ethernet
interface-name=$1[ipv4]
method=manual
address1=$2/24,172.25.254.2
dns=8.8.8.8
EOFchmod 600 /etc/NetworkManager/system-connections/$1.nmconnection
nmcli connection reload
nmcli connection up $1hostnamectl hostname $3grep -e "$2\t$3" /etc/hosts || {echo -e "$2\t$3" >> /etc/hosts
}
软件仓库配置脚本
rhel9:
vim /etc/rc.d/rc.local
mkdir /rhel9
cd /etc/yum.repos.d/
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.touch /var/lock/subsys/local
mount /dev/cdrom /rhel9
vim rhel9.repo
mount /dev/cdrom /rhel9
chmod +x /etc/rc.d/rc.local
reboot重启后,df检查是否开机挂载,dnf search nginx 检查是否成功
[AppStream]
name = AppStream
baseurl = file:///rhel9/AppStream
gpgcheck = 0[BaseOS]
name = BaseOS
baseurl = file:///rhel9/BaseOS
gpgcheck = 0
[root@node1 ~]# cd /etc/NetworkManager/system-connections/
[root@node1 system-connections]# ls
ens160.nmconnection
[root@node1 system-connections]# rm -rf ens160.nmconnection