cobbler之ks

ks.cfg

yunPC kickstart
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
install
keyboard us
rootpw ctyun@123
timezone Asia/Shanghai
url --url=$tree
lang en_US
firewall --disabled
auth  --useshadow  --passalgo=sha512
text
selinux --disabled
skipx
bootloader --location=mbr --driveorder=sda
zerombr
clearpart --all --initlabel
part / --fstype ext4 --size=1 --grow  --ondisk sda
firstboot --disable

# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot

%packages
@core
lldpad
wget
ethtool
pciutils
%end

%pre
$SNIPPET('kickstart_start')
%end





%post
$SNIPPET('post_install_kernel_options')
$SNIPPET('ReadyunPC_csv')
$SNIPPET('CloudPC_conf_NETWORK')
$SNIPPET('lldp')
$SNIPPET('it_mac')
$SNIPPET('Set_SSHD')
$SNIPPET('kickstart_done')
%end


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ReadyunPC_csv   ##

cd /tmp
wget $file/yunPC.csv
sed -i 's/\r//g' yunPC.csv
#raw
dmidecode -s system-serial-number > serial
serialVar1=$(tail -n 1 serial)
serialVar2=$(echo $serialVar1|sed s/[[:space:]]//g)
eval $(awk -F "," -v serial=$serialVar2 '{if($1==serial){ printf("hostname=%s;mark=%s;ipa=%s;ipb=%s;ipc=%s;",$2,$3,$4,$5,$6)}}' yunPC.csv)
#end raw

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CloudPC_conf_NETWORK   ##


cd /etc/sysconfig/network-scripts/
#raw
j=0
for i in $(ip addr|grep mtu|grep -v lo |awk -F '[ |:]' '{print $3}' | sort )
do
ethtool $i|egrep '1000baseT/Full' &> /dev/null
[ $? -ne 0 ] && continue
ethtool $i|egrep '10000' &> /dev/null
[ $? -eq 0 ] && continue
dev[$j]=$i
let j++
done

cp ifcfg-eno5 ifcfg-eno5.bak
cp ifcfg-eno6 ifcfg-eno6.bak
cp ifcfg-ens1f0 ifcfg-ens1f0.bak
cp ifcfg-ens1f1 ifcfg-ens1f1.bak



cp ifcfg-${dev[0]} ifcfg-${dev[0]}.bak
cat >ifcfg-${dev[0]}<<EOF
DEVICE=${dev[0]}
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
EOF

cp ifcfg-${dev[1]} ifcfg-${dev[1]}.bak
cat >ifcfg-${dev[1]}<<EOF
DEVICE=${dev[1]}
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
EOF

touch ifcfg-bond0
cat >ifcfg-bond0<<EOF
DEVICE=bond0
TYPE=Ethernet
BOOTPROTO=static
IPV6INIT=no
BONDING_MASTER=yes
BONDING_OPTS="mode=0 miimon=100" 
ONBOOT=yes 
EOF

touch ifcfg-bond0.350
cat >ifcfg-bond0.350<<EOF
DEVICE=bond0.350
BOOTPROTO=static
IPADDR=${ipa}
NETMASK=255.255.255.0
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF

touch ifcfg-bond0.199
cat >ifcfg-bond0.199<<EOF
DEVICE=bond0.199
BOOTPROTO=dhcp
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF


if [ "$mark" = "comp" ] ; then

cat >ifcfg-eno5<<EOF
DEVICE=eno5
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond1
SLAVE=yes
EOF


cat >ifcfg-ens4f1<<EOF
DEVICE=ens4f1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond1
SLAVE=yes
EOF

touch ifcfg-bond1
cat >ifcfg-bond1<<EOF
DEVICE=bond1
TYPE=Ethernet
BOOTPROTO=static
IPV6INIT=no
BONDING_MASTER=yes
BONDING_OPTS="mode=1 miimon=100" 
ONBOOT=yes 
EOF

touch ifcfg-bond1.353
cat >ifcfg-bond1.353<<EOF
DEVICE=bond1.353
BOOTPROTO=static
IPADDR=${ipb}
NETMASK=255.255.252.0
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF


cat >ifcfg-eno6<<EOF
DEVICE=eno6
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond2
SLAVE=yes
EOF


cat >ifcfg-ens4f0<<EOF
DEVICE=ens4f0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond2
SLAVE=yes
EOF

touch ifcfg-bond2
cat >ifcfg-bond2<<EOF
DEVICE=bond2
TYPE=Ethernet
BOOTPROTO=static
IPV6INIT=no
BONDING_MASTER=yes
BONDING_OPTS="mode=1 miimon=100" 
ONBOOT=yes 
EOF

touch ifcfg-bond2.351
cat >ifcfg-bond2.351<<EOF
DEVICE=bond2.351
BOOTPROTO=static
IPADDR=${ipc}
NETMASK=255.255.255.0
GATEWAY=10.107.174.254
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF



touch ifcfg-bond2.354
cat >ifcfg-bond2.354<<EOF
DEVICE=bond2.354
BOOTPROTO=dhcp
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF

touch ifcfg-bond2.355
cat >ifcfg-bond2.355<<EOF
DEVICE=bond2.355
BOOTPROTO=dhcp
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF

fi



if [ "$mark" = "lvs" ] ; then

cat >ifcfg-eno5<<EOF
DEVICE=eno5
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond1
SLAVE=yes
EOF


cat >ifcfg-ens4f1<<EOF
DEVICE=ens4f1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond1
SLAVE=yes
EOF

touch ifcfg-bond1
cat >ifcfg-bond1<<EOF
DEVICE=bond1
TYPE=Ethernet
BOOTPROTO=static
IPV6INIT=no
BONDING_MASTER=yes
BONDING_OPTS="mode=1 miimon=100" 
ONBOOT=yes 
EOF

touch ifcfg-bond1.353
cat >ifcfg-bond1.353<<EOF
DEVICE=bond1.353
BOOTPROTO=static
IPADDR=${ipb}
NETMASK=255.255.252.0
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF


cat >ifcfg-eno6<<EOF
DEVICE=eno6
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond2
SLAVE=yes
EOF


cat >ifcfg-ens4f0<<EOF
DEVICE=ens4f0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond2
SLAVE=yes
EOF

touch ifcfg-bond2
cat >ifcfg-bond2<<EOF
DEVICE=bond2
TYPE=Ethernet
BOOTPROTO=static
IPV6INIT=no
BONDING_MASTER=yes
BONDING_OPTS="mode=1 miimon=100" 
ONBOOT=yes 
EOF

touch ifcfg-bond2.351
cat >ifcfg-bond2.351<<EOF
DEVICE=bond2.351
BOOTPROTO=static
IPADDR=${ipc}
NETMASK=255.255.255.0
GATEWAY=10.107.174.254
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF



touch ifcfg-bond1.354
cat >ifcfg-bond1.354<<EOF
DEVICE=bond1.354
BOOTPROTO=dhcp
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF

touch ifcfg-bond1.355
cat >ifcfg-bond1.355<<EOF
DEVICE=bond1.355
BOOTPROTO=dhcp
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF

fi



if [ "$mark" = "stor" ] ; then

cat >ifcfg-ens4f1<<EOF
DEVICE=ens4f1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond1
SLAVE=yes
EOF


cat >ifcfg-eno1<<EOF
DEVICE=eno1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond1
SLAVE=yes
EOF

touch ifcfg-bond1
cat >ifcfg-bond1<<EOF
DEVICE=bond1
TYPE=Ethernet
BOOTPROTO=static
IPV6INIT=no
BONDING_MASTER=yes
BONDING_OPTS="mode=1 miimon=100" 
ONBOOT=yes 
EOF

touch ifcfg-bond1.353
cat >ifcfg-bond1.353<<EOF
DEVICE=bond1.353
BOOTPROTO=static
IPADDR=${ipb}
NETMASK=255.255.252.0
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF


cat >ifcfg-ens4f0<<EOF
DEVICE=ens4f0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond3
SLAVE=yes
EOF


cat >ifcfg-eno2<<EOF
DEVICE=eno2
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond3
SLAVE=yes
EOF

touch ifcfg-bond3
cat >ifcfg-bond3<<EOF
DEVICE=bond3
TYPE=Ethernet
BOOTPROTO=static
IPV6INIT=no
BONDING_MASTER=yes
BONDING_OPTS="mode=1 miimon=100" 
ONBOOT=yes 
EOF

touch ifcfg-bond3.352
cat >ifcfg-bond3.352<<EOF
DEVICE=bond3.352
BOOTPROTO=static
IPADDR=${ipc}
NETMASK=255.255.254.0
IPV6INIT=no
ONBOOT=yes
VLAN=yes
EOF

fi

touch route-bond0.350
cat >route-bond0.350<<EOF
10.251.0.0/16 via 10.107.173.254 dev bond0.350
10.252.0.0/16 via 10.107.173.254 dev bond0.350
10.253.0.0/16 via 10.107.173.254 dev bond0.350
10.254.0.0/16 via 10.107.173.254 dev bond0.350
10.255.0.0/16 via 10.107.173.254 dev bond0.350
192.168.14.0/24 via 10.107.173.254 dev bond0.350
EOF

echo "${hostname}" > /etc/hostname

systemctl stop NetworkManager
systemctl disable NetworkManager

#end raw

 

上一篇:C#联合Kepware OPC与西门子S7-300PLC通讯


下一篇:VSCode 自定义Vue snippets, 快速生成Vue模板