retire_support_solaris

retire_support_solaris
called by server_retire_solaris

code format="bash"
 * 1) !/bin/bash

export PATH="/usr/sbin:/usr/ccs/bin:/usr/bin:/usr/lib:$PATH:/etc:/usr/platform/$(/bin/uname -m)/sbin:/usr/tools/bin:/usr/bin"

if $FIXSENDMAIL = "y" ; then perl -i -pe 's/^DS.*//' /etc/mail/sendmail.cf   exit fi
 * 1) Make sure sendmail is configured properly so the various emails will go out

if $REMOVENETGROUP = "y" ; then echo "Connecting to Lepton..." echo -e "Enter bind passwd: \c " stty -echo read ADMINPASS stty echo ssh $USERID@ /bin/ldapmodify -D "" -w $ADMINPASS -c << EOF dn: cn=$NETGROUP,ou=netgroup, changetype: delete EOF touch /tmp/done6 echo "Press ENTER to return to the menu or CTRL-C to exit" read junk exit fi
 * 1) Remove LDAP Netgroup if requested from master retirement script

if $REMOVE_TS = "y" ; then TERM_SERVER=`nawk 'c-->b;$b~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+a)%b];print;c=a}b{r[NR%b]=$b}' b=0 a=1 s=" Terminal Server " /tmp/$FQHOST | tail -1 | sed -e :a -e 's/<[^>]*>//g;/b;$b~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+a)%b];print;c=a}b{r[NR%b]=$b}' b=0 a=1 s="Terminal Server Port " /tmp/$FQHOST | tail -1 | sed -e :a -e 's/<[^>]*>//g;/ password: " _PASS stty echo echo "" stty -echo read -p "Please enter the current  root password: " _PASS stty echo echo "" echo "Enter LDAP password to ssh to "
 * 1) Get current  and  root passwords from the user

ssh $USERID@ expect << EOF set timeout -1 spawn ssh @${TERM_SERVER} expect "*?assword:*" send "${<REMOVED>_PASS}\r" expect "$ " send "su -\r" sleep 2 expect "*?assword:*" send "${<REMOVED>_PASS}\r" sleep 1 expect "# " sleep 1 send "cp /etc/portslave/pslave.conf /etc/portslave/pslave.conf.b4.${SHOST}\r" sleep 1 send "vi /etc/portslave/pslave.conf\r" sleep 1 expect "*" send -- "/" send -- "${SHOST}\r" send -- "C" send -- "${PORT}" send -- "" send -- "ZZ" sleep 2 expect "# " send "if \[ -e /bin/runconf \]; then runconf;saveconf; else signal_ras hup;saveconf;fi\r" expect "# " send -- "" send -- "" expect eof EOF stty echo touch /tmp/done8 exit fi

if $EUID -ne 0 ; then echo "This script must be run as root" 1>&2 exit 1 fi
 * 1) Check to see if the user is root

email_workplan { echo -ne "Work Plan:\n=========\nRetirement will be done according to <REMOVED> Version 3.0\n\nEMC and DGC devices will be removed based on the following information:\nINQ output:\n`<REMOVED>/inq.sol64 -clariion`\n\nvxdisk list:\n`vxdisk list`\n\nThe following process will be used in order to prepare the system for GSMO to remove the devices:\n\n- will use vxdg destroy to remove all imported diskgroups (with the exception of rootdg and bootdg)\n- will use vxdiskunsetup to remove all disks from veritas control (with the exception of disks in rootdg and bootdg)\n- will cut a child to GSMO with the device number and the serial number of SAN devices to be removed from the server\n\nThe removal steps above do not use <REMOVED> because the script in that process is broken and the author currently has no plans to fix it.  Therefore, I have developed and confirmed this process as valid for retirements only as it does remove ALL VERITAS CONTROLLED DISKS. This process was developed to do away with the use of that OSI for the purpose of retirements only.\n\nVerification:\n============\nFrom <REMOVED> Version 3.0:\nVerify all applicable child CRs are closed.\n\nCommunication:\n=============\nOwner has submitted this request based on the Platfrom Retirement Approval From and is aware of change and the parties have agreed to the change.\n\nJustification:\n=============\nPlatfrom Retirement Approval Form has been signed by the system owner.\n\nTest/Backoff:\n============\nPerfrom a BMR and tape backup restore and re-attach devices to the SAN.\n" | mailx -s "full workplan for $SHOST" $EMAIL }
 * 1) Function to email workplan

if -e /tmp/done5partial ; then echo "Destroying the disk groups and running vxdiskunsetup on the disks..."
 * 1) Check to see if SAN Removal step is partial and if so execute the steps in the from the workplan

# Make list of all disks to unsetup before they're destroyed vxdisk -o alldgs list | egrep -v "rootdg|bootdg|DEVICE| - " | awk -Fs '{print $1}' > /tmp/vxdisk.disks.out # Destroy all local dgs for i in `vxdisk list | egrep -vi "rootdg|bootdg|DEVICE| - " | awk '{print $4}' | sort | uniq`; do vxdg destroy $i; done # Unsetup all non-root local (nonimported) disks for i in `cat /tmp/vxdisk.disks.out`; do /usr/lib/vxvm/bin/vxdiskunsetup -C $i; done

# Extra verification # Verify vxprint looks good vxprint -Aht

echo "Do you see only root disks listed in the 2nd to last column? [y/n]" read answer

if [ "$answer" = "y" ]; then mv /tmp/done5partial /tmp/done5 exit else echo "There is probably at least one filesystem in use." echo "Please use the fuser command to identify and free it up and then re-run this script" fi exit fi

echo "Stopping Key Services..." /etc/init.d/oracle stop;/etc/init.d/syslog stop; /etc/init.d/nqmdaemon stop;/etc/init.d/mysql.server stop killall httpd
 * 1) Stop Services

echo "Unmounting all extra filesystems" mount | egrep -v "/ |/usr |/proc|/home|/var |/tmp |/opt |/var/run|/dev/fd|/sys |/etc/mnttab|/usr/tools|/net/cursor|/net/guts|/net |/boot |/dev/pts" | awk '{print $1}' >> /tmp/mount.list
 * 1) Unmount all extra filesytems

COUNT=1 while $COUNT < 6 ; do                for i in `cat /tmp/mount.list`; do                        umount -f $i 2> /dev/null #echo "Mount point is $i" done #COUNT=$(($COUNT + 1)) let COUNT=COUNT+1 done mount echo "Are all extra filesystems unmounted? [y/n]" read answer
 * 1) Run mount again to visually verify everything removed

if [ "$answer" = "n" ]; then echo "Please manually unmount what's left and then re-run the script." echo "Also, please report the offending filesystem(s) to Chad Crider at criderch@lilly.com" echo "to be included in the script for future use." sleep 5 exit 1 fi

if ! -d <REMOVED> ; then mkdir <REMOVED> fi if ! -x <REMOVED>/inq ; then echo "<REMOVED>/inq not found. Mounting NFS share..." mount -F nfs <REMOVED> /usr/tools fi
 * 1) Make sure inq is reachable

rm -rf /var/tmp/emc 2>/dev/null mkdir /var/tmp/emc cd /var/tmp/emc

echo "Searching for EMC and DGC devices..." <REMOVED>/inq -nocapacity | grep -v d0 | grep EMC | tr 'd' ' ' | tr 's' ' ' >> emc_tmp <REMOVED>/inq -nocapacity | grep -v d0 | grep DGC | tr 'd' ' ' | tr 's' ' ' >> dgc_tmp
 * 1) Generate tmp files for each storage type

[ -s emc_tmp ] && echo "EMC devices found. Processing..." || echo "No EMC devices found." [ -s dgc_tmp ] && echo "DGC devices found. Processing..." || echo "No DGC devices found."
 * 1) Process SAN devices

while read LINE do       DEVICE=`echo $LINE | awk '{print $4}'` SERIAL=`echo $LINE | awk '{print $(NF-0)}'`
 * 1) Create device list for GSMO

echo "d$DEVICE $SERIAL" >> devfile_tmp done < "emc_tmp"

cat devfile_tmp | sort | uniq >> device_file

rm devfile_tmp
 * 1) Clean up

email_workplan echo -ne "Copy the below input into the child EMC Disk Removal CR (the one you cut to GSMO)\n\n `cat device_file`\n\nGSMO, Please unmask the above devices and unmap if applicable." | mailx -s "2nd CR for $(uname -n)" $EMAIL echo "Email sent" touch /tmp/done5partial echo "Press ENTER to return to the menu or CTRL-C to exit" read junk code
 * 1) Email yourself the info that goes in both CRs