#platform=x86, AMD64, 或 Intel EM64T#version=DEVEL# Install OS instead of upgradeinstall# Keyboard layoutskeyboard'us'# Root passwordrootpw--iscrypted$1$0Rnj3JYy$.O6bjrhyiBucwxVpIg8eF1# System languagelangen_US# System authorization informationauth--useshadow--passalgo=sha512# Use CDROM installation mediacdrom# Use text mode installtext# SELinux configurationselinux--disabled# Do not configure the X Window Systemskipx# System bootloader configurationbootloader--location=mbr# Firewall configurationfirewall--disabledservices--disabled="chronyd"services--enabled="sshd"# System timezonetimezoneAsia/Shanghai# Clear the Master Boot Recordzerombr# Partition clearing informationclearpart--all--initlabel# Disk partitioning informationpart/boot--fstype="xfs"--size=500part/boot/efi--fstype="xfs"--size=500partswap--fstype="swap"--size=1024part/--fstype="ext4"--grow--size=1poweroff%packages--multilib--ignoremissinglrzsznet-toolsopensslpython3screentcpdumpzipunzipvim-enhancedwgetyum-utilsnanoNetworkManager-tui%end%addoncom_redhat_kdump--enable--reserve-mb='auto'%end%post--nochrootcp-fr/mnt/install/repo/plus/*/mnt/sysimage/root/echo"/bin/bash /root/init.sh">>/mnt/sysimage/etc/rc.localchmoda+x/mnt/sysimage/etc/rc.local%end
#获取当前网络信息default_route=$(iprouteshow)default_interface=$(echo$default_route|sed-e's/^.*dev \([^ ]*\).*$/\1/'|head-n1)address=$(ipaddrshowlabel$default_interfacescopeglobal|awk'$1 == "inet" { print $2,$4}')ip=$(echo$address|awk'{print $1 }')ip=${ip%%/*}mask=$(route-n|grep'U[ \t]'|head-n1|awk'{print $3}')gateway=$(route-n|grep'UG[ \t]'|awk'{print $2}')dns=$(cat/etc/resolv.conf|grepnameserver|awk'{print $2}')#判断default_interface是否为空if[-z$default_interface]thenecho"no working network, exit! if you want to use Wi-Fi, please run nmtui to set"exit1ficfg_name=$(cd/etc/sysconfig/network-scripts&&grep-lWireless*|grepifcfg)echo"config file is $cfg_name"#download iot-device/bin/python3/root/cron_update.py#显示网络信息echo-e"The current net info [dynamic]"echo-e"------------------------------------------"echo-e" device: $default_interface"echo-e" ipaddr: $ip"echo-e"netmask: $mask"echo-e"gateway: $gateway"echo-e" dns: $dns"echo-e"------------------------------------------"echo-e""# set last ip to 200IFS='.'read-r-aarray<<<"$ip"array[3]=200newip=$(IFS=.eval'echo "${array[*]}"')#网络配置cp/etc/sysconfig/network-scripts/$cfg_name/etc/sysconfig/network-scripts/$cfg_name.baksed-i"/.*dhcp.*/d"/etc/sysconfig/network-scripts/$cfg_nameecho"IPADDR=$newip">>/etc/sysconfig/network-scripts/$cfg_nameecho"NETMASK=$mask">>/etc/sysconfig/network-scripts/$cfg_nameecho"GATEWAY=$gateway">>/etc/sysconfig/network-scripts/$cfg_nameecho"DNS1=114.114.114.114">>/etc/sysconfig/network-scripts/$cfg_nameifdown$cfg_name&&ifup$cfg_namesleep5ping-c4www.baidu.comif[$?!=0]thenecho-e"Error! Cant link to Internet"fiecho"current ip is $newip"