gnome-cleanup revision 15615
5ae0e2c8b72fa44237edeb37d1945b1c3535ca39Automatic Updater# Cleans up the GNOME Desktop user configuration files. This
59dd3b3cd954239d98ef52cd26328856cb6f2975Automatic Updater# will return the user to the default desktop configuration.
59dd3b3cd954239d98ef52cd26328856cb6f2975Automatic Updater# Useful if the user's configuration has become corrupted.
59dd3b3cd954239d98ef52cd26328856cb6f2975Automatic Updater# By: Brian Cameron <Brian.Cameron@sun.com>
bb93c8542756719b53096b9939e4041d0966026fAutomatic Updater# The first argument can be a user name. If so, then the script
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# will clean up the files for that specified user (if file
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# permissions permit). If no argument is given, the default value
ac4e70ff8955669341f435bc0a734a17c01af124Mark Andrews# is the current user.
56874aef380a64a2c183b7c282c3e7a361d67fa1Automatic Updater if [ -z "$LOGNAME" ]; then
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews# Error if the directory for this user does not exist.
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrewsif [ ! -d "$USRHOME" ]; then
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews echo "\nError: user <$LOGNAME> does not exist on this system.\n"
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# If USRHOME is the root directory, just set USRHOME to nothing
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# to avoid double-slash in the output since we refer to files
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# as $USRHOME/.gconf, for example.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Check if GNOME is running:
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark AndrewsGNOME_PROCESSES='(gnome-session|gconfd|gconfd-2|metacity|esd)'
3098364bcdd7a719fbafa5fc8d2cc9e90e5a5989Automatic UpdaterRUNNING_PROCESSES=`/usr/bin/pgrep -l -U $LOGNAME "$GNOME_PROCESSES"`
ca904804e43f663f08eb1ac9d6d617930b9a3cd3Automatic Updater echo "\nError getting user process information for user <$LOGNAME>...\n"
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsif [ ! -z "$RUNNING_PROCESSES" ]; then
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews echo "\nThe following GNOME processes are still running for user <$LOGNAME>:\n"
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews echo "\nPlease log out user <$LOGNAME> from GNOME, so this user has no"
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews echo "GNOME processes running before using gnome-cleanup. For example,"
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews echo "log out, and log into a failsafe session to run gnome-cleanup."
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# Use disp_files to echo files back to the screen so that we don't expand
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# "tmp" wildcard directories like gvfs-${LOGNAME}, otherwise the output
d145b64cacc8d9cda51f9924ec70cd4661c3e2cfAutomatic Updater# is cumbersome to read since this will echo dozens of files to the screen.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsgnome_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"
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews# GNOME 1.4 files
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsgnome_14_files="$USRHOME/.gnome-help-browser $USRHOME/.gnome_private $USRHOME/.thumbnails $USRHOME/Nautilus"
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrewscheck_files=`/bin/ls -d $gnome_files $gnome_14_files 2> /dev/null`
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrewstmp_cleanup="gconfd-${LOGNAME} mapping-${LOGNAME} orbit-${LOGNAME} gvfs-${LOGNAME}*"
bb93c8542756719b53096b9939e4041d0966026fAutomatic Updater check_files=`/bin/ls -d $dir/$cleanup 2> /dev/null`
5ae0e2c8b72fa44237edeb37d1945b1c3535ca39Automatic Updaterhas_files=`/bin/ls -d $tmp_files $gnome_files $gnome_14_files 2> /dev/null`
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater echo "\nUser <$LOGNAME> currently has the following GNOME configuration files:"
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater echo "\nDo you wish to remove these files (Y/N) \c"
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater echo "Removed..."
19b3dc94bce93fa76bd7e066f9298630dbc9dcb4Automatic Updater echo "Error removing files..."
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater echo "Not removed..."
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater echo "\nUser $LOGNAME does not have any GNOME configuration files.\n"