Mercurial > sat_docs
view scripts/launcher/launch.sh @ 152:4dc8ed9ae4de
flatpak: added flatpakref files
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 26 Jun 2019 21:39:14 +0200 |
parents | 4cd5475623eb |
children |
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 and resources paths PACKAGES=/usr/local/lib/python2.7/dist-packages SHARE=/usr/local/share TMP=~/workspace/tmp_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 # Services host SERVICE=libervia # Connection information for Prosody components SPS_JID=sat-pubsub.$SERVICE 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) # Common profile password for these profiles SAT_PROFILES_PASSWD=xxxxxx # Launch sat in debug mode? SAT_DEBUG=1 # Launch sat pubsub in debug mode? SPS_DEBUG=0 # Launch salut in debug mode? SALUT_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 } debug_console() { PYTHONPATH=$TMP:$PYTHONPATH x-terminal-emulator -e "$@" & } install() { echo "########## Compiling prosody ##########" cd $PROSODY && make echo "########## Installing sat_pubsub ##########" cd $SATPUBSUB && sudo python setup.py install echo "############## Installing sat #############" cd $SAT && sudo python setup.py install echo "########### Installing libervia ###########" cd $LIBERVIA && sudo python setup.py install } stop_lib() { echo "############ Stopping libervia ############" libervia stop kill_process $LIB_PID } stop_sat() { echo "############### Stopping sat ##############" sat stop kill_process $SAT_PID } stop_sps() { kill_process $SPS_PID } stop_salut() { kill_process $SALUT_PID } stop_ser() { echo "############# Stopping Prosody ############" cd $PROSODY && if [[ -f $SER_PID ]]; then ./prosodyctl stop; fi kill_process $SER_PID echo "####### Stopping Prosody components #######" stop_sps stop_salut echo "####### Stopping bind9 #######" sudo /etc/init.d/bind9 stop 2> /dev/null || echo "bind9 not installed?" } start_sps() { echo "########### Starting sat-pubsub ###########" cd $SATPUBSUB if [[ $SPS_DEBUG = 1 ]]; then debug_console twistd -n -b sat_pubsub --jid=$SPS_JID --secret=$SPS_PWD else twistd sat_pubsub --jid=$SPS_JID --secret=$SPS_PWD #-v fi } start_salut() { echo "############## Starting salut #############" cd $SALUT if [[ $SALUT_DEBUG = 1 ]]; then debug_console twistd -b -y salut.tac else twistd -y salut.tac fi } start_ser() { echo "############# Starting Prosody ############" cd $PROSODY && ./prosodyctl start & start_sps start_salut echo "############## Starting bind9 #############" sudo /etc/init.d/bind9 restart 2> /dev/null || echo "bind9 not installed?" } start_sat() { echo "############### Starting sat ##############" cd $SAT/src if [[ $SAT_DEBUG = 1 ]]; then debug_console ./sat.sh debug else ./sat.sh fi } start_lib() { echo "############ Starting libervia ############" cd $LIBERVIA/src/browser #--platforms=mozilla pyjsbuild libervia_main -d --no-compile-inplace -I $TMP -o $LIBERVIA/html cd $LIBERVIA/src if [[ $LIB_DEBUG = 1 ]]; then debug_console ./libervia.sh debug else ./libervia.sh 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}" 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 $SALUT/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 rm -rf $SHARE/libervia } sat_main() { echo "######## Starting SàT main instance #######" cd $SAT_MAIN/lib/sat && hg qpop -a && hg pull -u && hg qpush -a && PYTHONPATH=$SAT_MAIN/lib:$PYTHONPATH ./sat.sh echo "#### Starting primitivus main instance ####" cd $SAT_MAIN/lib/sat_frontends/primitivus && PYTHONPATH=$SAT_MAIN/lib:$PYTHONPATH ./primitivus -p souliane } primitivus_main() { echo "#### Starting primitivus main instance ####" cd $SAT_MAIN/lib/sat_frontends/primitivus && PYTHONPATH=$SAT_MAIN/lib:$PYTHONPATH ./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`& } link_pkgs() { echo "## Linking temporary packages directory ##" rm -f $TMP/* # avoid to create symlinks like $TMP/sat/src mkdir -p $TMP ln -s $SAT/src $TMP/sat ln -s $SAT/frontends/src $TMP/sat_frontends ln -s $LIBERVIA/src $TMP/libervia ln -s $WORKSPACE/urwid_satext/urwid_satext $TMP/urwid_satext } echo "using temporary directory $TMP" export PYTHONPATH=$TMP:$PYTHONPATH case "$1" in install) install ;; 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_sps) stop_sps && start_sps ;; restart_ser) stop_ser && start_ser ;; restart_sat) stop_sat && start_sat ;; restart_lib) stop_lib && start_lib ;; restart_all) stop_lib && stop_sat && stop_ser && clean start_ser && start_sat && start_lib;; restart_sps) stop_sps && start_sps;; restart_salut) stop_salut && start_salut ;; 4foxes) 4foxes ;; clean) clean ;; purge) clean && purge;; main) sat_main ;; primitivus_main) primitivus_main ;; bridge) bridge ;; monitor_core) monitor_core ;; monitor_plugin) monitor_plugin ;; monitor_main) monitor_main ;; link_pkgs) link_pkgs ;; *) echo "Please specify a valid command." esac echo "Done."