echo "Running Software Installations" # enable chef user to use sudo usermod -aG sudo chef # Activate SSH package # already listed openssh-server to install during preseed #sudo apt-get -y install openssh-server # Fix for E3-1240V3 IPMI Hang sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/GRUB_CMDLINE_LINUX_DEFAULT="splash"/g' /etc/default/grub sudo update-grub mkdir -pv /etc/systemd/system/networking.service.d/ # fix for long wait for interfaces to come up (in case backend interface is disabled ... it takes 5 minutes to boot) cat > /etc/systemd/system/networking.service.d/override.conf < /etc/snmp/snmpd.conf sed -i 's/ 127.0.0.1//g' /etc/default/snmpd sed -i 's/snmpd.pid/snmpd.pid -c \/etc\/snmp\/snmpd.conf/g' /etc/default/snmpd wget -q -O /dev/null 'http://192.168.200.2/automation/updateKickstartInstallationStatus.php?kickstartInstallationId=73494&securityKey=wivinlfevkofcgpotkptooyqrdftkcwh&percentComplete=99&message=Completing%20Installation' BACKEND_INTERFACE=$(ip ntable | grep dev | sort | uniq | sed -e 's/^.*dev //;/^lo/d' | head -n 1 | tail -n 1 | xargs) echo detected backend interface name: $BACKEND_INTERFACE FRONTEND_INTERFACE=$(ip ntable | grep dev | sort | uniq | sed -e 's/^.*dev //;/^lo/d' | head -n 2 | tail -n 1 | xargs) # Configure Network echo "# Loopback" > /etc/network/interfaces2 echo "auto lo" >> /etc/network/interfaces2 echo "iface lo inet loopback" >> /etc/network/interfaces2 echo "" >> /etc/network/interfaces2 echo "# Backend Interface" >> /etc/network/interfaces2 echo "auto $BACKEND_INTERFACE" >> /etc/network/interfaces2 echo "iface $BACKEND_INTERFACE inet static" >> /etc/network/interfaces2 echo "address 0.0.0.0" >> /etc/network/interfaces2 echo "netmask 255.255.255.255" >> /etc/network/interfaces2 echo "" >> /etc/network/interfaces2 echo "# Public Interfaces" >> /etc/network/interfaces2 echo "auto $FRONTEND_INTERFACE" >> /etc/network/interfaces2 echo "iface $FRONTEND_INTERFACE inet static" >> /etc/network/interfaces2 echo "address 66.85.140.34" >> /etc/network/interfaces2 echo "netmask 255.255.255.248" >> /etc/network/interfaces2 echo "gateway 66.85.140.33" >> /etc/network/interfaces2 # Name Servers echo "dns-search securedservers.com" >> /etc/network/interfaces2 echo "dns-nameservers 8.8.8.8 8.8.4.4" >> /etc/network/interfaces2 # Startup script echo "mv /etc/network/interfaces2 /etc/network/interfaces" > /root/initializeNetwork.sh echo "/etc/init.d/networking stop; /etc/init.d/networking start" >> /root/initializeNetwork.sh #echo "service networking restart" >> /root/initializeNetwork.sh echo "ifdown --exclude=lo -a && sudo ifup --exclude=lo -a" >> /root/initializeNetwork.sh echo "mv /etc/rc.local.bu /etc/rc.local" >> /root/initializeNetwork.sh echo "chmod +x /etc/rc.local" >> /root/initializeNetwork.sh echo "#rm /root/initializeNetwork.sh" >> /root/initializeNetwork.sh chmod +x /root/initializeNetwork.sh echo "" >> /etc/network/interfaces2 echo "auto $FRONTEND_INTERFACE:1" >> /etc/network/interfaces2 echo "iface $FRONTEND_INTERFACE:1 inet static" >> /etc/network/interfaces2 echo "address 66.85.140.35" >> /etc/network/interfaces2 echo "netmask 255.255.255.248" >> /etc/network/interfaces2 echo "" >> /etc/network/interfaces2 echo "auto $FRONTEND_INTERFACE:2" >> /etc/network/interfaces2 echo "iface $FRONTEND_INTERFACE:2 inet static" >> /etc/network/interfaces2 echo "address 66.85.140.36" >> /etc/network/interfaces2 echo "netmask 255.255.255.248" >> /etc/network/interfaces2 echo "" >> /etc/network/interfaces2 echo "auto $FRONTEND_INTERFACE:3" >> /etc/network/interfaces2 echo "iface $FRONTEND_INTERFACE:3 inet static" >> /etc/network/interfaces2 echo "address 66.85.140.37" >> /etc/network/interfaces2 echo "netmask 255.255.255.248" >> /etc/network/interfaces2 echo "" >> /etc/network/interfaces2 echo "auto $FRONTEND_INTERFACE:4" >> /etc/network/interfaces2 echo "iface $FRONTEND_INTERFACE:4 inet static" >> /etc/network/interfaces2 echo "address 66.85.140.38" >> /etc/network/interfaces2 echo "netmask 255.255.255.248" >> /etc/network/interfaces2 #this should blacklist the mei and mei_me modules as per ticket 848112 - #echo "\n#blacklisting the mei modules\n\n" >> /target/etc/modprobe.d/blacklist.conf #echo "blacklist mei" >> /target/etc/modprobe.d/blacklist.conf #echo "blacklist mei_me" >> /target/etc/modprobe.d/blacklist.conf #SWAP creation touch /root/swap-partition-creator.sh chmod +x /root/swap-partition-creator.sh echo "#!/bin/sh -e" > /root/swap-partition-creator.sh #echo 'SECOND_DISK=$(lsblk -nlp -o name,type | grep disk | awk -F" " '\''{print $1}'\'' | head -n 2 | tail -n 1)' >> /root/swap-partition-creator.sh echo 'SECOND_DISK=$(fdisk -l | grep -E '\''^Disk /dev/sd*|^Disk /dev/nvme*'\'' | tail -n 1 | awk '\''{print $2}'\'' | sed '\''s/://g'\'')' >> /root/swap-partition-creator.sh echo 'fdisk $SECOND_DISK << FDISK_CMDS' >> /root/swap-partition-creator.sh echo "d" >> /root/swap-partition-creator.sh echo "o" >> /root/swap-partition-creator.sh echo "n" >> /root/swap-partition-creator.sh echo "p" >> /root/swap-partition-creator.sh echo "" >> /root/swap-partition-creator.sh echo "" >> /root/swap-partition-creator.sh echo "" >> /root/swap-partition-creator.sh echo "t" >> /root/swap-partition-creator.sh echo "82" >> /root/swap-partition-creator.sh echo "w" >> /root/swap-partition-creator.sh echo "FDISK_CMDS" >> /root/swap-partition-creator.sh #find swap partition #echo 'SWAP_PARTITION=$(lsblk -nlp -o name,type | grep part | awk -F" " '\''{print $1}'\'' | head -n 2 | tail -n 1)' >> /root/swap-partition-creator.sh echo 'SWAP_PARTITION=$(fdisk -l | grep -E '\''^/dev/sd*|^/dev/nvme*'\'' | tail -n 1 | awk '\''{print $1}'\'')' >> /root/swap-partition-creator.sh echo 'mkswap $SWAP_PARTITION' >> /root/swap-partition-creator.sh echo 'swapon $SWAP_PARTITION' >> /root/swap-partition-creator.sh echo 'echo "$SWAP_PARTITION swap swap defaults 0 0" >> /etc/fstab' >> /root/swap-partition-creator.sh echo "rm -f /root/swap-partition-creator.sh" >> /root/swap-partition-creator.sh echo "exit 0" >> /root/swap-partition-creator.sh # Add the startup script to firstboot cp /etc/rc.local /etc/rc.local.bu echo "#!/bin/sh -e" > /etc/rc.local echo "" >> /etc/rc.local echo "/root/swap-partition-creator.sh" >> /etc/rc.local echo "/root/initializeNetwork.sh" >> /etc/rc.local echo "exit 0" >> /etc/rc.local chmod +x /etc/rc.local # inject SSH key for user chef messenger "Inserting sshKey to /home/chef/.ssh/authorized_keys" #dir must be 700 file must be 644 or it won't work. mkdir -p -m 755 /home/chef/.ssh chmod 755 /home/chef/.ssh chown chef:chef /home/chef/.ssh echo ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1IfMy2VAX7pX2nwKCAnah3ri3yTLnpImYuLm1QTr4r/EFHyJU5YfKMhVKbbSN2j2TrrYkJ0aLy4Ht+YtXOhJfXVQNGLAJdcm3DFhwL6LKfTpaMKxBPjCuUuwy1w+ZxWIy1HPbW2DGg2wlE4kccLpRRF28zW0ntF2PdDescwk19V1dU7HeYpjZZ9s2HnMqo6UgR8EIqb6NGeq2K+JpnS4hipO+HAf/HEkAv+h/I5Q3T1OO1LC3/lIav61wkqqin9IWME2RLHSV/N8eyZZRSBsxj2eBAJ94Firz+OmSEFvkR8FtMrKlWcfNFlhMnDprJ6MuShSs0fvrGGNl+DlF0baR chef > /home/chef/.ssh/authorized_keys messenger "sshKey was not provided" chmod 644 /home/chef/.ssh/authorized_keys chown chef:chef /home/chef/.ssh/authorized_keys cat /home/chef/.ssh/authorized_keys | wc -l ls -la /home/chef/.ssh/ # All done here wget --tries=2 -T 30 -O /dev/null 'http://192.168.200.2/automation/completeKickstartInstallation.php?kickstartInstallationId=73494&securityKey=wivinlfevkofcgpotkptooyqrdftkcwh' echo "Done" #delete this script rm -- "$0"