gnome-cleanup revision 15607
10139N/A#!/bin/ksh
10139N/A#
10139N/A# Cleans up the GNOME Desktop user configuration files. This
10139N/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>
10139N/A
10139N/A# The first argument can be a user name. If so, then the script
10139N/A# will clean up the files for that specified user (if file
10139N/A# permissions permit). If no argument is given, the default value
11416N/A# is the current user.
10139N/A#
10139N/Aif [ $# -ge 1 ]; then
10139N/A LOGNAME="$1"
10139N/A USRHOME=`echo ~$1`
11253N/Aelse
10794N/A USRHOME="$HOME"
10794N/A if [ -z "$LOGNAME" ]; then
10794N/A LOGNAME=`/usr/bin/logname`
10139N/A fi
10815N/Afi
11418N/A
11418N/A# Error if the directory for this user does not exist.
10139N/A#
10139N/Aif [ ! -d "$USRHOME" ]; then
10139N/A echo ""
10139N/A echo "Error: user $LOGNAME does not exist on this system."
10139N/A echo ""
10139N/A exit 1
10139N/Afi
10139N/A
10139N/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# tmp files
10139N/A#
10139N/Atmp_dirs="/var/tmp $TEMPDIR $TMP $TEMP"
10139N/Atmp_files=""
10139N/A
10139N/Atmp_cleanup="gconfd-${LOGNAME} mapping-${LOGNAME} orbit-${LOGNAME} gvfs-${LOGNAME}*"
10139N/A
10139N/Afor dir in $tmp_dirs; do
10139N/A for cleanup in $tmp_cleanup; do
10139N/A tmp_files="$dir/$cleanup $tmp_files"
10139N/A done
10139N/Adone
10139N/A
10139N/A# GNOME 2.x files
10794N/A#
10794N/Agnome_files="$USRHOME/.dbus $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/registry.* $USRHOME/.local/share"
10794N/A
10794N/A# GNOME 1.4 files
11087N/A#
11418N/Agnome_14_files="$USRHOME/.gnome-help-browser $USRHOME/.gnome_private $USRHOME/.thumbnails $USRHOME/Nautilus"
10139N/A
10139N/Ahas_files=`/bin/ls -1d $tmp_files $gnome_files $gnome_14_files 2> /dev/null`
10139N/A
10139N/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=$?
10139N/A if [ $rc = 0 ]; then
10139N/A echo "Removed..."
10139N/A else
10139N/A echo "Error removing files..."
10139N/A fi
11338N/A else
11338N/A echo "Not removed..."
11338N/A fi
11338N/A echo ""
11338N/Aelse
10139N/A echo ""
10139N/A echo "User $LOGNAME does not have any GNOME configuration files."
10139N/A echo ""
10139N/Afi
10139N/A