Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 226 lines (196 sloc) 5.56 kB
ea00068 @nniclausse use bash; solaris does not like 'hostname -s' (jasonwtucker@gmail.com)
nniclausse authored
1 #!/bin/bash
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
2
ea00068 @nniclausse use bash; solaris does not like 'hostname -s' (jasonwtucker@gmail.com)
nniclausse authored
3 UNAME=`uname`
4 case $UNAME in
3027f82 @nniclausse argh
nniclausse authored
5 "Linux") HOST=`hostname -s`;;
6 "SunOS") HOST=`hostname`;;
7 *) HOST=`hostname -s`;;
ea00068 @nniclausse use bash; solaris does not like 'hostname -s' (jasonwtucker@gmail.com)
nniclausse authored
8 esac
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
9
13dfdfd @nniclausse update configure & Makefile
nniclausse authored
10 INSTALL_DIR=@prefix@/lib/erlang/
11 ERL=@ERL@
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
12 MAIN_DIR=$HOME/.tsung
76b47d6 @nniclausse save session in main directory instead of log
nniclausse authored
13 LOG_DIR=$MAIN_DIR/log
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
14 LOG_OPT="log_file \"$LOG_DIR/tsung.log\""
13dfdfd @nniclausse update configure & Makefile
nniclausse authored
15 VERSION=@PACKAGE_VERSION@
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
16
17 LISTEN_PORT=8090
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
18 NAME=tsung
19 CONTROLLER=tsung_controller
20 RECORDER=tsung_recorder
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
21
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
22 TSUNGPATH=$INSTALL_DIR/lib/tsung-$VERSION/ebin
23 CONTROLLERPATH=$INSTALL_DIR/lib/tsung_controller-$VERSION/ebin
24 RECORDERPATH=$INSTALL_DIR/lib/tsung_recorder-$VERSION/ebin
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
25
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
26 CONF_OPT_FILE="$HOME/.tsung/tsung.xml"
27 BOOT_OPT="-boot $INSTALL_DIR/lib/tsung_controller-$VERSION/priv/tsung_controller -boot_var TSUNGPATH $INSTALL_DIR "
28 REC_BOOT_OPT="-boot $INSTALL_DIR/lib/tsung_recorder-$VERSION/priv/tsung_recorder -boot_var TSUNGPATH $INSTALL_DIR "
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
29 REC_DEBUG_LEVEL=5
ad4f1ed @nniclausse refactoring of recorder: add plugin architecture for other protocols …
nniclausse authored
30 RECORDER_PLUGIN="http"
95fb173 @nniclausse add -r option to set the command for starting nodes on remote host (s…
nniclausse authored
31 ERL_RSH=" -rsh ssh "
13dfdfd @nniclausse update configure & Makefile
nniclausse authored
32 ERL_OPTS=" +A 1 @ERL_OPTS@ "
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
33 COOKIE='tsung'
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored
34 ERTS_RUN=`$ERL -version 2>&1 | tr -d '[A-Za-z] (),\f\n\r'`
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
35 ERTS_BOOT=`grep erts $TSUNGPATH/../priv/tsung.rel | tr -d 'a-z{}"" ,\n'`
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
36
37 stop() {
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
38 $ERL $ERL_OPTS $ERL_RSH -noshell -sname killer -setcookie $COOKIE -pa $TSUNGPATH -pa $CONTROLLERPATH -s tsung_controller stop_all $HOST -s init stop
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
39 }
40
41 stop_recorder() {
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
42 $ERL $ERL_OPTS $ERL_RSH -noshell -sname killer -setcookie $COOKIE -pa $TSUNGPATH -pa $RECORDERPATH -s tsung_recorder stop_all $HOST -s init stop
0992b82 @nniclausse check if recorder is already running
nniclausse authored
43 rm $PIDFILE
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
44 }
45
c65d43c @nniclausse fix output msg; fix usage.
nniclausse authored
46 recorder_status() {
47 PIDFILE="/tmp/tsung_recorder.pid"
48 if [ -f $PIDFILE ]; then
49 echo "Tsung recorder started [OK]"
50 else
51 echo "Tsung recorder not started "
52 fi
53 }
54
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored
55 checkversion() {
0992b82 @nniclausse check if recorder is already running
nniclausse authored
56 if [ $ERTS_RUN != $ERTS_BOOT ]
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored
57 then
58 echo "Erlang version has changed ! [$ERTS_BOOT] != [$ERTS_RUN]"
59 echo "Must create new boot files (you may have to run this once as root ! )"
60 makebootfiles
0992b82 @nniclausse check if recorder is already running
nniclausse authored
61 fi
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored
62 }
63
64 makebootfiles() {
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
65 cd $TSUNGPATH/..
66 echo "creating boot file for tsung application"
67 $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored
68 cd $CONTROLLERPATH/..
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
69 echo "creating boot file for tsung_controller application"
70 $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null
71 echo "creating boot file for tsung_recorder application"
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored
72 cd $RECORDERPATH/..
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
73 $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored
74 }
75
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
76 start() {
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
77 echo "Starting Tsung"
c3bd40d @nniclausse do not detached tsunami with start
nniclausse authored
78 $ERL $ERL_OPTS $ERL_RSH -noshell -sname $CONTROLLER -setcookie $COOKIE $BOOT_OPT \
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
79 -pa $TSUNGPATH -pa $CONTROLLERPATH \
80 -tsung_controller config_file \"$CONF_OPT_FILE\" -tsung_controller $LOG_OPT
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
81 }
82
83 recorder() {
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
84 echo "Starting Tsung recorder on port $LISTEN_PORT"
0992b82 @nniclausse check if recorder is already running
nniclausse authored
85 $ERL $ERL_OPTS $ERL_RSH -noshell -sname $RECORDER -setcookie $COOKIE $REC_BOOT_OPT \
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
86 -pa $TSUNGPATH -pa $RECORDERPATH -pa $CONTROLLERPATH \
87 -tsung_recorder debug_level $REC_DEBUG_LEVEL \
88 -tsung_recorder $LOG_OPT \
89 -tsung_recorder plugin ts_proxy_$RECORDER_PLUGIN \
90 -tsung_recorder proxy_log_file \"$MAIN_DIR/tsung_recorder.xml\" \
91 -tsung_recorder proxy_listen_port $LISTEN_PORT &
92 echo $! > /tmp/tsung_recorder.pid
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
93 }
94
7fbd71d @nniclausse check if config file exist
nniclausse authored
95 debug() {
95fb173 @nniclausse add -r option to set the command for starting nodes on remote host (s…
nniclausse authored
96 $ERL $ERL_OPTS $ERL_RSH -sname $CONTROLLER -setcookie $COOKIE $BOOT_OPT \
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
97 -pa $TSUNGPATH -pa $CONTROLLERPATH \
98 -tsung_controller config_file \"$CONF_OPT_FILE\" \
99 -tsung_controller $LOG_OPT
7fbd71d @nniclausse check if config file exist
nniclausse authored
100 }
101
13dfdfd @nniclausse update configure & Makefile
nniclausse authored
102 version() {
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
103 echo "Tsung version $VERSION"
13dfdfd @nniclausse update configure & Makefile
nniclausse authored
104 }
105
7fbd71d @nniclausse check if config file exist
nniclausse authored
106 checkconfig() {
107 if [ ! -e $CONF_OPT_FILE ]
108 then
109 echo "Config file $CONF_OPT_FILE doesn't exist, aborting !"
110 exit 1
111 fi
112 }
113
1ffd1ec @nniclausse add configure scripts to detect erlang installation directory and com…
nniclausse authored
114 maindir() {
115 if [ ! -d $MAIN_DIR ]
116 then
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
117 echo "Creating local Tsung directory $MAIN_DIR"
1ffd1ec @nniclausse add configure scripts to detect erlang installation directory and com…
nniclausse authored
118 mkdir $MAIN_DIR
119 fi
120 }
7fbd71d @nniclausse check if config file exist
nniclausse authored
121
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
122 logdir() {
123 if [ ! -d $LOG_DIR ]
124 then
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
125 echo "Creating Tsung log directory $LOG_DIR"
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
126 mkdir $LOG_DIR
127 fi
128 }
129
130 status() {
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
131 SNAME=tsung_status_$RANDOM
132 $ERL -noshell -sname $SNAME -setcookie $COOKIE -pa $TSUNGPATH -pa $CONTROLLERPATH -s tsung_controller status $HOST -s init stop
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
133 }
134
0992b82 @nniclausse check if recorder is already running
nniclausse authored
135 checkrunning_controller() {
136 RES=`status`
c65d43c @nniclausse fix output msg; fix usage.
nniclausse authored
137 if [ "$RES" != "Tsung is not started" ]; then
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
138 echo "Tsung is already running, exit."
0992b82 @nniclausse check if recorder is already running
nniclausse authored
139 exit 1
140 fi
141 }
142
143 checkrunning(){
144 if [ -f $PIDFILE ]; then
145 CURPID=`cat $PIDFILE`
146 if kill -0 $CURPID 2> /dev/null ; then
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
147 echo "Can't start: Tsung recorder already running !"
0992b82 @nniclausse check if recorder is already running
nniclausse authored
148 exit 1
149 fi
150 fi
151 }
152
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
153 usage() {
c65d43c @nniclausse fix output msg; fix usage.
nniclausse authored
154 prog=`basename $0`
13dfdfd @nniclausse update configure & Makefile
nniclausse authored
155 echo "$prog start|stop|restart|debug|status|recorder|stop_recorder|version"
c65d43c @nniclausse fix output msg; fix usage.
nniclausse authored
156 exit
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
157 }
158
ad4f1ed @nniclausse refactoring of recorder: add plugin architecture for other protocols …
nniclausse authored
159 while getopts ":f:p:l:d:r:" Option
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
160 do
161 case $Option in
7fbd71d @nniclausse check if config file exist
nniclausse authored
162 f) CONF_OPT_FILE=$OPTARG;;
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
163 l) LOG_OPT="log_file \"$OPTARG\" ";;
37364cc @nniclausse add debut level option for recorder
nniclausse authored
164 d) REC_DEBUG_LEVEL=$OPTARG;;
95fb173 @nniclausse add -r option to set the command for starting nodes on remote host (s…
nniclausse authored
165 r) ERL_RSH=" -rsh $OPTARG ";;
ad4f1ed @nniclausse refactoring of recorder: add plugin architecture for other protocols …
nniclausse authored
166 p) RECORDER_PLUGIN=$OPTARG;;
f2c04e9 @nniclausse argh, stupid typo
nniclausse authored
167 *) usage ;;
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
168 esac
169 done
170 shift $(($OPTIND - 1))
171
172 case $1 in
173 start)
0992b82 @nniclausse check if recorder is already running
nniclausse authored
174 checkconfig
175 checkversion
1ffd1ec @nniclausse add configure scripts to detect erlang installation directory and com…
nniclausse authored
176 maindir
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
177 logdir
178 start
179 ;;
180 recorder)
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
181 PIDFILE="/tmp/tsung_recorder.pid"
0992b82 @nniclausse check if recorder is already running
nniclausse authored
182 checkversion
1ffd1ec @nniclausse add configure scripts to detect erlang installation directory and com…
nniclausse authored
183 maindir
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
184 logdir
0992b82 @nniclausse check if recorder is already running
nniclausse authored
185 checkrunning
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
186 recorder
187 ;;
188
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored
189 boot)
0992b82 @nniclausse check if recorder is already running
nniclausse authored
190 checkversion
191 ;;
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored
192
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
193 debug)
0992b82 @nniclausse check if recorder is already running
nniclausse authored
194 checkconfig
195 checkversion
1ffd1ec @nniclausse add configure scripts to detect erlang installation directory and com…
nniclausse authored
196 maindir
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
197 logdir
198 debug
199 ;;
200
201 stop)
202 stop
203 ;;
204 stop_recorder)
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored
205 PIDFILE="/tmp/tsung_recorder.pid"
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
206 stop_recorder
207 ;;
208
209 status)
c65d43c @nniclausse fix output msg; fix usage.
nniclausse authored
210 recorder_status
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
211 status
212 ;;
213
214 restart)
215 stop
216 start
217 ;;
13dfdfd @nniclausse update configure & Makefile
nniclausse authored
218 version)
219 version
220 ;;
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored
221
222 *)
223 usage $0
224 ;;
225 esac
Something went wrong with that request. Please try again.