Added client work scripts
[clearscm.git] / clients / HP / bin / install_new_kernel
1 #!/bin/ksh
2 #
3 # Move a new kernel, previously generated, into place
4 #
5 me=$(basename $0)
6
7 if [ $(id -u) -ne 0 ]; then
8   print -u2 "$me: Error: Must be root to execute this command!"
9   exit 1
10 fi
11
12 OS=$(/bin/uname -r | /usr/bin/cut -f2 -d.)
13
14 kernel_1_source=
15 kernel_2_source=
16 kernel_1_destination=
17 kernel_2_destination=
18
19 case "$OS" in
20   10)
21     kernel_1_source=/stand/build/vmunix_test
22     kernel_2_source=/stand/build/system.SAM
23     kernel_1_destination=/stand/vmunix
24     kernel_2_destination=/stand/system
25     ;;
26   09)
27     kernel_1_source=/etc/conf/hp-ux
28     kernel_2_source=/etc/conf/dfile.SAM
29     kernel_1_destination=/hp-ux
30     kernel_2_destination=/etc/conf/dfile
31     ;;
32   *)
33     print -u2 "$me: Error: Unable to determine OS level: $OS"
34     exit 1
35     ;;
36 esac
37
38 if [ -f $kernel_1_source -a -f $kernel_2_source ]; then
39   answer=y
40   print "New kernel found, move into place (Y/n)?\c"
41   read answer
42   if [ "$answer" = "y" -o "$answer" = "Y" ]; then
43     print -u2 "Moving kernel into place..."
44     mv $kernel_1_source $kernel_1_destination
45     mv $kernel_2_source $kernel_2_destination
46   else
47     print "WARNING: kernel not moved into place!"
48   fi
49
50   answer=y
51   print "Restart system (Y/n)?\c"
52   read answer
53   if [ "$answer" = "y" -o "$answer" = "Y" ]; then
54     cd /
55     /etc/shutdown -yr 0
56   else
57     print "System not restarted"
58     exit
59   fi
60 else
61   print -u2 "$me: Error: Unable to find new kernel files:"
62   print -u2 "\t$kernel_1_source"
63   print -u2 "\t$kernel_2_source"
64   exit 1
65 fi