Mercurial > sat_docs
comparison scripts/launcher/launch.sh @ 49:068252a37689
update launching script
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 28 Sep 2015 09:40:33 +0200 |
parents | 1eb3ec190ea1 |
children | fe116a11199b |
comparison
equal
deleted
inserted
replaced
48:358a4fc0e091 | 49:068252a37689 |
---|---|
1 #!/bin/bash | 1 cd #!/bin/bash |
2 | 2 |
3 # This is a helping script to do some tasks like installing, cleaning, starting sat and/or libervia. | 3 # This is a helping script to do some tasks like installing, cleaning, starting sat and/or libervia. |
4 | 4 |
5 # Python dist-packages where project are installed | 5 # Python and resources paths |
6 PACKAGES=/usr/local/lib/python2.7/dist-packages | 6 PACKAGES=/usr/local/lib/python2.7/dist-packages |
7 SHARE=/usr/local/share | |
8 TMP=~/workspace/tmp_packages | |
7 | 9 |
8 # Paths to the projects | 10 # Paths to the projects |
9 WORKSPACE=~/workspace | 11 WORKSPACE=~/workspace |
10 SAT=$WORKSPACE/sat | 12 SAT=$WORKSPACE/sat |
11 PYJS=$WORKSPACE/pyjamas | 13 PYJS=$WORKSPACE/pyjamas |
39 # 4 Firefox profiles names for testing | 41 # 4 Firefox profiles names for testing |
40 FF_PROFILES=(test1 test2 test3 test4) | 42 FF_PROFILES=(test1 test2 test3 test4) |
41 # 4 SàT profiles names for testing | 43 # 4 SàT profiles names for testing |
42 SAT_PROFILES=(pierre elisee louise buenaventura) | 44 SAT_PROFILES=(pierre elisee louise buenaventura) |
43 # Common profile password for these profiles | 45 # Common profile password for these profiles |
44 SAT_PROFILES_PASSWD= | 46 SAT_PROFILES_PASSWD=xxxxxx |
45 | 47 |
46 # Launch sat in debug mode? | 48 # Launch sat in debug mode? |
47 SAT_DEBUG=1 | 49 SAT_DEBUG=1 |
48 # Launch sat pubsub in debug mode? | 50 # Launch sat pubsub in debug mode? |
49 SPS_DEBUG=0 | 51 SPS_DEBUG=0 |
52 # Launch salut in debug mode? | |
53 SALUT_DEBUG=0 | |
50 # Launch libervia in debug mode? | 54 # Launch libervia in debug mode? |
51 LIB_DEBUG=0 | 55 LIB_DEBUG=1 |
52 # Force killing processes? | 56 # Force killing processes? |
53 KILL_FORCE=1 | 57 KILL_FORCE=1 |
58 | |
54 | 59 |
55 kill_process() { | 60 kill_process() { |
56 # $1 is the file containing the PID to kill | 61 # $1 is the file containing the PID to kill |
57 if [ -f $1 ]; then | 62 if [ -f $1 ]; then |
58 PID=`cat $1` | 63 PID=`cat $1` |
65 fi | 70 fi |
66 rm -f $1 | 71 rm -f $1 |
67 fi | 72 fi |
68 } | 73 } |
69 | 74 |
75 debug_console() { | |
76 PYTHONPATH=$TMP:$PYTHONPATH x-terminal-emulator -e "$@" & | |
77 } | |
78 | |
79 install() { | |
80 echo "########## Compiling prosody ##########" | |
81 cd $PROSODY && make | |
82 echo "########## Installing sat_pubsub ##########" | |
83 cd $SATPUBSUB && sudo python setup.py install | |
84 echo "############## Installing sat #############" | |
85 cd $SAT && sudo python setup.py install | |
86 echo "########### Installing libervia ###########" | |
87 cd $LIBERVIA && sudo python setup.py install | |
88 } | |
89 | |
70 stop_lib() { | 90 stop_lib() { |
71 echo "############ Stopping libervia ############" | 91 echo "############ Stopping libervia ############" |
72 libervia stop | 92 libervia stop |
73 kill_process $LIB_PID | 93 kill_process $LIB_PID |
74 } | 94 } |
95 | |
75 stop_sat() { | 96 stop_sat() { |
76 echo "############### Stopping sat ##############" | 97 echo "############### Stopping sat ##############" |
77 sat stop | 98 sat stop |
78 kill_process $SAT_PID | 99 kill_process $SAT_PID |
79 } | 100 } |
101 | |
102 stop_sps() { | |
103 kill_process $SPS_PID | |
104 } | |
105 | |
106 stop_salut() { | |
107 kill_process $SALUT_PID | |
108 } | |
109 | |
80 stop_ser() { | 110 stop_ser() { |
81 echo "############# Stopping Prosody ############" | 111 echo "############# Stopping Prosody ############" |
82 cd $PROSODY && if [[ -f $SER_PID ]]; then ./prosodyctl stop; fi | 112 cd $PROSODY && if [[ -f $SER_PID ]]; then ./prosodyctl stop; fi |
83 kill_process $SER_PID | 113 kill_process $SER_PID |
84 echo "####### Stopping Prosody components #######" | 114 echo "####### Stopping Prosody components #######" |
85 kill_process $SPS_PID | 115 stop_sps |
86 kill_process $SALUT_PID | 116 stop_salut |
87 } | 117 echo "####### Stopping bind9 #######" |
118 sudo /etc/init.d/bind9 stop | |
119 | |
120 } | |
121 | |
122 start_sps() { | |
123 echo "########### Starting sat-pubsub ###########" | |
124 cd $SATPUBSUB | |
125 if [[ $SPS_DEBUG = 1 ]]; then | |
126 debug_console twistd -n -b sat_pubsub --jid=$SPS_JID --secret=$SPS_PWD | |
127 else | |
128 twistd sat_pubsub --jid=$SPS_JID --secret=$SPS_PWD | |
129 fi | |
130 } | |
131 | |
132 start_salut() { | |
133 echo "############## Starting salut #############" | |
134 cd $SALUT | |
135 if [[ $SALUT_DEBUG = 1 ]]; then | |
136 debug_console twistd -b -y salut.tac | |
137 else | |
138 twistd -y salut.tac | |
139 fi | |
140 } | |
141 | |
88 start_ser() { | 142 start_ser() { |
89 echo "############# Starting Prosody ############" | 143 echo "############# Starting Prosody ############" |
90 cd $PROSODY && ./prosodyctl start & | 144 cd $PROSODY && ./prosodyctl start & |
91 echo "########## Installing sat_pubsub ##########" | 145 start_sps |
92 cd $SATPUBSUB && sudo python setup.py install | 146 start_salut |
93 echo "########### Starting sat-pubsub ###########" | 147 echo "############## Starting bind9 #############" |
94 if [[ $SPS_DEBUG = 1 ]]; then | 148 sudo /etc/init.d/bind9 restart |
95 mate-terminal -e "twistd -n -b sat_pubsub --jid=$SPS_JID --secret=$SPS_PWD" & | 149 } |
96 else | 150 |
97 twistd sat_pubsub --jid=$SPS_JID --secret=$SPS_PWD | |
98 fi | |
99 echo "############## Starting salut #############" | |
100 cd $SALUT && twistd -y salut.tac | |
101 } | |
102 start_sat() { | 151 start_sat() { |
103 echo "############## Installing sat #############" | |
104 cd $SAT && sudo python setup.py install | |
105 echo "############### Starting sat ##############" | 152 echo "############### Starting sat ##############" |
153 cd $SAT/src | |
106 if [[ $SAT_DEBUG = 1 ]]; then | 154 if [[ $SAT_DEBUG = 1 ]]; then |
107 mate-terminal -e "sat debug" & | 155 debug_console ./sat.sh debug |
108 else | 156 else |
109 sat | 157 ./sat.sh |
110 fi | 158 fi |
111 } | 159 } |
160 | |
112 start_lib() { | 161 start_lib() { |
113 echo "########### Installing libervia ###########" | |
114 cd $LIBERVIA && sudo python setup.py install | |
115 echo "############ Starting libervia ############" | 162 echo "############ Starting libervia ############" |
116 cd src | 163 cd $LIBERVIA/src/browser |
164 pyjsbuild libervia_main -d --no-compile-inplace --platforms=mozilla -I $TMP -o $LIBERVIA/html | |
165 cd $LIBERVIA/src | |
117 if [[ $LIB_DEBUG = 1 ]]; then | 166 if [[ $LIB_DEBUG = 1 ]]; then |
118 mate-terminal -e "libervia debug" & | 167 debug_console ./libervia.sh debug |
119 else | 168 else |
120 libervia | 169 ./libervia.sh |
121 fi | 170 fi |
122 } | 171 } |
172 | |
123 4foxes() { | 173 4foxes() { |
124 # Starts 4 instances of firefox and connect SàT profiles with Libervia | 174 # Starts 4 instances of firefox and connect SàT profiles with Libervia |
125 # Assumes the HTTPS port for local server is 8443 | 175 # Assumes the HTTPS port for local server is 8443 |
126 echo "####### Starting 4 libervia clients #######" | 176 echo "####### Starting 4 libervia clients #######" |
127 for I in `seq 0 3`; do | 177 for I in `seq 0 3`; do |
128 URL="https://localhost:8443/libervia.html?login=${SAT_PROFILES[$I]}&passwd=${SAT_PROFILES_PASSWD}" | 178 URL="https://localhost:8443/libervia.html?login=${SAT_PROFILES[$I]}&passwd=${SAT_PROFILES_PASSWD}" |
129 firefox -no-remote -P ${FF_PROFILES[$I]} "$URL" & | 179 firefox -no-remote -P ${FF_PROFILES[$I]} "$URL" & |
130 done | 180 done |
131 } | 181 } |
182 | |
132 clean() { | 183 clean() { |
133 echo "############ Cleaning log files ###########" | 184 echo "############ Cleaning log files ###########" |
134 rm -f $LOCAL_DIR/*.log* | 185 rm -f $LOCAL_DIR/*.log* |
135 rm -f $SATPUBSUB/twistd.log* | 186 rm -f $SATPUBSUB/twistd.log* |
187 rm -f $SALUT/twistd.log* | |
136 rm -f $PROSODY/prosody.log* $PROSODY/prosody.err* | 188 rm -f $PROSODY/prosody.log* $PROSODY/prosody.err* |
137 } | 189 } |
190 | |
138 purge() { | 191 purge() { |
139 echo "######## Purging installed packages #######" | 192 echo "######## Purging installed packages #######" |
140 rm -rf $PACKAGES/sat | 193 rm -rf $PACKAGES/sat |
141 rm -rf $PACKAGES/sat_frontends | 194 rm -rf $PACKAGES/sat_frontends |
142 rm -rf $PACKAGES/libervia | 195 rm -rf $PACKAGES/libervia |
143 rm -rf $PACKAGES/libervia_server | 196 rm -rf $PACKAGES/libervia_server |
144 } | 197 rm -rf $SHARE/libervia |
145 main() { | 198 } |
199 | |
200 sat_main() { | |
146 echo "######## Starting SàT main instance #######" | 201 echo "######## Starting SàT main instance #######" |
147 export PYTHONPATH=$SAT_MAIN/lib | 202 cd $SAT_MAIN/lib/sat && hg pull -u && PYTHONPATH=$SAT_MAIN/lib:$PYTHONPATH ./sat.sh |
148 cd $SAT_MAIN/lib/sat && hg pull -u && ./sat.sh | |
149 echo "#### Starting primitivus main instance ####" | 203 echo "#### Starting primitivus main instance ####" |
150 cd $SAT_MAIN/lib/sat_frontends/primitivus && ./primitivus | 204 cd $SAT_MAIN/lib/sat_frontends/primitivus && PYTHONPATH=$SAT_MAIN/lib:$PYTHONPATH ./primitivus -p souliane |
151 } | 205 } |
206 | |
207 primitivus_main() { | |
208 echo "#### Starting primitivus main instance ####" | |
209 cd $SAT_MAIN/lib/sat_frontends/primitivus && PYTHONPATH=$SAT_MAIN/lib:$PYTHONPATH ./primitivus | |
210 } | |
211 | |
152 bridge() { | 212 bridge() { |
153 echo "######### Generating DBus.py files ########" | 213 echo "######### Generating DBus.py files ########" |
154 cd $SAT/src/bridge/bridge_constructor | 214 cd $SAT/src/bridge/bridge_constructor |
155 ./bridge_constructor.py --force && cp generated/DBus.py ../DBus.py | 215 ./bridge_constructor.py --force && cp generated/DBus.py ../DBus.py |
156 ./bridge_constructor.py -s frontend --force && cp generated/DBus.py ../../../frontends/src/bridge/DBus.py | 216 ./bridge_constructor.py -s frontend --force && cp generated/DBus.py ../../../frontends/src/bridge/DBus.py |
157 cd $SAT_MAIN/src/bridge/bridge_constructor | 217 cd $SAT_MAIN/src/bridge/bridge_constructor |
158 SAT_BRIDGE_CONST_INT_PREFIX='"org.goffi.sat_main"' ./bridge_constructor.py --force && cp generated/DBus.py ../DBus.py | 218 SAT_BRIDGE_CONST_INT_PREFIX='"org.goffi.sat_main"' ./bridge_constructor.py --force && cp generated/DBus.py ../DBus.py |
159 SAT_BRIDGE_CONST_INT_PREFIX='"org.goffi.sat_main"' ./bridge_constructor.py -s frontend --force && cp generated/DBus.py ../../../frontends/src/bridge/DBus.py | 219 SAT_BRIDGE_CONST_INT_PREFIX='"org.goffi.sat_main"' ./bridge_constructor.py -s frontend --force && cp generated/DBus.py ../../../frontends/src/bridge/DBus.py |
160 } | 220 } |
221 | |
161 monitor_core() { | 222 monitor_core() { |
162 echo "## Monitoring DBus for SàT dev instance - core ##" | 223 echo "## Monitoring DBus for SàT dev instance - core ##" |
163 dbus-monitor "sender='org.goffi.SAT', interface='org.goffi.SAT.core'" | 224 dbus-monitor "sender='org.goffi.SAT', interface='org.goffi.SAT.core'" |
164 } | 225 } |
226 | |
165 monitor_plugin() { | 227 monitor_plugin() { |
166 echo "## Monitoring DBus for SàT dev instance - plugin ##" | 228 echo "## Monitoring DBus for SàT dev instance - plugin ##" |
167 dbus-monitor "sender='org.goffi.SAT', interface='org.goffi.SAT.plugin'" | 229 dbus-monitor "sender='org.goffi.SAT', interface='org.goffi.SAT.plugin'" |
168 } | 230 } |
231 | |
169 monitor_main() { | 232 monitor_main() { |
170 echo "## Monitoring DBus for SàT main instance (redirected to /tmp/...) ##" | 233 echo "## Monitoring DBus for SàT main instance (redirected to /tmp/...) ##" |
171 killall -q dbus-monitor | 234 killall -q dbus-monitor |
172 nohup dbus-monitor "sender='org.goffi.sat_main', interface='org.goffi.sat_main.core'" >> /tmp/sat_xml_core_`date +%y.%m.%d`& | 235 nohup dbus-monitor "sender='org.goffi.sat_main', interface='org.goffi.sat_main.core'" >> /tmp/sat_xml_core_`date +%y.%m.%d`& |
173 nohup dbus-monitor "sender='org.goffi.sat_main', interface='org.goffi.sat_main.plugin'" >> /tmp/sat_xml_plugin_`date +%y.%m.%d`& | 236 nohup dbus-monitor "sender='org.goffi.sat_main', interface='org.goffi.sat_main.plugin'" >> /tmp/sat_xml_plugin_`date +%y.%m.%d`& |
174 } | 237 } |
238 | |
239 link_pkgs() { | |
240 echo "## Linking temporary packages directory ##" | |
241 rm -f $TMP/* # avoid to create symlinks like $TMP/sat/src | |
242 mkdir -p $TMP | |
243 ln -s $SAT/src $TMP/sat | |
244 ln -s $SAT/frontends/src $TMP/sat_frontends | |
245 ln -s $LIBERVIA/src $TMP/libervia | |
246 ln -s $WORKSPACE/urwid_satext/urwid_satext $TMP/urwid_satext | |
247 } | |
248 | |
249 echo "using temporary directory $TMP" | |
250 export PYTHONPATH=$TMP:$PYTHONPATH | |
251 | |
175 case "$1" in | 252 case "$1" in |
253 install) install ;; | |
176 stop_lib) stop_lib ;; | 254 stop_lib) stop_lib ;; |
177 stop_sat) stop_sat ;; | 255 stop_sat) stop_sat ;; |
178 stop_ser) stop_ser ;; | 256 stop_ser) stop_ser ;; |
179 start_ser) start_ser ;; | 257 start_ser) start_ser ;; |
180 start_sat) start_sat ;; | 258 start_sat) start_sat ;; |
181 start_lib) start_lib ;; | 259 start_lib) start_lib ;; |
182 stop) stop_lib && stop_sat && stop_ser ;; | 260 stop) stop_lib && stop_sat && stop_ser ;; |
183 start) start_ser && start_sat && start_lib;; | 261 start) start_ser && start_sat && start_lib;; |
184 restart_sat) stop_sat && stop_ser && start_ser && start_sat ;; | 262 restart_ser) stop_ser && start_ser ;; |
263 restart_sat) stop_sat && start_sat ;; | |
185 restart_lib) stop_lib && start_lib ;; | 264 restart_lib) stop_lib && start_lib ;; |
265 restart_all) | |
266 stop_lib && stop_sat && stop_ser && clean | |
267 start_ser && start_sat && start_lib;; | |
268 restart_sps) stop_sps && start_sps;; | |
269 restart_salut) stop_salut && start_salut ;; | |
186 4foxes) 4foxes ;; | 270 4foxes) 4foxes ;; |
187 clean) clean ;; | 271 clean) clean ;; |
188 purge) clean && purge;; | 272 purge) clean && purge;; |
189 main) main ;; | 273 main) sat_main ;; |
274 primitivus_main) primitivus_main ;; | |
190 bridge) bridge ;; | 275 bridge) bridge ;; |
191 monitor_core) monitor_core ;; | 276 monitor_core) monitor_core ;; |
192 monitor_plugin) monitor_plugin ;; | 277 monitor_plugin) monitor_plugin ;; |
193 monitor_main) monitor_main ;; | 278 monitor_main) monitor_main ;; |
279 link_pkgs) link_pkgs ;; | |
194 *) | 280 *) |
195 # default: reinstall and restart all | 281 echo "Please specify a valid command." |
196 stop_lib && stop_sat && stop_ser | |
197 clean | |
198 start_ser && start_sat && start_lib | |
199 ;; | |
200 esac | 282 esac |
201 | 283 |
202 echo "Done." | 284 echo "Done." |