11990N/A#!/bin/ksh
2920N/A#
11990N/A# Cleans up the GNOME Desktop user configuration files. This
11990N/A# will return the user to the default desktop configuration.
11990N/A# Useful if the user's configuration has become corrupted.
2920N/A#
2920N/A# By: Brian Cameron <Brian.Cameron@sun.com>
2920N/A
11990N/A# The first argument can be a user name. If so, then the script
11990N/A# will clean up the files for that specified user (if file
11990N/A# permissions permit). If no argument is given, the default value
11990N/A# is the current user.
11990N/A#
11990N/Aif [ $# -ge 1 ]; then
11990N/A LOGNAME="$1"
11990N/A USRHOME=`echo ~$1`
11990N/Aelse
11990N/A USRHOME="$HOME"
11990N/A if [ -z "$LOGNAME" ]; then
11990N/A LOGNAME=`/usr/bin/logname`
11990N/A fi
11990N/Afi
11990N/A
11990N/A# Error if the directory for this user does not exist.
11990N/A#
11990N/Aif [ ! -d "$USRHOME" ]; then
15615N/A echo "\nError: user <$LOGNAME> does not exist on this system.\n"
11990N/A exit 1
11990N/Afi
11990N/A
11990N/A# If USRHOME is the root directory, just set USRHOME to nothing
11990N/A# to avoid double-slash in the output since we refer to files
11990N/A# as $USRHOME/.gconf, for example.
11990N/A#
11990N/Aif [ "$USRHOME" = "/" ]; then
11990N/A USRHOME=""
11990N/Afi
11990N/A
2920N/A# Check if GNOME is running:
2920N/A#
2920N/AGNOME_PROCESSES='(gnome-session|gconfd|gconfd-2|metacity|esd)'
2920N/ARUNNING_PROCESSES=`/usr/bin/pgrep -l -U $LOGNAME "$GNOME_PROCESSES"`
11990N/Arc=$?
11990N/Aif [ $rc -ge 2 ]; then
15615N/A echo "\nError getting user process information for user <$LOGNAME>...\n"
11990N/A exit 1
11990N/Afi
2920N/A
2920N/Aif [ ! -z "$RUNNING_PROCESSES" ]; then
15615N/A echo "\nThe following GNOME processes are still running for user <$LOGNAME>:\n"
2920N/A echo "$RUNNING_PROCESSES"
15615N/A echo "\nPlease log out user <$LOGNAME> from GNOME, so this user has no"
11990N/A echo "GNOME processes running before using gnome-cleanup. For example,"
11990N/A echo "log out, and log into a failsafe session to run gnome-cleanup."
11990N/A echo ""
2920N/A exit 1
2920N/Afi
2920N/A
15615N/A# Use disp_files to echo files back to the screen so that we don't expand
15615N/A# "tmp" wildcard directories like gvfs-${LOGNAME}, otherwise the output
15615N/A# is cumbersome to read since this will echo dozens of files to the screen.
15615N/A#
15615N/Adisp_files=""
15615N/A
15615N/A# GNOME 2.x files
15615N/A#
16973N/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 $USRHOME/.config"
15615N/A
15615N/A# GNOME 1.4 files
15615N/A#
15615N/Agnome_14_files="$USRHOME/.gnome-help-browser $USRHOME/.gnome_private $USRHOME/.thumbnails $USRHOME/Nautilus"
15615N/A
15615N/Acheck_files=`/bin/ls -d $gnome_files $gnome_14_files 2> /dev/null`
15615N/Aif [ ! -x "$check_files" ]
15615N/Athen
15615N/A disp_files="$disp_files\n$check_files"
15615N/Afi
15615N/A
15607N/A# tmp files
15607N/A#
15607N/Atmp_dirs="/var/tmp $TEMPDIR $TMP $TEMP"
15607N/Atmp_files=""
15607N/A
15607N/Atmp_cleanup="gconfd-${LOGNAME} mapping-${LOGNAME} orbit-${LOGNAME} gvfs-${LOGNAME}*"
15607N/A
15607N/Afor dir in $tmp_dirs; do
15607N/A for cleanup in $tmp_cleanup; do
15615N/A tmp_files="$dir/$cleanup $tmp_files"
15615N/A
15615N/A check_files=`/bin/ls -d $dir/$cleanup 2> /dev/null`
15615N/A if [ ! -x "$check_files" ]
15615N/A then
15615N/A disp_files="$disp_files\n$dir/$cleanup"
15615N/A fi
15607N/A done
15607N/Adone
15607N/A
15615N/Ahas_files=`/bin/ls -d $tmp_files $gnome_files $gnome_14_files 2> /dev/null`
15676N/Ahas_user_files=`/bin/ls -d $gnome_files $gnome_14_files 2> /dev/null`
2920N/A
2920N/Aif [ ! -z "$has_files" ]
2920N/Athen
15615N/A echo "\nUser <$LOGNAME> currently has the following GNOME configuration files:"
15615N/A echo "$disp_files"
15615N/A echo "\nDo you wish to remove these files (Y/N) \c"
2920N/A read input;
2920N/A
2920N/A if [ "$input" = "Y" -o "$input" = "y" ]
2920N/A then
15676N/A # Back up files for debugging.
15676N/A date=`/usr/bin/date +%F-%H:%M:%S`
15676N/A tarfile="/tmp/gnome-cleanup-$LOGNAME-$date.tar"
15676N/A /usr/bin/tar -cf $tarfile $has_user_files
15676N/A
2920N/A /bin/rm -fR $has_files
11990N/A rc=$?
11990N/A if [ $rc = 0 ]; then
15676N/A echo "\nRemoved..."
15676N/A echo "\nThe files removed from the user \$HOME directory have been"
15676N/A echo "backed up to the following file:"
15676N/A echo "\n$tarfile"
15676N/A echo "\nIf you ran this program to resolve an issue that was caused"
15676N/A echo "by the GNOME desktop not functioning properly, then please"
15676N/A echo "report a bug at http://defect.opensolaris.org/."
15676N/A echo "\nNote that configuration files may contain sensitive"
15676N/A echo "information about you. If this is a concern, then it is best"
15676N/A echo "to not attach this tar file to a publicly visible bug report."
15676N/A echo "If this is not an issue, then attaching this file would likely"
15676N/A echo "help to debug the problem. Also note that files in the /tmp"
15676N/A echo "directory are removed automatically on reboot, so move this"
15676N/A echo "file to a more permanent location if you want to save it for"
15676N/A echo "reference or future use."
11990N/A else
11990N/A echo "Error removing files..."
11990N/A fi
2920N/A else
2920N/A echo "Not removed..."
2920N/A fi
2920N/A echo ""
2920N/Aelse
15615N/A echo "\nUser $LOGNAME does not have any GNOME configuration files.\n"
2920N/Afi