source: trunk/packs/update/do-update.sh @ 14079

Revision 14079, 8.6 KB checked in by jweiss, 25 years ago (diff)
kill off the daemos before we start updating also sleep some, since there is a problem that can cause a panic when certain daemons are killed (after a port scan puts the kernel into a weird state)
Line 
1#!/bin/sh
2# $Id: do-update.sh,v 1.33 1999-12-14 04:56:13 jweiss Exp $
3
4# Copyright 1996 by the Massachusetts Institute of Technology.
5#
6# Permission to use, copy, modify, and distribute this
7# software and its documentation for any purpose and without
8# fee is hereby granted, provided that the above copyright
9# notice appear in all copies and that both that copyright
10# notice and this permission notice appear in supporting
11# documentation, and that the name of M.I.T. not be used in
12# advertising or publicity pertaining to distribution of the
13# software without specific, written prior permission.
14# M.I.T. makes no representations about the suitability of
15# this software for any purpose.  It is provided "as is"
16# without express or implied warranty.
17
18# Eliminate duplicates in the argument list, putting the result into
19# a variable "out".  Not super-robust, but it's only intended to work
20# on filenames added to CONFCHG.  We have this because we can't rely
21# on "sort" working across OS versions.
22undup() {
23        for i in "$@"; do
24                case $out in
25                *" $i "*)
26                        ;;
27                *)
28                        out="$out $i "
29                        ;;
30                esac
31        done
32}
33
34echo "Starting update at `date`."
35. /srvd/usr/athena/lib/update/update-environment
36
37# Get the platform name for Solaris.  "uname -i" is the documented way, but
38# it doesn't work in Solaris 2.4 and prior, and "uname -m" works for now.
39# Also determine the root disk based on the mount table.
40case "$HOSTTYPE" in
41sun4)
42        SUNPLATFORM=`uname -m`
43        ROOTDISK=`mount | sed -n '/^\/ /s#^/ on /dev/dsk/\([^ ]*\).*$#\1#p'`
44        export SUNPLATFORM ROOTDISK
45        ;;
46esac
47
48# We get three arguments: the method by which the machine was rebooted.
49# (possible values are Auto, Manual, and Remote), the current workstation
50# version, and the new version.
51method=$1
52version=$2
53newvers=$3
54
55# Some versions of Solaris will panic if they are hit with a certain
56# type of port scan and you then kill a network daemon.  As a
57# work-around, sync the disks first, and sleep to give the machine a
58# chance to panic if it is going to.
59sync
60sleep 2
61# We could be more intelligent and shutdown everything, but...
62echo "Shutting down running services"
63if [ -f /var/athena/inetd.pid ]; then
64        kill `cat /var/athena/inetd.pid` > /dev/null 2>&1
65fi
66if [ -f /var/athena/sshd.pid ]; then
67        kill `cat /var/athena/sshd.pid` > /dev/null 2>&1
68fi
69if [ -f /var/athena/named.pid ]; then
70        kill `cat /var/athena/named.pid` > /dev/null 2>&1
71fi
72case "$HOSTTYPE" in
73sgi)
74        killall inetd snmpd syslogd
75        ;;
76*)
77        if [ -f /etc/syslog.pid ]; then
78                kill `cat /etc/syslog.pid` > /dev/null 2>&1
79        fi
80        if [ -f /var/athena/snmpd.pid ]; then
81                kill `cat /var/athena/snmpd.pid` > /dev/null 2>&1
82        fi
83        ;;
84esac
85sleep 10
86
87echo "Athena Workstation ($HOSTTYPE) Version Update `date`" >> \
88        "$CONFDIR/version"
89
90if [ "$version" != "$newvers" ]; then
91        echo "Version-specific updating.."
92        cp /dev/null "$CONFCHG"
93        cp /dev/null "$CONFVARS"
94        cp /dev/null "$OLDBINS"
95        cp /dev/null "$OLDLIBS"
96        upvers "$version" "$newvers" "$LIBDIR"
97fi
98
99. $CONFDIR/rc.conf
100if [ -f $CONFVARS ]; then
101        . $CONFVARS
102fi
103
104# The version scripts may have modified the following files:
105#       $CONFCHG        A list of configuration files to update
106#       $AUXDEVS        A list of auxiliary device scripts to run
107#                       from /srvd/install/aux.devs (sun4 only)
108#       $OLDBINS        A list of binaries to preserve before tracking
109#       $OLDLIBS        A list of libraries to preserve before tracking
110#       $DEADFILES      A list of local files to be removed
111#       $LOCALPACKAGES  A list of local OS packages to be de/installed
112#       $LINKPACKAGES   A list of linked OS packages to be de/installed
113#       $CONFIGVERS     A list of new/old versions of config files,
114#                       left behind by OS installation (Irix only)
115#       $CONFVARS       Can set variables to "true", including:
116#               NEWUNIX         Update kernel
117#               NEWBOOT         Boot blocks have changed
118#               NEWDEVS         New pseudo-devices required
119#               NEWOS           OS version has changed
120#               TRACKOS         OS files relevant to local disk have changed
121#               MINIROOT        some OS files require a miniroot update
122
123configfiles=`cat $LIBDIR/configfiles`
124
125if [ "$PUBLIC" = true ]; then
126        NEWUNIX=true
127        NEWBOOT=true
128        for i in $configfiles; do
129                echo "$i" >> $CONFCHG;
130        done
131        rm -f /.hushlogin /etc/*.local /etc/athena/*.local
132fi
133for i in $configfiles; do
134        if [ ! -f "$i" ]; then
135                echo "$i" >> $CONFCHG
136        fi
137done
138
139if [ -s "$CONFCHG" ]; then
140        undup `cat "$CONFCHG"`
141        conf=$out
142        if [ "$PUBLIC" != true ]; then
143                echo "The following configuration files have changed and will"
144                echo "be replaced.  The old versions will be renamed to the"
145                echo "same name, but with a .old extension.  For example,"
146                echo "/etc/shells would be renamed to /etc/shells.old and a"
147                echo "new version would take its place."
148                echo ""
149                for i in $conf; do
150                        if [ -f $i ]; then
151                                echo "        $i"
152                        fi
153                done
154                echo ""
155                echo "Press return to continue"
156                read foo
157                for i in $conf; do
158                        if [ -f $i ]; then
159                                mv -f $i $i.old
160                        fi
161                done
162        fi
163        for i in $conf; do
164                rm -rf $i
165                if [ -f /srvd$i ]; then
166                        cp -p /srvd$i $i
167                elif [ -f /os$i ]; then
168                        cp -p /os$i $i
169                elif [ -f /install$i ]; then
170                        cp -p /install$i $i
171                fi
172        done
173fi
174
175if [ "$PUBLIC" = true ]; then
176        # Just substitute who we are into the current rc.conf from the srvd.
177        echo "Updating $CONFDIR/rc.conf from /srvd$CONFDIR/rc.conf"
178        sed -n  -e "s#^HOST=[^;]*#HOST=$HOST#" \
179                -e "s#^ADDR=[^;]*#ADDR=$ADDR#" \
180                -e "s#^MACHINE=[^;]*#MACHINE=$MACHINE#" \
181                -e "s#^SYSTEM=[^;]*#SYSTEM=$SYSTEM#" \
182                -e "s#^NETDEV=[^;]*#NETDEV=$NETDEV#" \
183                -e p "/srvd$CONFDIR/rc.conf" > "$CONFDIR/rc.conf"
184else
185        # Add any new variables to rc.conf.
186        echo "Looking for new variables to add to $CONFDIR/rc.conf"
187        conf=`cat "/srvd$CONFDIR/rc.conf" | awk -F= '(NF>1){print $1}'`
188        vars=""
189        for i in $conf; do
190                if [ `grep -c "^$i=" "$CONFDIR/rc.conf"` = 0 ]; then
191                        vars="$vars $i"
192                fi
193        done
194        if [ -n "$vars" ]; then
195                echo "Backing up $CONFDIR/rc.conf to $CONFDIR/rc.conf.orig"
196                rm -f "$CONFDIR/rc.conf.orig"
197                cp -p "$CONFDIR/rc.conf" "$CONFDIR/rc.conf.orig"
198
199                echo "The following variables are being added to /etc/rc.conf:"
200                echo "  $vars"
201                for i in $vars; do
202                        grep "^$i=" "/srvd$CONFDIR/rc.conf" \
203                                >> "$CONFDIR/rc.conf"
204                done
205        fi
206fi
207
208# MINIROOT is currently only used for Irix 6.x.
209if [ "$MINIROOT" = true ]; then
210        # Set up a miniroot in the swap partition. We will boot into
211        # it, and update-os will be run from there.
212
213        echo "Suppressing network daemons for reboot"
214        chkconfig -f suppress-network-daemons on
215
216        # Note the volume header must be updated before the miniroot
217        # can boot (Irix only).
218        if [ "$NEWBOOT" = true ]; then
219                # Make sure the volume header has an up-to-date sash.
220                echo "Updating sash volume directory entry..."
221                dvhtool -v creat /install/lib/sash sash
222        fi
223
224        sh /srvd/usr/athena/lib/update/setup-swap-boot "$method" "$newvers"
225        case "$?" in
226        0)
227                echo "Rebooting into swap to update OS files..."
228                ;;
229        2)
230                echo "Rebooting to clear swap..."
231                echo "Athena Workstation ($HOSTTYPE) Version" \
232                      "ClearSwap $method $newvers `date`" \
233                        >> "$CONFDIR/version"
234                # Make sure this machine knows what the heck to do
235                # with "ClearSwap" in version, since it may not be
236                # updated to a release that understands it yet.
237                cp /srvd/etc/init.d/finish-update /etc/init.d
238                ;;
239        *)
240                echo "Please contact Athena Hotline at x3-1410."
241                echo "Thank you. -Athena Operations"
242                exit 0
243                ;;
244        esac
245
246        echo "Update partially completed, system will reboot in 15 seconds."
247        sync
248        sleep 15
249        exec reboot
250fi
251
252# Not a miniroot update; run update-os here.  This is a good place to
253# handle OLDBINS and OLDLIBS, since we need the environment variables
254# after update-os.
255
256if [ -s "$OLDBINS" ]; then
257        echo "Making copies of OS binaries we need"
258        mkdir -p /tmp/bin
259        bins="`cat $OLDBINS`"
260        for i in $bins; do
261                cp -p $i /tmp/bin/`basename $i`
262        done
263        PATH=/tmp/bin:$PATH; export PATH
264fi
265
266if [ -s "$OLDLIBS" ]; then
267        echo "Making copies of OS libraries we need"
268        mkdir -p /tmp/lib
269        libs="`cat $OLDLIBS`"
270        for i in $libs; do
271                cp -p $i /tmp/lib/`basename $i`
272        done
273        LD_LIBRARY_PATH=/tmp/lib; export LD_LIBRARY_PATH
274fi
275
276sh /srvd/usr/athena/lib/update/update-os
277
278if [ "$NEWOS" = true ]; then
279        # Reboot to finish update.
280
281        case "$HOSTTYPE" in
282        sgi)
283                echo "Suppressing network daemons for reboot"
284                chkconfig -f suppress-network-daemons on
285                ;;
286        esac
287
288        echo "Updating version for reboot"
289        echo "Athena Workstation ($HOSTTYPE) Version Reboot" \
290                "$method $newvers `date`" >> "$CONFDIR/version"
291        echo "Update partially completed, system will reboot in 15 seconds."
292        sync
293        sleep 15
294        exec reboot
295fi
296
297# Not an OS update; run finish-update here.  Restart named first, since
298# mkserv has to resolve names.
299/etc/athena/named
300sh /srvd/usr/athena/lib/update/finish-update "$newvers"
301if [ "$method" = Auto ]; then
302        echo "Automatic update done; system will reboot in 15 seconds."
303        sync
304        sleep 15
305        exec reboot
306fi
307
308# Not an automatic update; just sync the disk and drop back to the shell.
309sync
Note: See TracBrowser for help on using the repository browser.