--- a/ext-sources/gnome-cleanup Tue Nov 27 11:45:19 2007 +0000
+++ b/ext-sources/gnome-cleanup Tue Nov 27 20:57:26 2007 +0000
@@ -1,36 +1,75 @@
-#!/bin/sh
+#!/bin/ksh
#
-# Cleans up Sun's Gnome Desktop user files to return the user
-# to the default desktop configuration.
+# Cleans up the GNOME Desktop user configuration files. This
+# will return the user to the default desktop configuration.
+# Useful if the user's configuration has become corrupted.
#
# By: Brian Cameron <[email protected]>
+# The first argument can be a user name. If so, then the script
+# will clean up the files for that specified user (if file
+# permissions permit). If no argument is given, the default value
+# is the current user.
+#
+if [ $# -ge 1 ]; then
+ LOGNAME="$1"
+ USRHOME=`echo ~$1`
+else
+ USRHOME="$HOME"
+ if [ -z "$LOGNAME" ]; then
+ LOGNAME=`/usr/bin/logname`
+ fi
+fi
+
+# Error if the directory for this user does not exist.
+#
+if [ ! -d "$USRHOME" ]; then
+ echo ""
+ echo "Error: user $LOGNAME does not exist on this system."
+ echo ""
+ exit 1
+fi
+
+# If USRHOME is the root directory, just set USRHOME to nothing
+# to avoid double-slash in the output since we refer to files
+# as $USRHOME/.gconf, for example.
+#
+if [ "$USRHOME" = "/" ]; then
+ USRHOME=""
+fi
+
# Check if GNOME is running:
#
-if [ -z "$LOGNAME" ]; then
- LOGNAME=`/usr/bin/logname`
-fi
GNOME_PROCESSES='(gnome-session|gconfd|gconfd-2|metacity|esd)'
RUNNING_PROCESSES=`/usr/bin/pgrep -l -U $LOGNAME "$GNOME_PROCESSES"`
+rc=$?
+if [ $rc -ge 2 ]; then
+ echo ""
+ echo "Error getting user process information for user $LOGNAME..."
+ echo ""
+ exit 1
+fi
if [ ! -z "$RUNNING_PROCESSES" ]; then
- echo "The following GNOME processes are still running:"
- echo
+ echo ""
+ echo "The following GNOME processes are still running for user $LOGNAME:"
+ echo ""
echo "$RUNNING_PROCESSES"
- echo
- echo "Please log out from GNOME and stop all your GNOME processes"
- echo "before running this script."
-
+ echo ""
+ echo "Please log out user $LOGNAME from GNOME, so this user has no"
+ echo "GNOME processes running before using gnome-cleanup. For example,"
+ echo "log out, and log into a failsafe session to run gnome-cleanup."
+ echo ""
exit 1
fi
# GNOME 2.x files
#
-gnome_files="$HOME/.gconf $HOME/.gconfd $HOME/.gnome $HOME/.gnome-desktop $HOME/.gnome2 $HOME/.gnome2_private $HOME/.metacity $HOME/.nautilus $HOME/.esd_auth $HOME/.gtkrc $HOME/.gtkrc-1.2-gnome2 $HOME/.nautilus-metafile.xml $HOME/.gstreamer-0.10 $HOME/.local/share"
+gnome_files="$USRHOME/.gconf $USRHOME/.gconfd $USRHOME/.gnome $USRHOME/.gnome-desktop $USRHOME/.gnome2 $USRHOME/.gnome2_private $USRHOME/.metacity $USRHOME/.nautilus $USRHOME/.esd_auth $USRHOME/.gtkrc $USRHOME/.gtkrc-1.2-gnome2 $USRHOME/.nautilus-metafile.xml $USRHOME/.gstreamer-0.10 $USRHOME/.local/share"
# GNOME 1.4 files
#
-gnome_14_files="$HOME/.gimp-1.2 $HOME/.gnome-help-browser $HOME/.gnome_private $HOME/.thumbnails $HOME/Nautilus"
+gnome_14_files="$USRHOME/.gimp-1.2 $USRHOME/.gnome-help-browser $USRHOME/.gnome_private $USRHOME/.thumbnails $USRHOME/Nautilus"
# /var/tmp stuff
#
@@ -41,7 +80,7 @@
if [ ! -z "$has_files" ]
then
echo ""
- echo "You currently have the following GNOME configuration files:"
+ echo "User $LOGNAME currently has the following GNOME configuration files:"
echo ""
echo "$has_files"
echo ""
@@ -51,13 +90,18 @@
if [ "$input" = "Y" -o "$input" = "y" ]
then
/bin/rm -fR $has_files
- echo "Removed..."
+ rc=$?
+ if [ $rc = 0 ]; then
+ echo "Removed..."
+ else
+ echo "Error removing files..."
+ fi
else
echo "Not removed..."
fi
echo ""
else
echo ""
- echo "You do not have any GNOME configuration files."
+ echo "User $LOGNAME does not have any GNOME configuration files."
echo ""
fi