#!/bin/sh # # Copyright © 2001-2008 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. No representations are made about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. # # Created: 9-Jun-2001 # # This script re-initializes the contents of the kiosk directories with # the template in /home/kiosk-ro/. progname=`echo "$0" | sed 's@^.*/@@'`; olduser="guest-ro" allusers="guest01 guest02 guest03 guest04 guest05 guest06 guest07" usage() { echo "usage: $progname [--build-template fromdir | dirs...]" >&2 exit 1 } if [ x"$1" = x"--build-template" ]; then if [ $# -ne 2 ]; then usage fi olduser="$2" allusers="guest-ro" elif [ $# -gt 0 ]; then allusers="$*" fi tmpdir=`mktemp -d /tmp/khr.XXXXXX` for newuser in $allusers ; do if [ \! -d "/home/$newuser" ]; then echo "$progname: /home/$newuser does not exist" >&2 usage fi if [ "$olduser" != "$newuser" ]; then # echo "$progname: generating /home/$newuser from /home/$olduser" >&2 # echo "" >&2 srcdir="/home/$olduser" rsync -a --delete "$srcdir/" "$tmpdir/" find "$tmpdir" -type f | while read file ; do if grep -q "$olduser" "$file" ; then #echo "editing $file" perl -0777 -i -p -e "s/$olduser/$newuser/g" "$file" fi done chown -Rh "$newuser:guest" "$tmpdir" fi done if [ "$newuser" = "guest-ro" ]; then rm -rf /home/guest-ro mv "$tmpdir" /home/guest-ro rm -rf \ /home/guest-ro/.*.cache* \ /home/guest-ro/.bash* \ /home/guest-ro/.gconf*/*lock/* \ /home/guest-ro/.icq/history/ \ /home/guest-ro/.mozilla/firefox/*.default/Cache* \ /home/guest-ro/.mozilla/firefox/*.default/lock \ /home/guest-ro/.netscape-cache/* \ /home/guest-ro/.netscape/cache/* \ /home/guest-ro/.recently-used* \ /home/guest-ro/.ssh/* \ /home/guest-ro/.xscreensaver-getimage.cache \ /home/guest-ro/.xsession-errors \ /home/guest-ro/.ICEauthority \ /home/guest-ro/.MCOM-cache/* \ /home/guest-ro/.Xauthority \ /home/guest-ro/tmp/.??* \ /home/guest-ro/tmp/* else # --times rsync --recursive --links --perms --owner --group --checksum --delete \ --exclude '.ICEauthority' \ --exclude '.Xauthority' \ --exclude '.xscreensaver-getimage.cache' \ "$tmpdir/" "/home/$newuser" rm -rf "$tmpdir" # nuke /tmp/hsperfdata_guest01/ and /tmp/orbit-guest01/ # rm -rf /tmp/*"$newuser" # nuke all files/dirs in /tmp/ owned by $newuser find /tmp/ -user "$newuser" -prune -exec rm -rf '{}' \; fi