[K12OSN] reset-default-dekstops script

Eric Harrison eharrison at mail.mesd.k12.or.us
Sat Jan 29 18:27:11 UTC 2005


On Fri, 28 Jan 2005, Eric Harrison wrote:

> On Sat, 29 Jan 2005, Sudev Barar wrote:
>
>> On Fri, 2005-01-28 at 15:41 -0700, Joe Guenther wrote:
>>> I noticed that the reset-default-desktop script does NOT copy the
>>> /Desktop folder.  I have placed various icons on the desktop for my users.
>>>  It does work to populate new users from the /etc/skel, but the script to
>>> reset a particular user's desktop does not include the
>>> /Desktop with its included icon files.
>>> 
>>> Can anyone give me instructions on how to tweak the script the Eric
>>> Harrison has included so that this would work?
>
> This needs to be fixed. I'll get a new version out shortly.
>

I *think* I have the logic behind this correct:

1) remove all of the desktop config files (.gnome, .kde, etc)
2) copy over all the entries in /etc/skel IF they do not exist in the
    user's home directory

This will nuke the desktop settings, but won't have any side effects such
as removing documents saved in ~/Desktop. All new files in /etc/skel are
copied to the user's home if the user does not already have that specific
file.

The syntax to make all this work with arbitrarily named directories/files
is a bit hairy. I'd appreciate it if those of you with sharp scripting 
skills take a look at this (script attached).

A packaged test build is available at:

ftp://k12linux.mesd.k12.or.us/pub/K12LTSP/testing/RPMS/ltsp_config-0.0.26-k12ltsp.1.4.2.noarch.rpm


-Eric
-------------- next part --------------
#!/bin/sh
#
# A simple script to reset a specific user's desktop settings
#

if [ ! "$1" ]
then
	echo
	echo "usage: $0 <username>"
	echo
	exit
fi

HOMEDIR=`eval "echo ~$1"`

cd $HOMEDIR || { 
	echo
	echo "Ack! the home directory of $1 was not found, aborting"
	echo
	exit
}

# out with the old
for dir in .kde .gnome_private .gconfd .gconf .nautilus .gnome-desktop .gtkrc \
           .sawfish .gnome
do
	if [ -d $HOMEDIR/$dir ]
	then
		rm -rf $HOMEDIR/$dir &> /dev/null
	fi
done
for file in .screenrc 
do
	if [ -f $HOMEDIR/$file ]
	then
		rm -rf $HOMEDIR/$file &> /dev/null
	fi
done

# in with the new
cd /etc/skel
find . -type d -exec sh -c "[ -d $HOMEDIR/\"{}\" ] || mkdir -p $HOMEDIR/\"{}\" && chown --reference=$HOMEDIR $HOMEDIR/\"{}\"" \;
find . -type f -exec sh -c "[ -f $HOMEDIR/\"{}\" ] || cp \"{}\" $HOMEDIR/\"{}\" && chown --reference=$HOMEDIR $HOMEDIR/\"{}\"" \;



More information about the K12OSN mailing list