head	1.10;
access;
symbols;
locks; strict;
comment	@# @;


1.10
date	96.05.05.03.54.56;	author svalente;	state Exp;
branches;
next	1.9;

1.9
date	96.02.19.02.35.42;	author ghudson;	state Exp;
branches;
next	1.8;

1.8
date	95.10.30.06.23.06;	author ghudson;	state Exp;
branches;
next	1.7;

1.7
date	95.01.18.11.03.20;	author jhawk;	state Exp;
branches;
next	1.6;

1.6
date	95.01.18.10.36.28;	author jhawk;	state Exp;
branches;
next	1.5;

1.5
date	94.07.26.16.08.58;	author jtkohl;	state Exp;
branches;
next	1.4;

1.4
date	94.07.26.16.01.09;	author jtkohl;	state Exp;
branches;
next	1.3;

1.3
date	94.07.17.09.58.24;	author jtkohl;	state Exp;
branches;
next	1.2;

1.2
date	94.07.09.00.57.59;	author svalente;	state Exp;
branches;
next	1.1;

1.1
date	94.07.09.00.53.56;	author svalente;	state Exp;
branches;
next	;


desc
@Script run by xlogin to reactivate.
@


1.10
log
@Made the default case do very little about cleaning up /tmp.
@
text
@#!/bin/sh 
# Script to bounce the packs on an Athena workstation
#
# $Header: /mit/sipb-athena/src/reactivate/RCS/reactivate,v 1.9 1996/02/19 02:35:42 ghudson Exp svalente $

trap "" 1 15

PATH=/bin:/bin/athena:/usr/bin:/usr/athena/bin:/usr/sbin; export PATH

umask 022
. /etc/athena/rc.conf

# Default options
dflags="-clean"


# Set various flags (based on environment and command-line)
if [ "$1" = "-detach" ]; then dflags=""; fi

if [ "${USER}" = "" ]; then
	exec 1>/dev/console 2>&1
	quiet=-q
else
	echo Reactivating workstation...
	quiet=
fi

case "${SYSTEM}" in
ULTRIX*)
	cp=/bin/cp
	;;
*)
	cp="/bin/cp -p"
esac



# Flush all NFS uid mappings
fsid $quiet -p -a

# Tell the Zephyr hostmanager to reset state
if [ -f /etc/athena/zhm.pid -a "${ZCLIENT}" = "true" ] ; then 
	kill -HUP `cat /etc/athena/zhm.pid`
fi

# Clean temporary areas (including temporary home directories)
case "${SYSTEM}" in
RSAIX)
	find /tmp -depth \( -type f -o -type l \) -print | xargs rm -f -
	find /tmp -depth -type d -print | xargs rmdir 1>/dev/null 2>&1
	;;

SUN4)
	cp -p /tmp/ps_data /usr/tmp/ps_data
	rm -rf /tmp/* > /dev/null 2>&1
        cp -p /usr/tmp/ps_data /tmp/ps_data
	rm -f /usr/tmp/ps_data
	;;
LINUX|NetBSD)
	rm -rf /tmp/*
#	Be very careful about erasing dotfiles in /tmp!
#	Do not lose /tmp/.X0-lock or the directory /tmp/.X11-unix
	if [ -f /tmp/.X0-lock ] ; then
	   X0lock=1; mv /tmp/.X0-lock /tmp/X0-lock
	fi
	mv /tmp/.X11-unix /tmp/X11-unix
	rm -rf /tmp/.??*
	case "$X0lock" in 1)
	  	mv /tmp/X0-lock /tmp/.X0-lock
	;; esac
	mv /tmp/X11-unix /tmp/.X11-unix
	;;
*)
	rm -rf /tmp/*
	;;
esac

# Restore password and group files
case "${SYSTEM}" in
RSAIX)
	;;
SUN4)
        if [ -f /etc/passwd.local ] ; then
            ${cp} /etc/passwd.local /etc/ptmp && mv -f /etc/ptmp /etc/passwd
	fi
        if [ -f /etc/shadow.local ] ; then
            ${cp} /etc/shadow.local /etc/stmp && mv -f /etc/stmp /etc/shadow
	fi
        if [ -f /etc/group.local ] ; then
            ${cp} /etc/group.local /etc/gtmp && mv -f /etc/gtmp /etc/group
        fi
	;;
NetBSD)
	if [ -f /etc/master.passwd.local ] ; then
	    ${cp} /etc/master.passwd.local /etc/ptmp && pwd_mkdb -p /etc/ptmp
	fi
	if [ -f /etc/group.local ] ; then
	    ${cp} /etc/group.local /etc/gtmp && mv -f /etc/gtmp /etc/group
	fi
	;;
*)
	if [ -f /etc/passwd.local ] ; then
	    ${cp} /etc/passwd.local /etc/ptmp && mv -f /etc/ptmp /etc/passwd
	    rm -f /etc/passwd.dir /etc/passwd.pag
	fi
	if [ -f /etc/group.local ] ; then
	    ${cp} /etc/group.local /etc/gtmp && mv -f /etc/gtmp /etc/group
	fi
	;;
esac

# Reconfigure AFS state
if [ "${AFSCLIENT}" != "false" ]; then
    /etc/athena/config_afs > /dev/null &
fi

# punt any processes owned by users not in /etc/passwd
/etc/athena/cleanup -passwd

# Finally, detach all remote filesystems
detach -O -h -n   -a

# Now start activate again
/etc/athena/save_cluster_info

if [ -f /etc/athena/clusterinfo.bsh ] ; then
	. /etc/athena/clusterinfo.bsh
else
	if [ "${RVDCLIENT}" = "true" ]; then
		echo "Can't find library servers."
		exit 1
	fi
fi

if [ "${RVDCLIENT}" = "true" ]; then
	attach	$quiet -h -n -o hard  $SYSLIB
fi

# Perform an update if appropriate
if [ "${AUTOUPDATE}" = "true" -a -f /srvd/auto_update ]; then 
	/srvd/auto_update reactivate
elif [ -f /srvd/.rvdinfo ]; then
	NEWVERS=`awk '{a=$5}; END{print a}' /srvd/.rvdinfo`
	VERSION=`awk '{a=$5}; END{print a}' /etc/athena/version`
	if [ "${NEWVERS}" != "${VERSION}" ]; then
		cat <<EOF
The workstation software version ($VERSION) does not match the
version on the system packs ($NEWVERS).  A new version of software
may be available.  Please contact the Student Information Processing
Board (SIPB), x3-7788, or netbsd-help@@mit.edu to have your workstation
updated.
EOF
		if [ ! -f /usr/tmp/update.check -a -f /usr/ucb/logger ]; then
			/usr/ucb/logger -t `hostname` -p user.notice at revision $VERSION
			cp /dev/null /usr/tmp/update.check
		fi
	fi
fi

if [ -f /usr/athena/bin/access_off ]; then access_off; fi

if [ -f /etc/athena/reactivate.local ]; then
	/etc/athena/reactivate.local
fi

exit 0
@


1.9
log
@Nuke bogus code for dealing with /etc/passwd.local.  Substitute with
code to copy in /etc/master.passwd.local.
@
text
@d4 1
a4 1
# $Header: /afs/sipb/project/sipb-athena/src/reactivate/RCS/reactivate,v 1.8 1995/10/30 06:23:06 ghudson Exp ghudson $
d74 1
a74 3
	mv /tmp/.X11-unix /tmp/../.X11-unix
	rm -rf /tmp/ > /dev/null 2>&1
	mv /tmp/../.X11-unix /tmp/.X11-unix
@


1.8
log
@Update to corespond with distributed /etc/athena/rc.conf.
@
text
@d4 1
a4 1
# $Header: /afs/sipb/project/sipb-athena/src/reactivate/RCS/reactivate,v 1.7 1995/01/18 11:03:20 jhawk Exp ghudson $
d96 2
a97 6
	if [ -f /etc/passwd.local ] ; then
	  awk 'BEGIN { FS=":" }
            /.*/ { print $1 ":" $2 ":" $3 ":" $4 "::0:0:" $5 ":" $6 ":" $7 }' \
	  /etc/passwd.local > /etc/ptmp && \
	     pwd_mkdb /etc/ptmp
	  pwd_mkdb -p /etc/master.passwd
@


1.7
log
@*	Fixed all the explicit PATH bullshit. Added /usr/sbin to PATH

*	umask should be 022 rather than 22. Octal notation...

*	Attempted to converted foo > bar && baz to if... only for
	consistancy. Not a moral statement. Unfortunately, it doesn't seem
	to work. Perhaps an ash bug?

*	Removed the aklog auto-updating bullshit. If this is ever useful, it'd
	be for the sipb.mit.edu cell, anyway...

*	config_afs should not have stderr redirected to /dev/null. Fixed.
	Why is it being run in the background? Should there be a wait for it
	at the end of the script? Hmm...

*	zhm is currently writing to /etc/athena/zhm.pid rather than /var/run/zhm.pid.
	Perhaps it should be a symlink, but I suspect that gets rm'ed to easily.
	 Someone needs to fix zhm...

*	/etc/athena/cleanup causes far too many SIGKILLS to go to init. That calls
	for some investigation, but is not within the scope of reactivate.
@
text
@d4 1
a4 1
# $Header: /afs/sipb/project/netbsd/dev/athena/reactivate/RCS/reactivate,v 1.6 1995/01/18 10:36:28 jhawk Exp jhawk $
d59 1
a59 1
LINUX|NetBSD_I386)
d95 1
a95 1
NetBSD_I386)
@


1.6
log
@I'm very unhappy with this.

1)	It wipes out /tmp. This seems rather poor for a private ws, and is disturbing
	since the default NetBSD configuration doesn't have /usr/tmp.

2)	All throughout it seems to call various things with pathnames and others without.
	Eg: ``/bin/cp'' and  ``mv''. It even bothers to set PATH...

3)	It's loaded with special-cases for different platforms. Is there a good reason
	not to just have seperate scripts?

4)	Where does $SYSTEM come from? Inherited from Xlogin? Documentation'd be nice...

5)	This "Athena Operations" text is bogus. Don't call them--call us!

6)	Yoav will complain about my usage of a case...esac. Time to learn Bourne
	shell..

7)	More NetBSD with weird appendages in weird cases. Sigh...

8)	We should use $Header$ rather than $Id$ so we know where things came from...

Pout pout pout.
@
text
@d4 1
a4 1
# $Header: reactivate,v 1.5 1994/07/26 16:08:58 jtkohl Exp jhawk $
d8 1
a8 1
PATH=/bin:/bin/athena:/usr/bin:/usr/athena/bin; export PATH
d10 1
a10 1
umask 22
d39 1
a39 1
/bin/athena/fsid $quiet -p -a
d42 2
a43 2
if [ -f /var/run/zhm.pid -a "${ZCLIENT}" = "true" ] ; then 
	kill -HUP `/bin/cat /var/run/zhm.pid`
d49 2
a50 2
	find /tmp -depth \( -type f -o -type l \) -print | xargs /bin/rm -f -
	find /tmp -depth -type d -print | xargs /bin/rmdir 1>/dev/null 2>&1
d55 1
a55 1
	/bin/rm -rf /tmp/* > /dev/null 2>&1
d57 1
a57 1
	/bin/rm -f /usr/tmp/ps_data
d60 1
a60 1
	/bin/rm -rf /tmp/*
d67 1
a67 1
	/bin/rm -rf /tmp/.??*
d69 1
a69 1
	  	/bin/mv /tmp/X0-lock /tmp/.X0-lock
d71 1
a71 1
	/bin/mv /tmp/X11-unix /tmp/.X11-unix
d74 3
a76 3
	/bin/mv /tmp/.X11-unix /tmp/../.X11-unix
	/bin/rm -rf /tmp/ > /dev/null 2>&1
	/bin/mv /tmp/../.X11-unix /tmp/.X11-unix
d86 1
a86 1
            ${cp} /etc/passwd.local /etc/ptmp && /bin/mv -f /etc/ptmp /etc/passwd
d89 1
a89 1
            ${cp} /etc/shadow.local /etc/stmp && /bin/mv -f /etc/stmp /etc/shadow
d92 1
a92 1
            ${cp} /etc/group.local /etc/gtmp && /bin/mv -f /etc/gtmp /etc/group
d97 5
a101 4
	awk 'BEGIN { FS=":" }
/.*/ { print $1 ":" $2 ":" $3 ":" $4 "::0:0:" $5 ":" $6 ":" $7 }' \
	    /etc/passwd.local > /etc/ptmp && /usr/sbin/pwd_mkdb /etc/ptmp
	    /usr/sbin/pwd_mkdb -p /etc/master.passwd
d104 1
a104 1
	    ${cp} /etc/group.local /etc/gtmp && /bin/mv -f /etc/gtmp /etc/group
d109 2
a110 2
	    ${cp} /etc/passwd.local /etc/ptmp && /bin/mv -f /etc/ptmp /etc/passwd
	    /bin/rm -f /etc/passwd.dir /etc/passwd.pag
d113 1
a113 1
	    ${cp} /etc/group.local /etc/gtmp && /bin/mv -f /etc/gtmp /etc/group
d120 1
a120 7
    if [ -f /afs/athena.mit.edu/service/aklog ] ; then
	${cp} /afs/athena.mit.edu/service/aklog /bin/athena/aklog.new && \
	test -s /bin/athena/aklog.new && \
	/bin/mv /bin/athena/aklog.new /bin/athena/aklog
	/bin/rm -f /bin/athena/aklog.new
    fi
    /etc/athena/config_afs > /dev/null 2>&1 &
d127 1
a127 1
/bin/athena/detach -O -h -n   -a
d142 1
a142 1
	/bin/athena/attach	$quiet -h -n -o hard  $SYSLIB
d166 1
a166 1
if [ -f /usr/athena/bin/access_off ]; then /usr/athena/bin/access_off; fi
@


1.5
log
@fix up old style passwd stuff
@
text
@d4 1
a4 1
# $Id: reactivate,v 1.4 1994/07/26 16:01:09 jtkohl Exp jtkohl $
d63 3
a65 1
	mv /tmp/.X0-lock /tmp/X0-lock
d68 3
a70 1
	/bin/mv /tmp/X0-lock /tmp/.X0-lock
d160 3
a162 2
may be available.  Please contact Athena Operations (x3-1410) to
have your workstation updated.
@


1.4
log
@use old format passwd.local
@
text
@d4 1
a4 1
# $Id: reactivate,v 1.3 1994/07/17 09:58:24 jtkohl Exp jtkohl $
d94 1
a94 1
/.*/ { print $1 ":" $2 ":" $3 ":" $4 "::0:0:" $5 ":" $6 ":" $7 }'
d96 1
a96 1
	    /usr/sbin/pwd_mkdb /etc/master.passwd
d101 1
@


1.3
log
@changes for NetBSD
@
text
@d4 1
a4 1
# $Id: reactivate,v 1.2 1994/07/09 00:57:59 svalente Exp jtkohl $
d93 3
a95 1
	    ${cp} /etc/passwd.local /etc/ptmp && /usr/sbin/pwd_mkdb /etc/ptmp
@


1.2
log
@Fixed cleaning of /tmp and reactivating of zhm.
@
text
@d4 1
a4 1
# $Id: reactivate,v 1.1 1994/07/09 00:53:56 svalente Exp svalente $
d8 1
a8 1
PATH=/bin:/bin/athena:/usr/ucb; export PATH
d42 2
a43 2
if [ -f /etc/athena/zhm.pid -a "${ZCLIENT}" = "true" ] ; then 
	kill -HUP `/bin/cat /etc/athena/zhm.pid`
d59 1
a59 1
LINUX)
d91 8
@


1.1
log
@Initial revision
@
text
@d4 1
a4 1
# $Id: reactivate,v 1.3 93/08/30 14:01:25 vrt Exp Locker: vrt $
d42 1
a42 1
if [ -f /etc/athena/zhm.pid ] ; then 
d60 1
d63 5
a67 5
	mv /tmp/.X0-lock /etc/X0-lock
	mv /tmp/.X11-unix /etc/X11-unix
	/bin/rm -rf /tmp/* /tmp/.??*
	/bin/mv /etc/X0-lock /tmp/.X0-lock
	/bin/mv /etc/X11-unix /tmp/.X11-unix
@
