gnome-cleanup revision 11990
10139N/A#!/bin/ksh
10139N/A#
10139N/A# Cleans up the GNOME Desktop user configuration files. This
12168N/A# will return the user to the default desktop configuration.
10139N/A# Useful if the user's configuration has become corrupted.
10139N/A#
10139N/A# By: Brian Cameron <Brian.Cameron@sun.com>
17185N/A
10139N/A# The first argument can be a user name. If so, then the script
17177N/A# will clean up the files for that specified user (if file
17177N/A# permissions permit). If no argument is given, the default value
17177N/A# is the current user.
10139N/A#
10139N/Aif [ $# -ge 1 ]; then
10139N/A LOGNAME="$1"
10139N/A USRHOME=`echo ~$1`
17118N/Aelse
10139N/A USRHOME="$HOME"
10139N/A if [ -z "$LOGNAME" ]; then
10139N/A LOGNAME=`/usr/bin/logname`
10139N/A fi
16160N/Afi
13776N/A
13776N/A# Error if the directory for this user does not exist.
13776N/A#
10139N/Aif [ ! -d "$USRHOME" ]; then
15871N/A echo ""
10139N/A echo "Error: user $LOGNAME does not exist on this system."
15871N/A echo ""
15192N/A exit 1
15871N/Afi
16446N/A
16210N/A# If USRHOME is the root directory, just set USRHOME to nothing
10139N/A# to avoid double-slash in the output since we refer to files
10139N/A# as $USRHOME/.gconf, for example.
10139N/A#
10139N/Aif [ "$USRHOME" = "/" ]; then
10139N/A USRHOME=""
10139N/Afi
10139N/A
10139N/A# Check if GNOME is running:
10139N/A#
10139N/AGNOME_PROCESSES='(gnome-session|gconfd|gconfd-2|metacity|esd)'
10139N/ARUNNING_PROCESSES=`/usr/bin/pgrep -l -U $LOGNAME "$GNOME_PROCESSES"`
10139N/Arc=$?
10139N/Aif [ $rc -ge 2 ]; then
10139N/A echo ""
10139N/A echo "Error getting user process information for user $LOGNAME..."
10139N/A echo ""
10139N/A exit 1
10139N/Afi
10139N/A
10139N/Aif [ ! -z "$RUNNING_PROCESSES" ]; then
10139N/A echo ""
10139N/A echo "The following GNOME processes are still running for user $LOGNAME:"
10139N/A echo ""
10139N/A echo "$RUNNING_PROCESSES"
10139N/A echo ""
10139N/A echo "Please log out user $LOGNAME from GNOME, so this user has no"
10139N/A echo "GNOME processes running before using gnome-cleanup. For example,"
10139N/A echo "log out, and log into a failsafe session to run gnome-cleanup."
10139N/A echo ""
10139N/A exit 1
10139N/Afi
10139N/A
10139N/A# GNOME 2.x files
10139N/A#
10139N/Agnome_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"
10139N/A
10139N/A# GNOME 1.4 files
10139N/A#
13776N/Agnome_14_files="$USRHOME/.gimp-1.2 $USRHOME/.gnome-help-browser $USRHOME/.gnome_private $USRHOME/.thumbnails $USRHOME/Nautilus"
13776N/A
13776N/A# /var/tmp stuff
13776N/A#
13776N/Avar_tmp_dirs="/var/tmp/gconfd-${LOGNAME} /var/tmp/mapping-${LOGNAME} /var/tmp/orbit-${LOGNAME}"
10139N/A
12168N/Ahas_files=`/bin/ls -1d $gnome_files $gnome_14_files $var_tmp_dirs 2> /dev/null`
10139N/A
16247N/Aif [ ! -z "$has_files" ]
10139N/Athen
10139N/A echo ""
10139N/A echo "User $LOGNAME currently has the following GNOME configuration files:"
10139N/A echo ""
10139N/A echo "$has_files"
10139N/A echo ""
10139N/A echo "Do you wish to remove these files (Y/N) \c"
10139N/A read input;
10139N/A
10139N/A if [ "$input" = "Y" -o "$input" = "y" ]
10139N/A then
10139N/A /bin/rm -fR $has_files
10139N/A rc=$?
11330N/A if [ $rc = 0 ]; then
13776N/A echo "Removed..."
13776N/A else
13776N/A echo "Error removing files..."
13776N/A fi
13776N/A else
15696N/A echo "Not removed..."
10204N/A fi
10139N/A echo ""
10139N/Aelse
11314N/A echo ""
11314N/A echo "User $LOGNAME does not have any GNOME configuration files."
11314N/A echo ""
11314N/Afi
11314N/A