DREN/Kickstart/snippets: Difference between revisions

From DER's LLC
Jump to navigation Jump to search
No edit summary
 
Line 592: Line 592:
  #end raw
  #end raw


= | StatusBarScript =
= StatusBarScript =
  #raw
  #raw
  echo 'until [ "1" -eq "0" ]; do' > /tmp/status.sh
  echo 'until [ "1" -eq "0" ]; do' > /tmp/status.sh

Latest revision as of 19:36, 2 June 2023

AddADGroups

#raw
printf " Adding AD Groups:                                                           "
/bin/bash /tmp/status.sh &

groupadd domain_users -g 1342600513

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

AddAcasUser

#raw
printf " Creating ACAS Scan User:                                                    "
/bin/bash /tmp/status.sh &

useradd scan_account -g users
sudo -u scan_account ssh-keygen -b 2048 -t rsa -f /home/scan_account/.ssh/id_rsa -q -N ""
sudo -u scan_account rm -rf /home/scan_account/.ssh/id_rsa 
sudo -u scan_account curl --cacert /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT https://rdhpwngmp-01/pub/kickstart/nga_acas.pub >  /home/scan_account/.ssh/authorized_keys

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

AddMounts

#raw
printf " Adding NFS Mounts:                                                          "
/bin/bash /tmp/status.sh &

mkdir -p /users
chown :domain_users /users
chmod 775 /users
mkdir -p /data
chown :domain_users /data
chmod 775 /data
echo 'users:/users  /users  nfs noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,relatime    0 0' >> /etc/fstab
echo 'data:/data  /data  nfs noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,relatime    0 0' >> /etc/fstab

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

AddScaleUser

#raw
printf " Creating Scale User:                                                    "
/bin/bash /tmp/status.sh &

useradd scale -u 7498 -g 1342600513 -G users
sed -i 's~scale:!!:~scale:$6$hQ5XU8FI$BFssO833kwMzahuVXMnMO9qReK4VRAXtMKRL/csxtJoFtj7Wgc9twzp6E79jw8y.U/JfSqMhzMafhijnISiyh1:~' /etc/shadow

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

AddSpacewalkToHosts

#raw
printf " Adding Spacewalk server to /etc/hosts:                                              "
/bin/bash /tmp/status.sh &
curl http://140.32.192.51/pub/kickstart/hosts > /mnt/sysimage/etc/hosts
curl http://140.32.192.51/pub/kickstart/hosts > /etc/hosts
STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

ForceTime

printf " Forcing Time Synce with NTP Server:                                         "
/bin/bash /tmp/status.sh &
ntpdate -s 140.32.191.249
STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"

InstallDCOSMaster

#raw
printf " Installing DCOS Master:                                                     "
/bin/bash /tmp/status.sh &
#end raw
$SNIPPET('spacewalk/1/InstallDCOSPrereqs')
#raw
# This is needed for using the dcos command with jenkins 
yum -y install expect &> /dev/null

# Creating installDCOS.sh script 
echo "#CHECK=\`systemctl is-active docker\`"  > /root/installDCOS.sh
echo "#while \$CHECK != 'active' ; do sleep 5; CHECK=\`systemctl is-active docker\`;done"  >> /root/installDCOS.sh
echo "/bin/bash /tmp/dcos/dcos_install.sh master" >> /root/installDCOS.sh
echo "mkdir -p /var/log/mesos/archive" >> /root/installDCOS.sh
echo "echo 'ENABLE_CHECK_TIME=false' >> /opt/mesosphere/environment" >> /root/installDCOS.sh
echo "#sleep 6000" >> /root/installDCOS.sh
echo "#rm -rf /root/installDCOS.sh" >> /root/installDCOS.sh
echo "sed -i 's/\/bin\/bash\ \/root\/installDCOS.sh//g' /etc/rc.d/rc.local" >> /root/installDCOS.sh
echo "sed -i 's~LD_LIBRARY_PATH=/opt/mesosphere/lib~LD_LIBRARY_PATH=/lib64~' /opt/mesosphere/environment.export"  >> /root/installDCOS.sh
echo "curl -fLsS --retry 20 -Y 100000 -y 60 https://downloads.dcos.io/binaries/cli/linux/x86-64/dcos-1.8/dcos -o dcos"  >> /root/installDCOS.sh
echo "mv dcos /usr/local/bin"  >> /root/installDCOS.sh
echo "chmod +x /usr/local/bin/dcos"  >> /root/installDCOS.sh
echo "dcos config set core.dcos_url http://172.16.99.200"  >> /root/installDCOS.sh

chmod 777 /root/installDCOS.sh
echo "/bin/bash /root/installDCOS.sh" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

InstallDCOSPrereqs

echo "proxy=http://192.168.1.73:3128" >> /etc/yum.conf
yum -y install ipset tar xz unzip curl docker docker-selinux &> /dev/null
yum -y upgrade &> /dev/null

grep -q Restart=on-failure /usr/lib/systemd/system/docker.service && printf 'Restart function is already set in systemd script' || sed -i '/MountFlags=slave/aRestart=on-failure' /usr/lib/systemd/system/docker.service
rhncfg-client get
systemctl daemon-reload  
systemctl enable docker.service
systemctl start docker.service

# DCOS requires this firewall to be shut off.
## https://docs.mesosphere.com/1.7/administration/installing/custom/system-requirements/
systemctl disable firewalld
systemctl stop firewalld

mkdir -p /var/{lib,log}/mesos
chown nobody /var/{lib,log}/mesos
touch /var/marathon.ip
chown /var/marathon.ip

groupadd nogroup -g 9999
groupadd docker

yum -y remove dnsmasq &> /dev/null
PIDS=`ps -ef | grep dnsmasq | egrep -v grep | awk '{ print $2 }'`
kill $PIDS
mkdir -p /tmp/dcos && cd /tmp/dcos
#curl -s http://140.32.192.51/dcos/install/genconf/serve/dcos_install.sh > dcos_install.sh
curl -s http://192.168.1.73:81/dcos/genconf/serve/dcos_install.sh > dcos_install.sh

InstallDCOSSlave

#raw
printf " Installing DCOS Slave:                                                      "
/bin/bash /tmp/status.sh &
#end raw
$SNIPPET('spacewalk/1/InstallDCOSPrereqs')
#raw
echo "setenforce 0"  > /root/installDCOS.sh
echo "#CHECK=\`systemctl is-active docker\`"  >> /root/installDCOS.sh
echo "#while \$CHECK != 'active' ; do sleep 5; CHECK=\`systemctl is-active docker\`;done"  >> /root/installDCOS.sh
echo "/bin/bash /tmp/dcos/dcos_install.sh slave" >> /root/installDCOS.sh
echo "DCOS_CONFIG=\`grep -ir 'MESOS_HOSTNAME_LOOKUP=false' /opt/mesosphere/packages/dcos-config* | grep mesos-slave-common | cut -d ':' -f 1\`"  >> /root/installDCOS.sh
echo "for i in \$DCOS_CONFIG; do sed -i 's~MESOS_HOSTNAME_LOOKUP=.*~MESOS_HOSTNAME_LOOKUP=true~' \$i; done"  >> /root/installDCOS.sh
echo "rm -rf /var/lib/mesos/slave/meta/slaves/latest" >> /root/installDCOS.sh
echo "echo 'ENABLE_CHECK_TIME=false' >> /opt/mesosphere/environment" >> /root/installDCOS.sh
echo "#sleep 6000" >> /root/installDCOS.sh
echo "#rm -rf /root/installDCOS.sh" >> /root/installDCOS.sh
echo "sed -i 's/\/bin\/bash\ \/root\/installDCOS.sh//g' /etc/rc.d/rc.local" >> /root/installDCOS.sh
echo "sed -i 's~LD_LIBRARY_PATH=/opt/mesosphere/lib~LD_LIBRARY_PATH=/lib64~' /opt/mesosphere/environment.export"  >> /root/installDCOS.sh

chmod 777 /root/installDCOS.sh
echo "/bin/bash /root/installDCOS.sh" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

InstallDesktopPackages

#raw
printf " Installing GNOME Desktop Packages:                                          "
/bin/bash /tmp/status.sh &
yum -y --nogpgcheck groupinstall "GNOME Desktop" &> /dev/null
sed -i 's/id:3:/id:5:/' /etc/inittab
systemctl set-default graphical.target
rm -f /etc/xdg/autostart/gnome-initial-setup-first-login.desktop &> /dev/null
rm -f /etc/xdg/autostart/gnome-initial-setup-copy-worker.desktop &> /dev/null
rm -f /etc/xdg/autostart/gnome-welcome-tour.desktop &> /dev/null
sed -i '/daemon/a InitialSetupEnable=False' /etc/gdm/custom.conf
STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

InstallVMTools

#raw
if grep -i vmware) ; then
   printf " Installing VMware Tools:                                                    "
   /bin/bash /tmp/status.sh &
   yum -y install open-vm-tools
   STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
   kill $STATUSPID
   printf "\b\b\b\b\b\b\b\b"
   echo -e "[  \e[1;32mOK\e[0;39m  ]"
fi
#end raw

JoinAD

#raw
printf " Creating /root/joinAD.sh:                                                   "
/bin/bash /tmp/status.sh &

yum install -y realmd samba samba-common oddjob oddjob-mkhomedir sssd adcli sssd-tools samba-libs krb5-workstation &> /dev/null
echo 'read -p "Enter Admin Username: " USERNAME' > /root/joinAD.sh
echo 'yum install -y realmd samba samba-common oddjob oddjob-mkhomedir sssd adcli sssd-tools samba-libs krb5-workstation &> /dev/null' >> /root/joinAD.sh
echo 'rhncfg-client get &> /dev/null' >> /root/joinAD.sh
echo 'realm leave' >> /root/joinAD.sh
echo 'sleep 5' >> /root/joinAD.sh
echo 'realm join --user=$USERNAME "711hpw.afrl-wrs.hpc.mil"' >> /root/joinAD.sh
echo 'sleep 15' >> /root/joinAD.sh
echo 'systemctl stop sssd' >> /root/joinAD.sh
echo 'rm -rf /var/lib/sss/db/*' >> /root/joinAD.sh
echo 'rhncfg-client get &> /dev/null' >> /root/joinAD.sh
echo 'systemctl start sssd' >> /root/joinAD.sh
echo 'sleep 10' >> /root/joinAD.sh
echo 'systemctl restart sssd' >> /root/joinAD.sh
chmod 777 /root/joinAD.sh

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

PostNoChroot-InstallNetworking

$SNIPPET('spacewalk/1/StatusBarScript')
$SNIPPET('spacewalk/1/SwitchToTTY7')
#raw
# Set-Hostname-Network Snippet
printf " Setting up Networking:                                                      "
/bin/bash /tmp/status.sh &
PID=`ps -ef | grep status.sh | egrep -v grep | sed 's/\ \ \ \ /\ /g' | sed 's/\ \ \ /\ /g' | sed 's/\ \ /\ /g' | cut -d ' ' -f 2`
\cp -f /tmp/network /mnt/sysimage/etc/sysconfig/network
\cp -f /tmp/hostname /mnt/sysimage/tmp/hostname
\cp -f /tmp/newnic.txt /mnt/sysimage/tmp/newnic.txt
\cp -f /tmp/nics.txt /mnt/sysimage/tmp/nics.txt
NAME`grep HOSTNAME /tmp/hostname | cut -d "=" -f 2`
/mnt/sysimage/usr/bin/hostname ${NAME} &> /dev/null
/mnt/sysimage/usr/bin/hostnamectl set-hostname ${NAME} &> /dev/null
/bin/hostname ${NAME} &> /dev/null
/bin/hostnamectl set-hostname ${NAME} &> /dev/null
/mnt/sysimage/bin/hostname ${NAME} &> /dev/null
/mnt/sysimage/bin/hostnamectl set-hostname ${NAME} &> /dev/null
DEVICE1=`cat /tmp/newnic.txt`
\cp -f /tmp/ifcfg-${DEVICE1} /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-${DEVICE1}
\cp -f /tmp/ifcfg-${DEVICE1} /mnt/sysimage/tmp/ifcfg-${DEVICE1}
while read NIC
do
 \cp -f /tmp/ifcfg-${NIC} /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-${NIC}
 \cp -f /tmp/ifcfg-${NIC} /mnt/sysimage/tmp/ifcfg-${NIC}
done < /tmp/nics.txt
\cp -f /tmp/newnic.txt /mnt/sysimage/tmp/newnic.txt
\cp -f /tmp/nics.txt /mnt/sysimage/tmp/nics.txt
kill $PID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
printf " Setting up DNS:                                                             "
/bin/bash /tmp/status.sh &
\cp -f /tmp/resolv.conf /mnt/sysimage/etc/resolv.conf
PID=`ps -ef | grep status.sh | egrep -v grep | sed 's/\ \ \ \ /\ /g' | sed 's/\ \ \ /\ /g' | sed 's/\ \ /\ /g' | cut -d ' ' -f 2`
kill $PID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw
$SNIPPET('spacewalk/1/SwitchToTTY1')

PreScript Get-Hostname-Network

$SNIPPET('spacewalk/1/SwitchToTTY7')
#raw
# Get-Hostname-Network Snippet
uname -r | grep -q el7 && OS7=True || OS7=False
uname -r | grep -q el6 && OS6=True || OS6=False
SEP7="#########################################################################################"
LINE7="-----------------------------------------------------------------------------------------"
SEP6="#####################################################################"
LINE6="---------------------------------------------------------------------"
SPACE="                            "
TITLE1="\e[4;32m"
TITLE2="\e[39;0m"
QUESTION1="\e[31;1m"
QUESTION2="\e[39;0m"

if $OS7 = "True" ; then
 setterm -powersave off -blank 0
 DNS1=`nmcli device show | grep DNS | sed 's/\ //g' | cut -d ':' -f 2 | head -1`
 DNS2=`nmcli device show | grep DNS | sed 's/\ //g' | cut -d ':' -f 2 | head -2 | tail -1`
 DOMAIN1=`nmcli device show | grep DOMAIN | sed 's/\ //g' | cut -d ':' -f 2`
 GW1=`nmcli device show | grep GATEWAY | sed 's/\ //g' | cut -d ':' -f 2 | head -1`
 DEVICE=`nmcli device | grep ' connected ' | cut -d ' ' -f 1`
 NM1=`ifconfig | grep netmask | sed 's/.*\ 255/255/' | head -1 | cut -d ' ' -f 1`
 echo $SEP7
 echo -e $SPACE $TITLE1 "DISCOVERED VARIABLES" $TITLE2
 echo $LINE7
fi
if $OS6 = "True" ; then
 DNS1=`cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2 | head -1`
 DNS2=`cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2 | head -2 | tail -1`
 DOMAIN1=`cat /etc/resolv.conf | grep domain | cut -d ' ' -f 2 | head -1`
 GW1=`ip route show | grep default | cut -d ' ' -f 3`
 DEVICE=`ip addr show | grep inet | grep brd | cut -d ' ' -f 11`
 NM1=`ifconfig | grep Mask | sed 's/.*\ 255\255/' | head -1 | cut -d ':' -f 4`
 echo $SEP6
 echo -e $SPACE $TITLE1 "DISCOVERED VARIABLES" $TITLE2
 echo $LINE6
fi
NICNUM=`ip link show | grep ": " | egrep -v lo | wc -l`
ip link show | grep ": " | egrep -v lo | cut -d ':' -f 2 | cut -d ' ' -f 2 > /tmp/nics.txt
LINKNUM=0
COUNT=1
while read NIC
 do 
   LINK1=`ethtool ${NIC} | grep "Link detected:" | cut -d ':' -f 2 | sed 's/\ //'`
   if $LINK1 = "yes" ; then
     let LINKNUM=LINKNUM+1
     LINKCHOICE=$COUNT
   fi
   let COUNT=COUNT+1
done < /tmp/nics.txt
echo -e ' DNS1 Server:\t\t\t'${DNS1}
echo -e ' DNS2 Server:\t\t\t'${DNS2}
echo -e ' Domain Name:\t\t\t'${DOMAIN1}
echo -e ' Current Network Device:\t'${DEVICE}
echo -e ' Number of Network Devices:\t'${NICNUM}
echo -e ' Gateway:\t\t\t'${GW1}
echo -e ' Netmask:\t\t\t'${NM1}
if [ $NICNUM -ne 1 ]; then
 if [ $LINKNUM -ne 1 ]; then
  if $OS7 = "True" ; then
   echo $SEP7
   echo -e $QUESTION1 "WHAT NETWORK DEVICE DO YOU WANT THIS SERVER TO USE?" $QUESTION2
   echo -e " Note: This kickstart will continue to use the \e[31m"${DEVICE}"\e[39m for the installation."
   echo " Note: If you choose nothing it will default to option 1."
   echo $LINE7
  fi
  if $OS6 = "True" ; then
   echo $SEP6
   echo -e $QUESTION1 "WHAT NETWORK DEVICE DO YOU WANT THIS SERVER TO USE?" $QUESTION2
   echo -e " Note: This kickstart will continue to use the \e[31m"${DEVICE}"\e[39m for the installation."
   echo " Note: If you choose nothing it will default to option 1."
   echo $LINE6
  fi
  COUNT=1
  while read NIC
  do
   LINK=`ethtool ${NIC} | grep "Link detected:" | cut -d ':' -f 2 | sed 's/\ //'`
   echo -e " $COUNT:		DEVICE:\t\t$NIC"
   DRIVER=`ethtool -i ${NIC} | grep driver | cut -d ':' -f 2 | sed 's/\ //'`
   echo -e "		DRIVER:\t\t$DRIVER"
   TENG=`ethtool -i ${NIC} | grep baseT | grep 10000 | wc -l`
   if [ TENG -eq 0 ]; then 
    ONEG=`ethtool -i ${NIC} | grep baseT | grep 1000 | wc -l`
    if [ ONEG -eq 0 ]; then
     echo "NOT 1G Networking" > /dev/null
    else
     echo -e "		SPEED:\t\t1G"
    fi
   else
    echo -e "		SPEED:\t\t10G"
   fi
   echo -e "		LINK:\t\t$LINK"
   if $OS7 = "True" ; then
    echo $LINE7
   fi
   if $OS6 = "True" ; then
    echo $LINE6
   fi
   let COUNT=COUNT+1
  done < /tmp/nics.txt
  printf "		"
  read NICCHOICE
 else
  NICCHOICE=$LINKCHOICE
 fi
  if [ -z $NICCHOICE ]; then NICCHOICE=1; fi
fi
CMD='cat /tmp/nics.txt | head -'$NICCHOICE' | tail -1'
DEVICE1=`eval $CMD`
if $OS7 = "True" ; then
 echo $SEP7
 echo -e $QUESTION1 "WHAT HOSTNAME DO YOU WANT THIS SERVER TO USE?" $QUESTION2
 echo " Note: If this hostname is already in DNS you will NOT need to enter an IP address."
 echo $LINE7 
fi
if $OS6 = "True" ; then
 echo $SEP6
 echo -e $QUESTION1 "WHAT HOSTNAME DO YOU WANT THIS SERVER TO USE?" $QUESTION2
 echo " Note: If this hostname is already in DNS you will NOT need to enter an IP address."
 echo $LINE6
fi
printf "		"
if [ -f "/tmp/pre_install_network_config" ]; then
  NAME=`cat /tmp/pre_install_network_config | sed 's/.*--hostname=//' | cut -d '.' -f 1`
  echo $NAME
else
  read NAME
fi
echo ""
NAME1=`nslookup ${NAME} ${DNS1} | grep Name | head -1 | cut -f 2`
if [[ -z ${NAME1} ]]; then
 NAME=`echo ${NAME}.${DOMAIN1}`
else
 NAME=`echo ${NAME1}`
fi
/bin/hostnamectl set-hostname ${NAME}
ADDR=`cat /etc/hosts | grep -i ${NAME} | egrep -v KVM | awk '{ print $1 }'`
if [[ -z ${ADDR} ]]; then
 ADDR=`nslookup ${NAME} ${DNS1} | tail -2 | head -1 | cut -d ' ' -f 2`
fi
if [[ "${ADDR}" == "server" ]]; then
 if $OS7 = "True" ; then
  echo $SEP7
  echo -e $QUESTION1 "WHAT IP ADDRESS DO YOU WANT THIS SERVER TO USE?" $QUESTION2
  echo $LINE7
 fi
 if $OS6 = "True" ; then
  echo $SEP6
  echo -e $QUESTION1 "WHAT IP ADDRESS DO YOU WANT THIS SERVER TO USE?" $QUESTION2
  echo $LINE6
 fi
 printf "		"
 read ADDR
 echo ""
fi
if $OS7 = "True" ; then
 echo $SEP7
 echo -e $SPACE $TITLE1 "USER DEFINED VARIABLES" $TITLE2
 echo $LINE7
fi
if $OS6 = "True" ; then
 echo $SEP6
 echo -e $SPACE $TITLE1 "USER DEFINED VARIABLES" $TITLE2
 echo $LINE6
fi
echo -e " Hostname:\t\t"${NAME}
echo -e " IP Address:\t\t"${ADDR}
echo -e " Network Device:\t"${DEVICE1}
if $OS7 = "True" ; then
 echo $SEP7
fi
if $OS6 = "True" ; then
 echo $SEP6
fi

echo ${NAME} > /tmp/hostname
echo ${DEVICE1} > /tmp/newnic.txt
sed -i '/'$DEVICE1'/d' /tmp/nics.txt
echo "# GENERATED BY GET-HOSTNAME-NETWORK SNIPPET" > /tmp/network
echo "NETWORKING=yes" >> /tmp/network
echo "HOSTNAME="${NAME} >> /tmp/network
echo "GATEWAY="${GW1} >> /tmp/network

echo "# GENERATED BY GET-HOSTNAME-NETWORK SNIPPET" > /tmp/ifcfg-${DEVICE1}
echo "DEVICE="${DEVICE1} >> /tmp/ifcfg-${DEVICE1}
echo "BOOTPROTO=none" >> /tmp/ifcfg-${DEVICE1}
echo "IPV6INIT=no" >> /tmp/ifcfg-${DEVICE1}
echo "MTU=1500" >> /tmp/ifcfg-${DEVICE1}
echo "NM_CONTROLLED=no" >> /tmp/ifcfg-${DEVICE1}
echo "ONBOOT=yes" >> /tmp/ifcfg-${DEVICE1}
echo "TYPE=Ethernet" >> /tmp/ifcfg-${DEVICE1}
echo "IPADDR="${ADDR} >> /tmp/ifcfg-${DEVICE1}
echo "NETMASK="${NM1} >> /tmp/ifcfg-${DEVICE1}
echo "GATEWAY="${GW1} >> /tmp/ifcfg-${DEVICE1}
echo "DNS1="${DNS1} >> /tmp/ifcfg-${DEVICE1}
echo "DNS2="${DNS2} >> /tmp/ifcfg-${DEVICE1}
echo "DOMAIN="${DOMAIN1} >> /tmp/ifcfg-${DEVICE1}
while read NIC1
do
 echo "# GENERATED BY GET-HOSTNAME-NETWORK SNIPPET" > /tmp/ifcfg-${NIC1}
 echo "DEVICE="${NIC1} >> /tmp/ifcfg-${NIC1}
 echo "BOOTPROTO=none" >> /tmp/ifcfg-${NIC1}
 echo "IPV6INIT=no" >> /tmp/ifcfg-${NIC1}
 echo "MTU=1500" >> /tmp/ifcfg-${NIC1}
 echo "NM_CONTROLLED=no" >> /tmp/ifcfg-${NIC1}
 echo "ONBOOT=no" >> /tmp/ifcfg-${NIC1}
done < /tmp/nics.txt
echo "# GENERATED BY GET-HOSTNAME-NETWORK SNIPPET" > /tmp/resolv.conf
echo "search "${DOMAIN1} >> /tmp/resolv.conf
echo "nameserver "${DNS1} >> /tmp/resolv.conf
echo "nameserver "${DNS2} >> /tmp/resolv.conf

if $OS7 = "True" ; then
 echo -e $SPACE $TITLE1 "BEGINNING INSTALLATION" $TITLE2
 echo " Note: Press Ctrl+Alt+F1 to See Progress"
 echo $SEP7
fi
if $OS6 = "True" ; then
 echo -e $SPACE $TITLE1 "BEGINNING INSTALLATION" $TITLE2
 echo " Note: Press Ctrl+Alt+F1 to See Progress"
 echo $SEP6
fi
#end raw
$SNIPPET('spacewalk/1/SwitchToTTY1')

RemoveNetworkManager

#raw
printf " Removing NetworkManager:                                                    "
/bin/bash /tmp/status.sh &

yum -y remove NetworkManager &> /dev/null
yes | cp -f /tmp/ifcfg-* /etc/sysconfig/network-scripts/ &> /dev/null

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

SetHostname

#raw
printf " Setting Hostname:                                                           "
/bin/bash /tmp/status.sh &

echo "NAME=`cat /tmp/hostname`" > /root/setHostname.sh
echo "hostname \$NAME" >> /root/setHostname.sh
echo "hostnamectl set-hostname \$NAME" >> /root/setHostname.sh
echo "rhn-profile-sync" >> /root/setHostname.sh
echo "chmod -x /etc/rc.d/rc.local" >> /root/setHostname.sh
#echo "rm -rf /tmp/hostname" >> /root/setHostname.sh
echo "rm -rf /root/setHostname.sh" >> /root/setHostname.sh
echo "sed -i 's/\/bin\/bash\ \/root\/setHostname.sh//g' /etc/rc.d/rc.local" >> /root/setHostname.sh
chmod 777 /root/setHostname.sh
echo "/bin/bash /root/setHostname.sh" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

SetupFiglet

#raw
printf " Setting up Figlet:                                                          "
/bin/bash /tmp/status.sh &

yum -y install figlet &> /dev/null
mkdir -p /usr/share/figlet/ 
wget http://140.32.192.51/pub/kickstart/figlet.tar.gz &> /dev/null
tar xf figlet.tar.gz -C /usr/share/figlet/
rm -rf figlet.tar.gz
find /usr/share/figlet/ -name '*.flf' > /usr/share/figlet/figfonts.txt
rhncfg-client get &> /dev/null

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

SetupNTP

$SNIPPET('spacewalk/1/ForceTime')
#raw
printf " Setting up Chrony:                                                          "
/bin/bash /tmp/status.sh &

yum -y install chrony &> /dev/null
rhncfg-client get &> /dev/null
systemctl enable chrony &> /dev/null
systemctl start chrony &> /dev/null
ntpdate -s 140.32.191.249 &> /dev/null
hwclock --systohc &> /dev/null

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

SetupPuppetAgent

#raw
printf " Setting up Puppet Agent:                                                    "
/bin/bash /tmp/status.sh &

yum -y install puppet-agent &> /dev/null
 
STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw

StatusBarScript

#raw
echo 'until [ "1" -eq "0" ]; do' > /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" "*     "' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" " *    "' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" "  *   "' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" "   *  "' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" "    * "' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" "     *"' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" "    * "' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" "   *  "' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" "  *   "' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" " *    "' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo ' printf "[\e[1;32m%-6s\e[0;39m]" "*     "' >> /tmp/status.sh
echo ' sleep .25' >> /tmp/status.sh
echo ' printf "\b\b\b\b\b\b\b\b"' >> /tmp/status.sh
echo 'done' >> /tmp/status.sh
chmod 777 /tmp/status.sh
#end raw

SwitchToTTY1

#raw
exec </dev/tty1 > /dev/tty1
chvt 1
#end raw

SwitchToTTY7

#raw
setterm -powersave off -blank 0
chvt 7 
exec </dev/tty7 > /dev/tty7
#end raw

UpdateAllRPMs

#raw
printf " Installing the latest RPM's:                                                "
/bin/bash /tmp/status.sh &

yum --nogpgcheck update -y &> /dev/null
systemctl enable osad

STATUSPID=`ps -ef | grep status| egrep -v grep | head -1 | awk '{print $2}'`
kill $STATUSPID
printf "\b\b\b\b\b\b\b\b"
echo -e "[  \e[1;32mOK\e[0;39m  ]"
#end raw