echo "Running Software Installations" # Activate SSH package sudo apt-get -y install openssh-server #Install bc for calcluating ip address sudo apt-get -y install bc #Enable and start network service sudo systemctl enable systemd-networkd sudo systemctl start systemd-networkd # Fix for E3-1240V3 IPMI Hang sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"/g' /etc/default/grub #Fix diskfilter error: diskfilter writes are not supported cp -p /etc/grub.d/10_linux /etc/grub.d/10_linux.`date +%Y%m%d.%H%M` sed -i 's/quick_boot="1"/quick_boot="0"/' /etc/grub.d/10_linux sudo update-grub wget -q -O /dev/null 'http://192.168.200.2/automation/completeKickstartInstallationStep.php?kickstartInstallationId=76438&securityKey=btufftwuvpqiphkbkendicqtrybxnrzz&identifier=ubuntu20_04&percentComplete=50&message=Installing%20Software' # Install Software wget -q -O /dev/null 'http://192.168.200.2/automation/updateKickstartInstallationStatus.php?kickstartInstallationId=76438&securityKey=btufftwuvpqiphkbkendicqtrybxnrzz&percentComplete=95&message=Setting%20up%20SNMP' sudo apt-get install snmpd -y mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig service snmpd stop # Default Secured Servers echo 'rocommunity iuhet08532h\nsyslocation "PNAP, SecuredServers"\nsyscontact support@securedservers.com' > /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=76438&securityKey=btufftwuvpqiphkbkendicqtrybxnrzz&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) #Prepare Variables touch /etc/netplan/01-netplan2.yaml lastmask="" lastnet="" #Parse Given API Vars frontend_gateway_temp=66.85.130.89 frontend_netmask_temp=255.255.255.248 strnet=${frontend_gateway_temp%.*} lastnet=${frontend_gateway_temp##*.} lastmask=${frontend_netmask_temp##*.} #Get CIDR Notation and Amount of Addresses cidrbits=$(echo "obase=2;ibase=10;$lastmask"|bc|grep -o "1" | wc -l) cidrnet=$((cidrbits+24)) echo $cidrnet addrs="" addrcount=$((255-lastmask-2)) while [ $addrcount -ge 1 ] do addrs=$addrs"$strnet.$((lastnet+addrcount))/$cidrnet, " addrcount=$((addrcount-1)) done addrs=${addrs%,*} #remove last "," character from the string #Create Netplan Configuration printf "%s\n" "network:" > /etc/netplan/01-netplan2.yaml printf "%s\n" " version: 2" >> /etc/netplan/01-netplan2.yaml printf "%s\n" " renderer: networkd" >> /etc/netplan/01-netplan2.yaml printf "%s\n" " ethernets:" >> /etc/netplan/01-netplan2.yaml printf "%s\n" " $FRONTEND_INTERFACE:" >> /etc/netplan/01-netplan2.yaml printf "%s\n" " addresses: [ $addrs ]" >> /etc/netplan/01-netplan2.yaml printf "%s\n" " gateway4: 66.85.130.89" >> /etc/netplan/01-netplan2.yaml printf "%s\n" " nameservers:" >> /etc/netplan/01-netplan2.yaml printf "%s\n" " search: [ securedservers.com ]" >> /etc/netplan/01-netplan2.yaml printf "%s\n" " addresses: [ 8.8.8.8, 8.8.4.4 ]" >> /etc/netplan/01-netplan2.yaml #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 # finally attempt to inject root sh key #messenger "**** CONFIGURING AUTHORIZED KEYS ****" ## Inject public ssh key to root user in *any case* bacause it is just one ssh key and it is for root user messenger "sshKey is not defined, nothing inserted to authorized_keys" #Create a netplan script touch /netplan.sh chmod +x /netplan.sh echo "#!/bin/sh -e" > /netplan.sh echo "netplan apply" >> /netplan.sh echo "rm -f /netplan.sh" >> /netplan.sh echo "exit 0" >> /netplan.sh ###################################################################### # DELETE LVM_DELETE IF EXISTS - CUSTOM PARTITION INST # Must be done by first boot script # Wont work from this script even code is the same as in the Ubuntu 18 ###################################################################### echo "CREATE DELETE LVM SCRIPT" touch /delete_lvm_delete.sh chmod +x /delete_lvm_delete.sh echo "#!/bin/sh" > /delete_lvm_delete.sh echo "LVM_DELETE_EXIST=\`lvscan | grep \"delete\"\`" >> /delete_lvm_delete.sh echo "if [ -n \"\$LVM_DELETE_EXIST\" ];then" >> /delete_lvm_delete.sh echo "lvremove -f /dev/vg0/lvm_delete > /dev/null 2>&1" >> /delete_lvm_delete.sh echo "fi" >> /delete_lvm_delete.sh echo "rm -f /delete_lvm_delete.sh" >> /delete_lvm_delete.sh echo "exit 0" >> /delete_lvm_delete.sh ####################################################################### # Add the startup script to firstboot touch /etc/rc.local chmod +x /etc/rc.local echo "#!/bin/sh -e" > /etc/rc.local echo "sh /netplan.sh" >> /etc/rc.local echo "sh /delete_lvm_delete.sh" >> /etc/rc.local echo "rm -f /etc/rc.local" >> /etc/rc.local echo "exit 0" >> /etc/rc.local #Find the user for password expiration script USER='' USER=pnap24109 # Just one user? #Set password expiration in 2 days chage -M 2 root chage -M 2 "$USER" # All done here wget -T 30 -O /dev/null 'http://192.168.200.2/automation/completeKickstartInstallation.php?kickstartInstallationId=76438&securityKey=btufftwuvpqiphkbkendicqtrybxnrzz' echo "Done"