Hi all!
I'm trying to create an automated script for patching, for my Solaris 8 and 10 systems. The patches have to be applied in single-user mode and the patches are located on an NFS netapp mount (which is basically an NFS mount). All the logs are directed to a central location (the same NFS mount)
When the script below runs, it will create the files and when i reboot the system, it does the patching automatically by the files created, but I saw this message on the console during reboot after patching :
/etc/rcS.d/S9999patches: syntax error at line 8: `patchlist=' unexpected
I'm not sure why this error was shown because when I ran the script below, it didnt have an issue with the array 'patchlist' and created all the proper files.
As a result the patching was done but it seems that the 'if' loop for checking if the patches and properly installed are not not done and hence it does not run the cleanup script etc as expected....
Any help / hint you can give me is greatly appreciated!!
Thanks a lot in advance
========================================
# cat /var/tmp/print_script
#!/bin/bash
#
#
# Automated Patching Script
#
#
#
OS=`uname -a | awk '{print $3}'`;
hostname=`hostname`
rm /etc/rcS.d/S9999patches /var/tmp/cleanup.sh /etc/rcS.d/S9999mounteng /etc/rc3.d/S9999patch_boot
###
### Create a file for cleanup
###
cat >/cleanup.sh <<EOF
#!/bin/sh
rm /etc/rcS.d/S9999patches
rm /mnt/logs
/usr/sbin/reboot
EOF
###
### Create a file for checking status after reboot
###
cat >/etc/rc3.d/S9999patch_boot <<EOF
#!/bin/bash
mkdir /mnt_tmp
/usr/sbin/mount xxxx.xxxx.xxx.xxx:/vol/dev_eng/patching_logs /mnt_tmp
touch /mnt_tmp/${hostname}_RebootSuccess
/usr/sbin/umount /mnt_tmp
rm /cleanup.sh
rm /etc/rc3.d/S9999patch_boot
EOF
if [ "$OS" = "5.8" ]
then
###
### Making the mount for patch location
###
echo "/etc/init.d/inetsvc start" >/etc/rcS.d/S9999mounteng
echo "/etc/init.d/inetinit start" >>/etc/rcS.d/S9999mounteng
echo "/etc/init.d/rpc start" >>/etc/rcS.d/S9999mounteng
echo "mount -a" >>/etc/rcS.d/S9999mounteng
echo "mount -F lofs /export/opt /opt" >>/etc/rcS.d/S9999mounteng
echo "defroute=`egrep -v '^#' /etc/defaultrouter|awk '{print $1}'|head -1`" >>/etc/rcS.d/S9999mounteng
echo "/usr/sbin/route add default ${defroute} " >>/etc/rcS.d/S9999mounteng
echo "/usr/sbin/mount xxxx.xxxx.xxxx.xxxx:/vol/dev_eng /mnt" >>/etc/rcS.d/S9999mounteng
echo "/usr/sbin/mount xxxx.xxxx.xxxx.xxxx:/vol/dev_eng/patching_logs /mntlogs" >>/etc/rcS.d/S9999mounteng
###
### Create file for actual patching
###
cat >/etc/rcS.d/S9999patches <<EOF
#!/bin/bash
hostname=`hostname`
cd /mnt/patch_location1;./patch_install
cd /mnt/patch_location2;./patch_install
patchlist=( 109862-05 112438-03 109326-20 )
element=0
element_count=${#patchlist[@]}
patch_success=`while [ "$element" -lt "$element_count" ]
do
patch="/var/sadm/patch/${patchlist[$element]}"
if [ ! -f $patch ]
then
echo -n "Failure"
exit 0
fi
let "element = $element +1"
done`
if [ "$patch_success" != "Failure" ]
then
touch /mntlogs/${hostname}_PatchSuccess
else
touch /mntlogs/${hostname}_PatchFailure
fi
/usr/sbin/umount /mnt
/usr/sbin/umount /mntlogs
/bin/sh /cleanup.sh /dev/null 2>&1
EOF
else
###
### Making the mount for patch location
###
mkdir /mntlogs
echo "/usr/sbin/mount xxxx.xxxx.xxxx.xxxx:/vol/dev_eng /mnt" >>/etc/rcS.d/S9999mounteng
echo "/usr/sbin/mount xxxx.xxxx.xxxx.xxxx:/vol/dev_eng/patching_logs /mntlogs" >>/etc/rcS.d/S9999mounteng
###
### Create file for actual vtm patching
###
cat >/etc/rcS.d/S9999patches <<EOF
#!/bin/bash
cd /mnt/patch_location1;./patch_install
patchlist=( 119059-32 )
element=0
element_count=${#patchlist[@]}
vtm_success=`while [ "$element" -lt "$element_count" ]
do
patch="/var/sadm/patch/${patchlist[$element]}"
if [ ! -f $patch ]
then
echo -n "Failure"
exit 0
fi
let "element = $element +1"
done`
if [ "$patch_success" != "Failure" ]
then
touch /mntlogs/${hostname}_PatchSuccess
else
touch /mntlogs/${hostname}_PatchFailure
fi
/usr/sbin/umount /mnt
/usr/sbin/umount /mntlogs
/bin/sh /cleanup.sh /dev/null 2>&1
EOF
fi
chmod 500 /etc/rcS.d/S9999patches
chmod 500 /cleanup.sh
chmod 500 /etc/rcS.d/S9999mounteng
chmod 500 /etc/rc3.d/S9999patch_boot