blob: f9d3a6fdc59100c79cff9b634798351211ff08f9 (
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
|
#!/bin/sh
#----------------------------------------------------------------------------#
# Hobbit client bootup script. #
# #
# This invokes hobbitlaunch, which in turn runs the Hobbit client and any #
# extensions configured. #
# #
# Copyright (C) 2005-2006 Henrik Storner <henrik@hswn.dk> #
# "status" section (C) Scott Smith 2006 #
# #
# This program is released under the GNU General Public License (GPL), #
# version 2. See the file "COPYING" for details. #
# #
#----------------------------------------------------------------------------#
#
# $Id: runclient.sh,v 1.13 2006/07/14 21:25:19 henrik Rel $
# Default settings for this client
MACHINEDOTS="`uname -n`" # This systems hostname
BBOSTYPE="`uname -s | tr '[A-Z]' '[a-z]'`" # This systems operating system in lowercase
BBOSSCRIPT="hobbitclient-$BBOSTYPE.sh"
# Commandline mods for the defaults
while test "$1" != ""
do
case "$1" in
--hostname=*)
MACHINEDOTS="`echo $1 | sed -e 's/--hostname=//'`"
;;
--os=*)
BBOSTYPE="`echo $1 | sed -e 's/--os=//' | tr '[A-Z]' '[a-z]'`"
;;
--class=*)
CONFIGCLASS="`echo $1 | sed -e 's/--class=//' | tr '[A-Z]' '[a-z]'`"
;;
--help)
echo "Usage: $0 [--hostname=CLIENTNAME] [--os=rhel3|linux22] [--class=CLASSNAME] start|stop"
exit 0
;;
start)
CMD=$1
;;
stop)
CMD=$1
;;
restart)
CMD=$1
;;
status)
CMD=$1
;;
esac
shift
done
OLDDIR="`pwd`"
cd "`dirname $0`"
HOBBITCLIENTHOME="`pwd`"
cd "$OLDDIR"
MACHINE="`echo $MACHINEDOTS | sed -e 's/\./,/g'`"
export MACHINE MACHINEDOTS BBOSTYPE BBOSSCRIPT HOBBITCLIENTHOME CONFIGCLASS
case "$CMD" in
"start")
if test ! -w $HOBBITCLIENTHOME/logs; then
echo "Cannot write to the $HOBBITCLIENTHOME/logs directory"
exit 1
fi
if test ! -w $HOBBITCLIENTHOME/tmp; then
echo "Cannot write to the $HOBBITCLIENTHOME/tmp directory"
exit 1
fi
if test -s $HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid; then
echo "Hobbit client already running, re-starting it"
$0 stop
rm -f $HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid
fi
$HOBBITCLIENTHOME/bin/hobbitlaunch --config=$HOBBITCLIENTHOME/etc/clientlaunch.cfg --log=$HOBBITCLIENTHOME/logs/clientlaunch.log --pidfile=$HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid
if test $? -eq 0; then
echo "Hobbit client for $BBOSTYPE started on $MACHINEDOTS"
else
echo "Hobbit client startup failed"
fi
;;
"stop")
if test -s $HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid; then
kill `cat $HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid`
echo "Hobbit client stopped"
else
echo "Hobbit client not running"
fi
;;
"restart")
if test -s $HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid; then
$0 stop
else
echo "Hobbit client not running, continuing to start it"
fi
$0 start
;;
"status")
if test -s $HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid
then
kill -0 `cat $HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid`
if test $? -eq 0
then
echo "Hobbit client (clientlaunch) running with PID `cat $HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid`"
else
echo "Hobbit client not running, removing stale PID file"
rm -f $HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid
fi
else
echo "Hobbit client (clientlaunch) does not appear to be running"
fi
;;
*)
echo "Usage: $0 start|stop|restart|status"
break;
esac
exit 0
|