#! /bin/sh ### # # logout.hook for a radmind client. # This logout hook tries to make the logout process # as brief as possible. If there are no updates from # the server, the script exits, not scanning the # filesystem for changes to make. Maintenance # filesystem checks should be run out of cron. # Requires the radmind client tools. # (See http://rsug.itd.umich.edu/software/radmind) # ### ### # Copyright (c) 2002 Regents of The University of Michigan. # All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby granted, # provided that the above copyright notice appears in all copies and # that both that copyright notice and this permission notice appear # in supporting documentation, and that the name of The University # of Michigan not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior # permission. This software is supplied as is without expressed or # implied warranties of any kind. # # Research Systems Unix Group # The University of Michigan # c/o Wesley Craig # 4251 Plymouth Road B1F2, #2600 # Ann Arbor, MI 48105-2785 ### PATH=/bin:/usr/bin:/usr/local/bin; export PATH if [ -f /var/db/.DoNotRadmind ]; then echo Bypassing radmind sleep 2 exit 0 fi # TLS auth level. 0: None; 1: Verify Server; 2: Verify Server & Client authlevel="-w 2" rserver="-h server.radmind.edu" cksum= fsdiffpath="/" fsdiffoutput="/tmp/diff.T.$$" cd / # iHook Directives begin with a % sign, and are read on stdout. %<0-100> sets a # progress bar to a corresponding level of completion, e.g., %50 sets the # progress bar to half full. %0 begins a progress bar, and sets it to 0% done: echo %0 # messages to stdout will be displayed in iHook's window echo Checking for changes on the server... # We want ktcheck's output to be displayed in the drawer, so we # redirect it to stderr: ktcheck -c sha1 $rserver $authlevel 1>&2 rc="$?" # Check exit status of ktcheck. If > 1, an error occurred. # If there aren't any updates from the server, skip the rest of # the script. This keeps logout times to a minimum. case "$rc" in 0) echo No updates sleep 2 exit 0 ;; 1) echo Updates found ;; *) # iHook automatically opens the log drawer if the script exits status > 0. echo ktcheck failed! exit $rc ;; esac # fsdiff/lapply loop. while true; do echo %10 echo Examining the filesystem for differences... # run fsdiff, redirecting output to a file. Error messages will automatically # appear in the drawer. fsdiff -A $cksum $fsdiffpath > $fsdiffoutput case "$?" in 0) ;; *) echo fsdiff failed! exit $? ;; esac echo %75 # check the output file size. If 0, skip the lapply step. if [ -s $fsdiffoutput ]; then echo Applying changes.... lapply $cksum $rserver $authlevel $fsdiffoutput 1>&2 case "$?" in 0) break ;; 1) echo Apply failed, no changes made exit 1 ;; 2) echo Apply failed, trying again... echo %OPENDRAWER sleep 2 echo %0 echo Checking for changes on the server... ktcheck -c sha1 $rserver $authlevel 1>&2 continue ;; esac else break fi done # script finished, end progress bar. %100 fills the progress bar and removes it # from the screen echo %100 echo Update complete - rebooting. sleep 2 /sbin/reboot