source: trunk/packs/maint/reactivate.sh @ 13645

Revision 13645, 4.4 KB checked in by rbasch, 25 years ago (diff)
Only copy passwd, shadow, and group if they differ from the .local file; sync after copying them.
Line 
1#!/bin/sh
2# Script to bounce the packs on an Athena workstation
3#
4# $Id: reactivate.sh,v 1.43 1999-10-01 13:43:41 rbasch Exp $
5
6trap "" 1 15
7
8PATH=/bin:/bin/athena:/usr/bin:/usr/sbin:/usr/ucb; export PATH
9HOSTTYPE=`/bin/athena/machtype`; export HOSTTYPE
10
11# Usage: nuke directoryname
12# Do the equivalent of rm -rf directoryname/*, except using saferm.
13nuke()
14{
15        (
16                cd $1
17                if [ $? -eq 0 ]; then
18                        find * ! -type d -exec saferm {} \;
19                        find * -depth -type d -exec rmdir {} \;
20                fi
21        )
22}
23
24umask 22
25. /etc/athena/rc.conf
26
27# Set various flags (based on environment and command-line)
28if [ "$1" = -detach ]; then
29        dflags=""
30else
31        dflags="-clean"
32fi
33
34if [ "$1" = -prelogin ]; then
35        if [ "$PUBLIC" = "false" ]; then
36                exit 0;
37        fi
38        echo "Cleaning up..." >> /dev/console
39        full=false
40else
41        full=true
42fi
43
44if [ -z "$USER" ]; then
45        exec 1>/dev/console 2>&1
46        quiet=-q
47else
48        echo "Reactivating workstation..."
49        quiet=""
50fi
51
52# Flush all NFS uid mappings
53/bin/athena/fsid $quiet -p -a
54
55# Tell the Zephyr hostmanager to reset state
56if [ -f /var/athena/zhm.pid -a "$ZCLIENT" = true ] ; then
57        /bin/kill -HUP `/bin/cat /var/athena/zhm.pid`
58fi
59
60# Zero any ticket files in /tmp that may have escaped other methods
61# of destruction, before we clear /tmp. We must cd there since saferm
62# will not follow symbolic links.
63(cd /tmp; saferm -z tkt* krb5cc*) > /dev/null 2>&1
64
65# For some reason, emacs leaves behind a lock file sometimes.  Nuke it.
66rm -f /var/tmp/!!!SuperLock!!!
67
68if [ "$full" = true ]; then
69        # Clean temporary areas (including temporary home directories)
70        case "$HOSTTYPE" in
71        sun4)
72                cp -p /tmp/ps_data /var/athena/ps_data
73                nuke /tmp > /dev/null 2>&1
74                cp -p /var/athena/ps_data /tmp/ps_data
75                rm -f /var/athena/ps_data
76                ;;
77        *)
78                nuke /tmp > /dev/null 2>&1
79                ;;
80        esac
81        nuke /var/athena/tmphomedir > /dev/null 2>&1
82fi
83
84# Copy in latest password file
85if [ "$PUBLIC" = true ]; then
86        if [ -r /srvd/etc/passwd ]; then
87                cp -p /srvd/etc/passwd /etc/passwd.local
88                chmod 644 /etc/passwd.local
89                chown root /etc/passwd.local
90        fi
91        if [ -r /srvd/etc/shadow ]; then
92                cp -p /srvd/etc/shadow /etc/shadow.local
93                chmod 600 /etc/shadow.local
94                chown root /etc/shadow.local
95        fi
96        rm -rf /etc/athena/access >/dev/null 2>&1
97fi
98
99# Restore password and group files
100if [ -s /etc/passwd.local ] ; then
101        cmp -s /etc/passwd.local /etc/passwd || {
102                cp -p /etc/passwd.local /etc/ptmp &&
103                /bin/mv -f /etc/ptmp /etc/passwd &&
104                sync
105        }
106fi
107if [ -s /etc/shadow.local ] ; then
108        cmp -s /etc/shadow.local /etc/shadow || {
109                cp -p /etc/shadow.local /etc/stmp &&
110                /bin/mv -f /etc/stmp /etc/shadow &&
111                sync
112        }
113fi
114if [ -s /etc/group.local ] ; then
115        cmp -s /etc/group.local /etc/group || {
116                cp -p /etc/group.local /etc/gtmp &&
117                /bin/mv -f /etc/gtmp /etc/group &&
118                sync
119        }
120fi
121
122if [ "$full" = true ]; then
123        # Reconfigure AFS state
124        if [ "$AFSCLIENT" != "false" ]; then
125                /etc/athena/config_afs > /dev/null 2>&1 &
126        fi
127fi
128
129# Punt any processes owned by users not in /etc/passwd.
130/etc/athena/cleanup -passwd
131
132if [ "$full" = true ]; then
133        # Remove session files.
134        for i in /var/athena/sessions/*; do
135                # Sanity check.
136                if [ -s $i ]; then
137                        logger -p user.notice "Non-empty session record $i"
138                fi
139                rm -f $i
140        done
141
142        # Detach all remote filesystems
143        /bin/athena/detach -O -h -n $quiet $dflags -a
144
145        # Now start activate again
146        /etc/athena/save_cluster_info
147
148        if [ -f /var/athena/clusterinfo.bsh ] ; then
149                . /var/athena/clusterinfo.bsh
150        elif [ "$RVDCLIENT" = true ]; then
151                echo "Can't determine system packs location."
152                exit 1
153        fi
154
155        if [ "$RVDCLIENT" = true ]; then
156                /bin/athena/attach      $quiet -h -n -o hard -O $SYSLIB
157        fi
158
159        # Perform an update if appropriate
160        /srvd/auto_update reactivate
161
162        if [ "$PUBLIC" = true -a -f /srvd/.rvdinfo ]; then
163                NEWVERS=`awk '{a=$5} END{print a}' /srvd/.rvdinfo`
164                THISVERS=`awk '{a=$5} END{print a}' /etc/athena/version`
165                if [ "$NEWVERS" = "$THISVERS" ]; then
166                        /usr/athena/etc/track
167                        cf=`cat /srvd/usr/athena/lib/update/configfiles`
168                        for i in $cf; do
169                                if [ -f /srvd$i ]; then
170                                        cp -p /srvd$i $i
171                                else
172                                        cp -p /os$i $i
173                                fi
174                        done
175                        ps -e | awk '$4=="inetd" {print $1}' | xargs kill -HUP
176                fi
177                rm -f /etc/athena/reactivate.local /etc/ssh_*
178        fi
179fi
180
181if [ "$ACCESSON" = true -a -f /usr/athena/bin/access_on ]; then
182        /usr/athena/bin/access_on
183elif [ "$ACCESSON" != true -a -f /usr/athena/bin/access_off ]; then
184        /usr/athena/bin/access_off
185fi
186
187if [ "$full" = true ]; then
188        if [ -f /etc/athena/reactivate.local ]; then
189                /etc/athena/reactivate.local
190        fi
191fi
192
193exit 0
Note: See TracBrowser for help on using the repository browser.