Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / adm / bin / reinstall_patches_bundle
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:         reinstall_patch_bundle
5 # RCS:          $Header:$
6 # Description:  A script to reinstall the Patches bundle by removing it and
7 #               reinstalling it.
8 # Author:       Andrew DeFaria, California Language Labs
9 # Created:      Thu May  1 23:06:48 PDT 1997
10 # Modified:
11 # Language:     Korn Shell
12 #
13 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
14 #
15 ################################################################################
16 me=`basename $0`
17 notify=defaria@cup.hp.com
18 machine=`uname -n`
19 osver=`uname -r | cut -f2- -d.`
20 major_osver=`echo $osver | cut -f1 -d.`
21 depot="wampus:/Depots/$osver"
22
23 if [ "$major_osver" = "10" ]; then
24   if [ `id -u` -ne 0 ]; then
25     print -u2 "$me: Error: You must be root to use this command"
26     exit 1
27   fi
28   message="Reinstalling Patches bundle from $depot to $machine via $0"
29   mailx -s "$message" $notify <<!EOF
30 $message
31 !EOF
32   # First remove the old Patches bundle. Note that we do not enforce_scripts
33   # nor auto_kernel_build because we are going to be totally replacing the
34   # Patches bundle
35   additional_patches=$(/usr/sbin/swlist | grep PH | tr "        " " " | cut -c3- | cut -f1 -d' ')
36   /usr/sbin/swremove \
37     -x enforce_scripts=false \
38     -x auto_kernel_build=false \
39     Patches $additional_patches > /tmp/$me.$$ 2>&1
40
41   if [ $? -ne 0 ]; then
42     message="Removal of Patches bundle failed!"
43     mailx -s "$message" $notify < /tmp/$me.$$
44     exit 1
45   fi
46
47   # Next install the new Patches bundle.
48   /usr/sbin/swinstall \
49      -x autoreboot=true \
50      -s $depot Patches > /tmp/$me.$$ 2>&1
51
52   if [ $? -ne 0 ]; then
53     message="Installation of Patches bundle failed!"
54     mailx -s "$message" $notify < /tmp/$me.$$
55     exit 1
56   fi
57 else
58   message="Sorry but $0 only works on 10.x machines. This machine is
59 $major_osver."
60   exit 1
61 fi