1 | #!/bin/sh |
---|
2 | |
---|
3 | ## |
---|
4 | ## zopectl-srp |
---|
5 | ## |
---|
6 | ## starts, stops or restarts all srp-clients. |
---|
7 | ## |
---|
8 | ## Syntax: zopectl-srp [start|stop|restart] |
---|
9 | ## |
---|
10 | ## (c) 2006 Uli Fouquet and waeup.org |
---|
11 | |
---|
12 | ## All clients to handle... |
---|
13 | CLIENTDIRS="srp srp-ssl01" |
---|
14 | ## Where do the clients reside? |
---|
15 | CLIENTHOMES="/zope/instances/" |
---|
16 | |
---|
17 | CURR_DIR=`pwd` |
---|
18 | |
---|
19 | ## We expect at least one argument... |
---|
20 | if [ -z $1 ]; then |
---|
21 | echo "Usage: $0 [start|stop|restart|logreopen]" |
---|
22 | echo "Starts, stops or restarts all srp clients" |
---|
23 | exit |
---|
24 | fi |
---|
25 | |
---|
26 | ## We support help options... |
---|
27 | HELPLIST="help -help --help -h" |
---|
28 | for TOKEN in $HELPLIST; do |
---|
29 | if [ $1 = $TOKEN ]; then |
---|
30 | echo "Usage: $0 [start|stop|restart|logreopen]" |
---|
31 | echo "Starts, stops or restarts all srp clients" |
---|
32 | exit |
---|
33 | fi |
---|
34 | done |
---|
35 | |
---|
36 | ## We only allow root to run thos script. |
---|
37 | if [ $EUID -ne 0 ]; then |
---|
38 | echo "You must be root to execute this script." |
---|
39 | exit |
---|
40 | fi |
---|
41 | |
---|
42 | |
---|
43 | if [ -f /etc/default/zopectl-srp ]; then |
---|
44 | . /etc/default/zopectl-srp |
---|
45 | fi |
---|
46 | |
---|
47 | echo "Handling instances in $CLIENTHOMES" |
---|
48 | |
---|
49 | ## Do $1 to every single client... |
---|
50 | for DIR in $CLIENTDIRS; do |
---|
51 | echo "Handling instance: $DIR"; |
---|
52 | echo " waiting 10 secs..." |
---|
53 | sleep 10 |
---|
54 | |
---|
55 | ## Does the clienthome exist? |
---|
56 | if [ ! -d $CLIENTHOMES$DIR ]; then |
---|
57 | echo "Can't find $CLIENTHOMES$DIR." |
---|
58 | echo "Omitting this client." |
---|
59 | else |
---|
60 | ZOPECTLSCRIPT=$CLIENTHOMES$DIR/bin/zopectl |
---|
61 | |
---|
62 | ## Does the zopectl-script exist? |
---|
63 | if [ ! -x $ZOPECTLSCRIPT ]; then |
---|
64 | echo "Can't find executable $ZOPECTLSCRIPT" |
---|
65 | echo "Omitting this client" |
---|
66 | else |
---|
67 | ## Do it... |
---|
68 | echo "Doing $ZOPECTLSCRIPT $1" |
---|
69 | $ZOPECTLSCRIPT $1 |
---|
70 | fi |
---|
71 | fi |
---|
72 | done |
---|
73 | |
---|
74 | cd $CURR_DIR |
---|