summaryrefslogtreecommitdiff
path: root/nautilus-clean.sh
blob: bbdc458b7de10e7fed3673e08b2b8ae91d74a2e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/sh

# This is a quick hack to check if any nautilus auxiliary processes
# are running, and if so, list them and kill them.  It is not
# portable, and should be be expected to be used in any kind of
# production capacity.

quiet=no
extreme=no
medusa=no

if [ $# -gt 0 ]
then
    arg=$1

    if [ "$arg" = "-q" ]
    then
	quiet=yes
    elif [ "$arg" = "-x" ]
    then
	extreme=yes
    elif [ "$arg" = "-m" ]
    then
	medusa=yes
    fi
fi

if [ $# -gt 1 ]
then
    arg=$2

    if [ "$arg" = "-q" ]
    then
	quiet=yes
    elif [ "$arg" = "-x" ]
    then
	extreme=yes
    elif [ "$arg" = "-m" ]
    then
	medusa=yes
    fi
fi

if [ $# -gt 2 ]
then
    arg=$3

    if [ "$arg" = "-q" ]
    then
	quiet=yes
    elif [ "$arg" = "-x" ]
    then
	extreme=yes
    elif [ "$arg" = "-m" ]
    then
	medusa=yes
    fi
fi


echo_unless_quiet ()
{
    if [ "$quiet" != "yes" ]
    then
	echo "$*"
    fi
}

# Add any new auxiliary programs here.
AUX_PROGS="\
bonobo-application-x-pdf \
bonobo-image-generic \
bonobo-text-plain \
eazel-proxy \
eazel-proxy-util \
gnome-vfs-slave \
hyperbola \
nautilus-adapter \
nautilus-change-password-view \
nautilus-content-loser \
nautilus-hardware-view \
nautilus-history-view \
nautilus-image-view \
nautilus-inventory-view \
nautilus-mozilla-content-view \
nautilus-mpg123 \
nautilus-music-view \
nautilus-notes \
nautilus-rpm-view \
nautilus-sample-content-view \
nautilus-sample-service-view \
nautilus-service-install-view \
nautilus-service-startup-view \
nautilus-sidebar-loser \
nautilus-summary-view \
nautilus-text-view \
nautilus-throbber \
nautilus-tree-view \
trilobite-eazel-install-service  \
trilobite-eazel-time-view \
"

if [ "$extreme" = "yes" ]
then
    AUX_PROGS="gconfd-1 $AUX_PROGS oafd"
fi

unset FOUND_ANY

sysname=`uname -s`

if [ "$sysname" = "SunOS" ]; then
	killcmd="pkill"
else
	killcmd="killall"
fi

for NAME in $AUX_PROGS; do
    EGREP_PATTERN=`echo $NAME | sed -e 's/\(.\)\(.*\)/[\1]\2/' | sed -e 's/\[\\\^\]/\[\\^\]/'`
    COUNT=`ps auxww | egrep $EGREP_PATTERN | grep -v emacs | grep -v egrep | wc -l`

    if [ $COUNT -gt 0 ]; then
	if [ -z $FOUND_ANY ]; then
	    echo_unless_quiet "nautilus-clean: Stale processes found."
	    FOUND_ANY=true
	fi
	echo_unless_quiet "$NAME: $COUNT"

	if [ "$quiet" != "yes" ]
	then
	    $killcmd "$NAME"
	else
	    $killcmd "$NAME" > /dev/null 2>&1
	fi
    fi
done

if [ -z $FOUND_ANY ]; then
    echo_unless_quiet "nautilus-clean: No stale processes found."
fi


if [ "$medusa" = "yes" ]; then
    if [ -f `which medusa-restart 2> /dev/null || echo xxx` ]; then
	echo_unless_quiet "Restarting medusa search and index servers."
	medusa-restart
    fi
fi