Mercurial > sat_docs
view scripts/launcher/launch.sh @ 37:2abfd0f6fd34
association: AG extraordinaire du 05/02/2015
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 05 Feb 2015 11:46:12 +0100 |
parents | 7b337be4052d |
children | 1eb3ec190ea1 |
line wrap: on
line source
#!/bin/bash # This is a helping script to do some tasks like installing, cleaning, starting sat and/or libervia. # Python dist-packages where project are installed PACKAGES=/usr/local/lib/python2.7/dist-packages # Paths to the projects WORKSPACE=~/workspace SAT=$WORKSPACE/sat PYJS=$WORKSPACE/pyjamas LIBERVIA=$WORKSPACE/libervia PROSODY=$WORKSPACE/prosody-hg SATPUBSUB=$WORKSPACE/sat_pubsub SALUT=$WORKSPACE/salut URWID_SATEXT=$WORKSPACE/urwid_satext # PIDs of the processes LOCAL_DIR=~/.local/share/sat SAT_PID=$LOCAL_DIR/sat.pid LIB_PID=$LOCAL_DIR/libervia.pid SER_PID=$PROSODY/prosody.pid SPS_PID=$SATPUBSUB/twistd.pid SALUT_PID=$SALUT/twistd.pid # Connection information for Prosody components SPS_JID=sat-pubsub.tazar.int SPS_PWD=password # Informations for a concurrent sat instance # For this to work, you have to follow the instructions in: # http://wiki.goffi.org/wiki/Howto_launch_several_S%C3%A0T_instances # Also: # - modify const_INT_PREFIX in the two DBus.py files # - set DAEMON="" in the sat.sh to launch sat as a daemon SAT_MAIN=$WORKSPACE/sat_main SAT_MAIN_PID=~/.sat_main/sat.pid # 4 Firefox profiles names for testing FF_PROFILES=(test1 test2 test3 test4) # 4 SàT profiles names for testing SAT_PROFILES=(pierre elisee louise buenaventura) # Passwords for these profiles SAT_PROFILES_PASSWD=(xxxxxx xxxxxx xxxxxx xxxxxx) # Launch sat in debug mode? SAT_DEBUG=1 # Launch sat pubsub in debug mode? SPS_DEBUG=0 # Launch libervia in debug mode? LIB_DEBUG=0 # Force killing processes? KILL_FORCE=1 kill_process() { # $1 is the file containing the PID to kill if [ -f $1 ]; then PID=`cat $1` if ps -p $PID > /dev/null; then if [[ $KILL_FORCE = 1 ]]; then kill -9 $PID else kill -INT $PID fi fi rm -f $1 fi } stop_lib() { echo "############ Stopping libervia ############" libervia stop kill_process $LIB_PID } stop_sat() { echo "############### Stopping sat ##############" sat stop kill_process $SAT_PID } stop_ser() { echo "############# Stopping Prosody ############" cd $PROSODY && if [[ -f $SER_PID ]]; then ./prosodyctl stop; fi kill_process $SER_PID echo "####### Stopping Prosody components #######" kill_process $SPS_PID kill_process $SALUT_PID } start_ser() { echo "############# Starting Prosody ############" cd $PROSODY && ./prosodyctl start & echo "########## Installing sat_pubsub ##########" cd $SATPUBSUB && sudo python setup.py install echo "########### Starting sat-pubsub ###########" if [[ $SPS_DEBUG = 1 ]]; then mate-terminal -e "twistd -n -b sat_pubsub --jid=$SPS_JID --secret=$SPS_PWD" & else twistd sat_pubsub --jid=$SPS_JID --secret=$SPS_PWD fi echo "############## Starting salut #############" cd $SALUT && twistd -y salut.tac } start_sat() { echo "############## Installing sat #############" cd $SAT && sudo python setup.py install echo "############### Starting sat ##############" if [[ $SAT_DEBUG = 1 ]]; then mate-terminal -e "sat debug" & else sat fi } start_lib() { echo "########### Installing libervia ###########" cd $LIBERVIA && sudo python setup.py install echo "############ Starting libervia ############" cd src if [[ $LIB_DEBUG = 1 ]]; then mate-terminal -e "libervia debug" & else libervia fi } 4foxes() { # Starts 4 instances of firefox and connect SàT profiles with Libervia # Assumes the HTTPS port for local server is 8443 echo "####### Starting 4 libervia clients #######" for I in `seq 0 3`; do URL="https://localhost:8443/libervia.html?login=${SAT_PROFILES[$I]}&passwd=${SAT_PROFILES_PASSWD[$I]}" firefox -no-remote -P ${FF_PROFILES[$I]} "$URL" & done } clean() { echo "############ Cleaning log files ###########" rm -f $LOCAL_DIR/*.log* rm -f $SATPUBSUB/twistd.log* rm -f $PROSODY/prosody.log* $PROSODY/prosody.err* } purge() { echo "######## Purging installed packages #######" rm -rf $PACKAGES/sat rm -rf $PACKAGES/sat_frontends rm -rf $PACKAGES/libervia rm -rf $PACKAGES/libervia_server } main() { echo "######## Starting SàT main instance #######" export PYTHONPATH=$SAT_MAIN/lib cd $SAT_MAIN/lib/sat && hg pull -u && ./sat.sh echo "#### Starting primitivus main instance ####" cd $SAT_MAIN/lib/sat_frontends/primitivus && ./primitivus } bridge() { echo "######### Generating DBus.py files ########" cd $SAT/src/bridge/bridge_constructor ./bridge_constructor.py --force && cp generated/DBus.py ../DBus.py ./bridge_constructor.py -s frontend --force && cp generated/DBus.py ../../../frontends/src/bridge/DBus.py cd $SAT_MAIN/src/bridge/bridge_constructor SAT_BRIDGE_CONST_INT_PREFIX='"org.goffi.sat_main"' ./bridge_constructor.py --force && cp generated/DBus.py ../DBus.py SAT_BRIDGE_CONST_INT_PREFIX='"org.goffi.sat_main"' ./bridge_constructor.py -s frontend --force && cp generated/DBus.py ../../../frontends/src/bridge/DBus.py } monitor_core() { echo "## Monitoring DBus for SàT dev instance - core ##" dbus-monitor "sender='org.goffi.SAT', interface='org.goffi.SAT.core'" } monitor_plugin() { echo "## Monitoring DBus for SàT dev instance - plugin ##" dbus-monitor "sender='org.goffi.SAT', interface='org.goffi.SAT.plugin'" } monitor_main() { echo "## Monitoring DBus for SàT main instance (redirected to /tmp/...) ##" killall -q dbus-monitor nohup dbus-monitor "sender='org.goffi.sat_main', interface='org.goffi.sat_main.core'" >> /tmp/sat_xml_core_`date +%y.%m.%d`& nohup dbus-monitor "sender='org.goffi.sat_main', interface='org.goffi.sat_main.plugin'" >> /tmp/sat_xml_plugin_`date +%y.%m.%d`& } case "$1" in stop_lib) stop_lib ;; stop_sat) stop_sat ;; stop_ser) stop_ser ;; start_ser) start_ser ;; start_sat) start_sat ;; start_lib) start_lib ;; stop) stop_lib && stop_sat && stop_ser ;; start) start_ser && start_sat && start_lib;; restart_sat) stop_sat && stop_ser && start_ser && start_sat ;; restart_lib) stop_lib && start_lib ;; 4foxes) 4foxes ;; clean) clean ;; purge) clean && purge;; main) main ;; bridge) bridge ;; monitor_core) monitor_core ;; monitor_plugin) monitor_plugin ;; monitor_main) monitor_main ;; *) # default: reinstall and restart all stop_lib && stop_sat && stop_ser clean start_ser && start_sat && start_lib ;; esac echo "Done."