author | yippi |
Wed, 07 Jan 2009 18:04:10 +0000 | |
branch | gnome-2-24 |
changeset 14148 | d33008456d27 |
parent 11286 | 52c6c7e90138 |
child 14174 | 3a8e207a1e56 |
permissions | -rw-r--r-- |
11248 | 1 |
#!/bin/ksh |
2920 | 2 |
# |
11248 | 3 |
# Cleans up the GNOME Desktop user configuration files. This |
4 |
# will return the user to the default desktop configuration. |
|
5 |
# Useful if the user's configuration has become corrupted. |
|
2920 | 6 |
# |
7 |
# By: Brian Cameron <[email protected]> |
|
8 |
||
11248 | 9 |
# The first argument can be a user name. If so, then the script |
10 |
# will clean up the files for that specified user (if file |
|
11 |
# permissions permit). If no argument is given, the default value |
|
12 |
# is the current user. |
|
13 |
# |
|
14 |
if [ $# -ge 1 ]; then |
|
15 |
LOGNAME="$1" |
|
16 |
USRHOME=`echo ~$1` |
|
17 |
else |
|
18 |
USRHOME="$HOME" |
|
19 |
if [ -z "$LOGNAME" ]; then |
|
20 |
LOGNAME=`/usr/bin/logname` |
|
21 |
fi |
|
22 |
fi |
|
23 |
||
24 |
# Error if the directory for this user does not exist. |
|
25 |
# |
|
26 |
if [ ! -d "$USRHOME" ]; then |
|
14148 | 27 |
echo "\nError: user <$LOGNAME> does not exist on this system.\n" |
11248 | 28 |
exit 1 |
29 |
fi |
|
30 |
||
31 |
# If USRHOME is the root directory, just set USRHOME to nothing |
|
32 |
# to avoid double-slash in the output since we refer to files |
|
33 |
# as $USRHOME/.gconf, for example. |
|
34 |
# |
|
35 |
if [ "$USRHOME" = "/" ]; then |
|
36 |
USRHOME="" |
|
37 |
fi |
|
38 |
||
2920 | 39 |
# Check if GNOME is running: |
40 |
# |
|
41 |
GNOME_PROCESSES='(gnome-session|gconfd|gconfd-2|metacity|esd)' |
|
42 |
RUNNING_PROCESSES=`/usr/bin/pgrep -l -U $LOGNAME "$GNOME_PROCESSES"` |
|
11248 | 43 |
rc=$? |
44 |
if [ $rc -ge 2 ]; then |
|
14148 | 45 |
echo "\nError getting user process information for user <$LOGNAME>...\n" |
11248 | 46 |
exit 1 |
47 |
fi |
|
2920 | 48 |
|
49 |
if [ ! -z "$RUNNING_PROCESSES" ]; then |
|
14148 | 50 |
echo "\nThe following GNOME processes are still running for user <$LOGNAME>:\n" |
2920 | 51 |
echo "$RUNNING_PROCESSES" |
14148 | 52 |
echo "\nPlease log out user <$LOGNAME> from GNOME, so this user has no" |
11248 | 53 |
echo "GNOME processes running before using gnome-cleanup. For example," |
54 |
echo "log out, and log into a failsafe session to run gnome-cleanup." |
|
55 |
echo "" |
|
2920 | 56 |
exit 1 |
57 |
fi |
|
58 |
||
14148 | 59 |
# Use disp_files to echo files back to the screen so that we don't expand |
60 |
# "tmp" wildcard directories like gvfs-${LOGNAME}, otherwise the output |
|
61 |
# is cumbersome to read since this will echo dozens of files to the screen. |
|
62 |
# |
|
63 |
disp_files="" |
|
64 |
||
11116 | 65 |
# GNOME 2.x files |
2920 | 66 |
# |
14148 | 67 |
gnome_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" |
2920 | 68 |
|
11116 | 69 |
# GNOME 1.4 files |
2920 | 70 |
# |
14148 | 71 |
gnome_14_files="$USRHOME/.gnome-help-browser $USRHOME/.gnome_private $USRHOME/.thumbnails $USRHOME/Nautilus" |
2920 | 72 |
|
14148 | 73 |
check_files=`/bin/ls -d $gnome_files $gnome_14_files 2> /dev/null` |
74 |
if [ ! -x "$check_files" ] |
|
75 |
then |
|
76 |
disp_files="$disp_files\n$check_files" |
|
77 |
fi |
|
78 |
||
79 |
# tmp files |
|
7408
8aad920cca69
2006-06-08 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
2927
diff
changeset
|
80 |
# |
14148 | 81 |
tmp_dirs="/var/tmp $TEMPDIR $TMP $TEMP" |
82 |
tmp_files="" |
|
7408
8aad920cca69
2006-06-08 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
2927
diff
changeset
|
83 |
|
14148 | 84 |
tmp_cleanup="gconfd-${LOGNAME} mapping-${LOGNAME} orbit-${LOGNAME} gvfs-${LOGNAME}*" |
85 |
||
86 |
for dir in $tmp_dirs; do |
|
87 |
for cleanup in $tmp_cleanup; do |
|
88 |
tmp_files="$dir/$cleanup $tmp_files" |
|
11286 | 89 |
|
14148 | 90 |
check_files=`/bin/ls -d $dir/$cleanup 2> /dev/null` |
91 |
if [ ! -x "$check_files" ] |
|
92 |
then |
|
93 |
disp_files="$disp_files\n$dir/$cleanup" |
|
94 |
fi |
|
95 |
done |
|
96 |
done |
|
97 |
||
98 |
has_files=`/bin/ls -d $tmp_files $gnome_files $gnome_14_files 2> /dev/null` |
|
2920 | 99 |
|
100 |
if [ ! -z "$has_files" ] |
|
101 |
then |
|
14148 | 102 |
echo "\nUser <$LOGNAME> currently has the following GNOME configuration files:" |
103 |
echo "$disp_files" |
|
104 |
echo "\nDo you wish to remove these files (Y/N) \c" |
|
2920 | 105 |
read input; |
106 |
||
107 |
if [ "$input" = "Y" -o "$input" = "y" ] |
|
108 |
then |
|
109 |
/bin/rm -fR $has_files |
|
11248 | 110 |
rc=$? |
111 |
if [ $rc = 0 ]; then |
|
112 |
echo "Removed..." |
|
113 |
else |
|
114 |
echo "Error removing files..." |
|
115 |
fi |
|
2920 | 116 |
else |
117 |
echo "Not removed..." |
|
118 |
fi |
|
119 |
echo "" |
|
120 |
else |
|
14148 | 121 |
echo "\nUser $LOGNAME does not have any GNOME configuration files.\n" |
2920 | 122 |
fi |