1 | #!/bin/sh |
---|
2 | # $Id: do-update.sh,v 1.32 1999-09-28 22:10:34 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. |
---|
22 | undup() { |
---|
23 | for i in "$@"; do |
---|
24 | case $out in |
---|
25 | *" $i "*) |
---|
26 | ;; |
---|
27 | *) |
---|
28 | out="$out $i " |
---|
29 | ;; |
---|
30 | esac |
---|
31 | done |
---|
32 | } |
---|
33 | |
---|
34 | echo "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. |
---|
40 | case "$HOSTTYPE" in |
---|
41 | sun4) |
---|
42 | SUNPLATFORM=`uname -m` |
---|
43 | ROOTDISK=`mount | sed -n '/^\/ /s#^/ on /dev/dsk/\([^ ]*\).*$#\1#p'` |
---|
44 | export SUNPLATFORM ROOTDISK |
---|
45 | ;; |
---|
46 | esac |
---|
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. |
---|
51 | method=$1 |
---|
52 | version=$2 |
---|
53 | newvers=$3 |
---|
54 | |
---|
55 | echo "Athena Workstation ($HOSTTYPE) Version Update `date`" >> \ |
---|
56 | "$CONFDIR/version" |
---|
57 | |
---|
58 | if [ "$version" != "$newvers" ]; then |
---|
59 | echo "Version-specific updating.." |
---|
60 | cp /dev/null "$CONFCHG" |
---|
61 | cp /dev/null "$CONFVARS" |
---|
62 | cp /dev/null "$OLDBINS" |
---|
63 | cp /dev/null "$OLDLIBS" |
---|
64 | upvers "$version" "$newvers" "$LIBDIR" |
---|
65 | fi |
---|
66 | |
---|
67 | . $CONFDIR/rc.conf |
---|
68 | if [ -f $CONFVARS ]; then |
---|
69 | . $CONFVARS |
---|
70 | fi |
---|
71 | |
---|
72 | # The version scripts may have modified the following files: |
---|
73 | # $CONFCHG A list of configuration files to update |
---|
74 | # $AUXDEVS A list of auxiliary device scripts to run |
---|
75 | # from /srvd/install/aux.devs (sun4 only) |
---|
76 | # $OLDBINS A list of binaries to preserve before tracking |
---|
77 | # $OLDLIBS A list of libraries to preserve before tracking |
---|
78 | # $DEADFILES A list of local files to be removed |
---|
79 | # $LOCALPACKAGES A list of local OS packages to be de/installed |
---|
80 | # $LINKPACKAGES A list of linked OS packages to be de/installed |
---|
81 | # $CONFIGVERS A list of new/old versions of config files, |
---|
82 | # left behind by OS installation (Irix only) |
---|
83 | # $CONFVARS Can set variables to "true", including: |
---|
84 | # NEWUNIX Update kernel |
---|
85 | # NEWBOOT Boot blocks have changed |
---|
86 | # NEWDEVS New pseudo-devices required |
---|
87 | # NEWOS OS version has changed |
---|
88 | # TRACKOS OS files relevant to local disk have changed |
---|
89 | # MINIROOT some OS files require a miniroot update |
---|
90 | |
---|
91 | configfiles=`cat $LIBDIR/configfiles` |
---|
92 | |
---|
93 | if [ "$PUBLIC" = true ]; then |
---|
94 | NEWUNIX=true |
---|
95 | NEWBOOT=true |
---|
96 | for i in $configfiles; do |
---|
97 | echo "$i" >> $CONFCHG; |
---|
98 | done |
---|
99 | rm -f /.hushlogin /etc/*.local /etc/athena/*.local |
---|
100 | fi |
---|
101 | for i in $configfiles; do |
---|
102 | if [ ! -f "$i" ]; then |
---|
103 | echo "$i" >> $CONFCHG |
---|
104 | fi |
---|
105 | done |
---|
106 | |
---|
107 | if [ -s "$CONFCHG" ]; then |
---|
108 | undup `cat "$CONFCHG"` |
---|
109 | conf=$out |
---|
110 | if [ "$PUBLIC" != true ]; then |
---|
111 | echo "The following configuration files have changed and will" |
---|
112 | echo "be replaced. The old versions will be renamed to the" |
---|
113 | echo "same name, but with a .old extension. For example," |
---|
114 | echo "/etc/shells would be renamed to /etc/shells.old and a" |
---|
115 | echo "new version would take its place." |
---|
116 | echo "" |
---|
117 | for i in $conf; do |
---|
118 | if [ -f $i ]; then |
---|
119 | echo " $i" |
---|
120 | fi |
---|
121 | done |
---|
122 | echo "" |
---|
123 | echo "Press return to continue" |
---|
124 | read foo |
---|
125 | for i in $conf; do |
---|
126 | if [ -f $i ]; then |
---|
127 | mv -f $i $i.old |
---|
128 | fi |
---|
129 | done |
---|
130 | fi |
---|
131 | for i in $conf; do |
---|
132 | rm -rf $i |
---|
133 | if [ -f /srvd$i ]; then |
---|
134 | cp -p /srvd$i $i |
---|
135 | elif [ -f /os$i ]; then |
---|
136 | cp -p /os$i $i |
---|
137 | elif [ -f /install$i ]; then |
---|
138 | cp -p /install$i $i |
---|
139 | fi |
---|
140 | done |
---|
141 | fi |
---|
142 | |
---|
143 | if [ "$PUBLIC" = true ]; then |
---|
144 | # Just substitute who we are into the current rc.conf from the srvd. |
---|
145 | echo "Updating $CONFDIR/rc.conf from /srvd$CONFDIR/rc.conf" |
---|
146 | sed -n -e "s#^HOST=[^;]*#HOST=$HOST#" \ |
---|
147 | -e "s#^ADDR=[^;]*#ADDR=$ADDR#" \ |
---|
148 | -e "s#^MACHINE=[^;]*#MACHINE=$MACHINE#" \ |
---|
149 | -e "s#^SYSTEM=[^;]*#SYSTEM=$SYSTEM#" \ |
---|
150 | -e "s#^NETDEV=[^;]*#NETDEV=$NETDEV#" \ |
---|
151 | -e p "/srvd$CONFDIR/rc.conf" > "$CONFDIR/rc.conf" |
---|
152 | else |
---|
153 | # Add any new variables to rc.conf. |
---|
154 | echo "Looking for new variables to add to $CONFDIR/rc.conf" |
---|
155 | conf=`cat "/srvd$CONFDIR/rc.conf" | awk -F= '(NF>1){print $1}'` |
---|
156 | vars="" |
---|
157 | for i in $conf; do |
---|
158 | if [ `grep -c "^$i=" "$CONFDIR/rc.conf"` = 0 ]; then |
---|
159 | vars="$vars $i" |
---|
160 | fi |
---|
161 | done |
---|
162 | if [ -n "$vars" ]; then |
---|
163 | echo "Backing up $CONFDIR/rc.conf to $CONFDIR/rc.conf.orig" |
---|
164 | rm -f "$CONFDIR/rc.conf.orig" |
---|
165 | cp -p "$CONFDIR/rc.conf" "$CONFDIR/rc.conf.orig" |
---|
166 | |
---|
167 | echo "The following variables are being added to /etc/rc.conf:" |
---|
168 | echo " $vars" |
---|
169 | for i in $vars; do |
---|
170 | grep "^$i=" "/srvd$CONFDIR/rc.conf" \ |
---|
171 | >> "$CONFDIR/rc.conf" |
---|
172 | done |
---|
173 | fi |
---|
174 | fi |
---|
175 | |
---|
176 | # We could be more intelligent and shutdown everything, but... |
---|
177 | echo "Shutting down running services" |
---|
178 | if [ -f /var/athena/inetd.pid ]; then |
---|
179 | kill `cat /var/athena/inetd.pid` > /dev/null 2>&1 |
---|
180 | fi |
---|
181 | if [ -f /var/athena/sshd.pid ]; then |
---|
182 | kill `cat /var/athena/sshd.pid` > /dev/null 2>&1 |
---|
183 | fi |
---|
184 | if [ -f /var/athena/named.pid ]; then |
---|
185 | kill `cat /var/athena/named.pid` > /dev/null 2>&1 |
---|
186 | fi |
---|
187 | case "$HOSTTYPE" in |
---|
188 | sgi) |
---|
189 | killall inetd snmpd syslogd |
---|
190 | ;; |
---|
191 | *) |
---|
192 | if [ -f /etc/syslog.pid ]; then |
---|
193 | kill `cat /etc/syslog.pid` > /dev/null 2>&1 |
---|
194 | fi |
---|
195 | if [ -f /var/athena/snmpd.pid ]; then |
---|
196 | kill `cat /var/athena/snmpd.pid` > /dev/null 2>&1 |
---|
197 | fi |
---|
198 | ;; |
---|
199 | esac |
---|
200 | |
---|
201 | # MINIROOT is currently only used for Irix 6.x. |
---|
202 | if [ "$MINIROOT" = true ]; then |
---|
203 | # Set up a miniroot in the swap partition. We will boot into |
---|
204 | # it, and update-os will be run from there. |
---|
205 | |
---|
206 | echo "Suppressing network daemons for reboot" |
---|
207 | chkconfig -f suppress-network-daemons on |
---|
208 | |
---|
209 | # Note the volume header must be updated before the miniroot |
---|
210 | # can boot (Irix only). |
---|
211 | if [ "$NEWBOOT" = true ]; then |
---|
212 | # Make sure the volume header has an up-to-date sash. |
---|
213 | echo "Updating sash volume directory entry..." |
---|
214 | dvhtool -v creat /install/lib/sash sash |
---|
215 | fi |
---|
216 | |
---|
217 | sh /srvd/usr/athena/lib/update/setup-swap-boot "$method" "$newvers" |
---|
218 | case "$?" in |
---|
219 | 0) |
---|
220 | echo "Rebooting into swap to update OS files..." |
---|
221 | ;; |
---|
222 | 2) |
---|
223 | echo "Rebooting to clear swap..." |
---|
224 | echo "Athena Workstation ($HOSTTYPE) Version" \ |
---|
225 | "ClearSwap $method $newvers `date`" \ |
---|
226 | >> "$CONFDIR/version" |
---|
227 | # Make sure this machine knows what the heck to do |
---|
228 | # with "ClearSwap" in version, since it may not be |
---|
229 | # updated to a release that understands it yet. |
---|
230 | cp /srvd/etc/init.d/finish-update /etc/init.d |
---|
231 | ;; |
---|
232 | *) |
---|
233 | echo "Please contact Athena Hotline at x3-1410." |
---|
234 | echo "Thank you. -Athena Operations" |
---|
235 | exit 0 |
---|
236 | ;; |
---|
237 | esac |
---|
238 | |
---|
239 | echo "Update partially completed, system will reboot in 15 seconds." |
---|
240 | sync |
---|
241 | sleep 15 |
---|
242 | exec reboot |
---|
243 | fi |
---|
244 | |
---|
245 | # Not a miniroot update; run update-os here. This is a good place to |
---|
246 | # handle OLDBINS and OLDLIBS, since we need the environment variables |
---|
247 | # after update-os. |
---|
248 | |
---|
249 | if [ -s "$OLDBINS" ]; then |
---|
250 | echo "Making copies of OS binaries we need" |
---|
251 | mkdir -p /tmp/bin |
---|
252 | bins="`cat $OLDBINS`" |
---|
253 | for i in $bins; do |
---|
254 | cp -p $i /tmp/bin/`basename $i` |
---|
255 | done |
---|
256 | PATH=/tmp/bin:$PATH; export PATH |
---|
257 | fi |
---|
258 | |
---|
259 | if [ -s "$OLDLIBS" ]; then |
---|
260 | echo "Making copies of OS libraries we need" |
---|
261 | mkdir -p /tmp/lib |
---|
262 | libs="`cat $OLDLIBS`" |
---|
263 | for i in $libs; do |
---|
264 | cp -p $i /tmp/lib/`basename $i` |
---|
265 | done |
---|
266 | LD_LIBRARY_PATH=/tmp/lib; export LD_LIBRARY_PATH |
---|
267 | fi |
---|
268 | |
---|
269 | sh /srvd/usr/athena/lib/update/update-os |
---|
270 | |
---|
271 | if [ "$NEWOS" = true ]; then |
---|
272 | # Reboot to finish update. |
---|
273 | |
---|
274 | case "$HOSTTYPE" in |
---|
275 | sgi) |
---|
276 | echo "Suppressing network daemons for reboot" |
---|
277 | chkconfig -f suppress-network-daemons on |
---|
278 | ;; |
---|
279 | esac |
---|
280 | |
---|
281 | echo "Updating version for reboot" |
---|
282 | echo "Athena Workstation ($HOSTTYPE) Version Reboot" \ |
---|
283 | "$method $newvers `date`" >> "$CONFDIR/version" |
---|
284 | echo "Update partially completed, system will reboot in 15 seconds." |
---|
285 | sync |
---|
286 | sleep 15 |
---|
287 | exec reboot |
---|
288 | fi |
---|
289 | |
---|
290 | # Not an OS update; run finish-update here. Restart named first, since |
---|
291 | # mkserv has to resolve names. |
---|
292 | /etc/athena/named |
---|
293 | sh /srvd/usr/athena/lib/update/finish-update "$newvers" |
---|
294 | if [ "$method" = Auto ]; then |
---|
295 | echo "Automatic update done; system will reboot in 15 seconds." |
---|
296 | sync |
---|
297 | sleep 15 |
---|
298 | exec reboot |
---|
299 | fi |
---|
300 | |
---|
301 | # Not an automatic update; just sync the disk and drop back to the shell. |
---|
302 | sync |
---|