#Create /etc/rc.local touch /target/etc/rc.local chmod +x /target/etc/rc.local echo "/target/etc/rc.local created...." # udevadm tool can provide us with a link from old to new name # udevadm info -e > /root/udevadm ETH0=$(udevadm info /sys/class/net/eth0| grep 'E: ID_NET_NAME_PATH' | sed 's/E: ID_NET_NAME_PATH=//') ETH1=$(udevadm info /sys/class/net/eth1| grep 'E: ID_NET_NAME_PATH' | sed 's/E: ID_NET_NAME_PATH=//') echo "Running Software Installations" # Install Software wget -q -O /dev/null 'http://192.168.200.2/automation/updateKickstartInstallationStatus.php?kickstartInstallationId=75758&securityKey=kgcqsmejmnivozfzcluzctljvlwavxzv&percentComplete=99&message=Completing%20Installation' # Configure Network # Debian will reset the configurations on first boot # Save to a second file, and have a startup script move the file over echo "CONFIGURE NETWORK SCRIPT" echo "auto lo" > /target/etc/network/interfaces echo "iface lo inet loopback" >> /target/etc/network/interfaces echo "" >> /target/etc/network/interfaces echo "auto $ETH0" >> /target/etc/network/interfaces echo "iface $ETH0 inet static" >> /target/etc/network/interfaces echo "address 0.0.0.0" >> /target/etc/network/interfaces echo "netmask 255.255.255.255" >> /target/etc/network/interfaces echo "" >> /target/etc/network/interfaces echo "auto $ETH1" >> /target/etc/network/interfaces echo "iface $ETH1 inet static" >> /target/etc/network/interfaces echo "address 0.0.0.0" >> /target/etc/network/interfaces echo "netmask 255.255.255.255" >> /target/etc/network/interfaces echo "gateway 0.0.0.0" >> /target/etc/network/interfaces # Name Servers echo "dns-search securedservers.com" >> /target/etc/network/interfaces echo "dns-nameservers 8.8.8.8 8.8.4.4" >> /target/etc/network/interfaces echo "nameserver 8.8.8.8" > /target/etc/resolv.conf echo "nameserver 8.8.4.4" >> /target/etc/resolv.conf echo "/etc/init.d/networking stop; /etc/init.d/networking start" > /target/root/initializeNetwork.sh echo "rm -f /root/initializeNetwork.sh" >> /target/root/initializeNetwork.sh chmod +x /target/root/initializeNetwork.sh ############################################################################# # SNMPD ############################################################################# echo "CREATE SNMPD NETWORK SCRIPT" #Snmpd service installation script #trying to `apt-get install -y snmpd` from here errors out #error is caused when Processing triggers for man-db #system is unable to find a file #handling snmpd install like this now (cat <<'EOF' # preseeded snmpd package so no install is needed # apt-get install -y snmpd mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig echo 'rocommunity iuhet08532h\nsyslocation "PNAP, SecuredServers"\nsyscontact support@securedservers.com' > /etc/snmp/snmpd.conf sed -i "s/SNMPDOPTS=.*$/SNMPDOPTS='-Lsd -Lf \/dev\/null -u snmp -I -smux -p \/var\/run\/snmpd.pid -c \/etc\/snmp\/snmpd.conf'/" /etc/default/snmpd rm -f /root/installSnmpd.sh /etc/init.d/snmpd restart EOF ) > /target/root/installSnmpd.sh chmod +x /target/root/installSnmpd.sh ############################################################################# # PASSWORD EXPIRATION ############################################################################# echo "CREATE PASSWORD EXPIRATION SCRIPT" USER='' USER=ss1696 # Just one user? #Create password expiration script touch /target/root/setPasswordExpiration.sh chmod +x /target/root/setPasswordExpiration.sh echo "#!/bin/sh -e" > /target/root/setPasswordExpiration.sh echo "chage -M 2 root" >> /target/root/setPasswordExpiration.sh echo "chage -M 2 $USER" >> /target/root/setPasswordExpiration.sh echo "rm -f /root/setPasswordExpiration.sh" >> /target/root/setPasswordExpiration.sh echo "exit 0" >> /target/root/setPasswordExpiration.sh echo "CREATE PASSWORD EXPIRATION SCRIPT COMPLETED" ############################################################################ # SET NIC0 AS 1ST BOOT DEVICE UEFI ############################################################################ echo "CREATE 1ST BOOT DEVICE SCRIPT" touch /target/root/setNetworkFisrtBootBiosUefi.sh chmod +x /target/root/setNetworkFisrtBootBiosUefi.sh echo "#!/bin/sh -e" > /target/root/setNetworkFisrtBootBiosUefi.sh echo "IP4=\`efibootmgr | grep \"IP4\"\`" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "if [ -z \"\$IP4\" ];then" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "NIC0=\`efibootmgr | grep \"IPv4\" | head -n 1 | sed 's/*.*//' | sed 's/Boot//g'\`" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "else" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "NIC0=\`efibootmgr | grep \"IP4\" | head -n 1 | sed 's/*.*//' | sed 's/Boot//g'\`" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "fi" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "BOOT_ORDER_NO_NIC0=\`efibootmgr | awk '/BootOrder/ { print \$2 }' | sed \"s/,\$NIC0//g\"\`" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "NEW_BOOT_ORDER=\"\$NIC0,\$BOOT_ORDER_NO_NIC0\"" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "efibootmgr -o \$NEW_BOOT_ORDER" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "rm -f /root/setNetworkFisrtBootBiosUefi.sh" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "exit 0" >> /target/root/setNetworkFisrtBootBiosUefi.sh echo "CREATE 1ST BOOT DEVICE SCRIPT COMPLETED" ############################################################################# # FIRST BOOT SCRIPT ############################################################################# echo "CREATE 1ST REBOOT SCRIPT" # Add the startup script to firstboot # Also install network, snmpd and password expiration on the startup. echo "#!/bin/sh -e" > /target/etc/rc.local echo "" >> /target/etc/rc.local echo "sh /root/initializeNetwork.sh" >> /target/etc/rc.local echo "sh /root/installSnmpd.sh" >> /target/etc/rc.local echo "sh /root/setPasswordExpiration.sh" >> /target/etc/rc.local echo "sh /root/setNetworkFisrtBootBiosUefi.sh" >> /target/etc/rc.local echo "rm -f /etc/rc.local" >> /target/etc/rc.local echo "exit 0" >> /target/etc/rc.local echo "CREATE 1ST REBOOT SCRIPT DONE" # All done here # after this is executed, backend interface is removed from kickstart vlan so internet *has* to work for snmp install to complete # no need to wait for reply hence 5 seconds timeout wget --tries=1 -T 5 -O /dev/null 'http://192.168.200.2/automation/completeKickstartInstallation.php?kickstartInstallationId=75758&securityKey=kgcqsmejmnivozfzcluzctljvlwavxzv' echo "Kickstart installation completed" echo "END"