changeset 3:73d3b94b7364

added DNS SRV configuration script + move launching script to scripts/launcher/launch.sh
author souliane <souliane@mailoo.org>
date Fri, 27 Jun 2014 19:17:18 +0200
parents 3ec5808e3b53
children a6af040be754
files scripts/dns_srv/configure_dns_srv.sh scripts/dns_srv/template/etc/bind/named.conf.local scripts/dns_srv/template/var/cache/bind/revp.127.0.0 scripts/dns_srv/template/var/cache/bind/zone.my.domain scripts/launch.sh scripts/launcher/launch.sh
diffstat 6 files changed, 258 insertions(+), 187 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/dns_srv/configure_dns_srv.sh	Fri Jun 27 19:17:18 2014 +0200
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# This script allows you to quickly change your bind9 configuration:
+#     - define an internal domain and bind it to 127.0.0.1
+#     - add SRV records to use this domain with your local XMPP server
+#
+# BE SURE TO BACKUP /etc/bind AND /var/cache/bind BEFORE USING THIS SCRIPT!
+#
+# Configuration files based on:
+#     - http://www.madboa.com/geek/soho-bind
+#     - http://wiki.xmpp.org/web/SRV_Records
+#     - http://prosody.im/doc/dns
+#
+# For this to work, Prosody configuration must define the domain as a VirtualHost.
+# It is also assumed that the Prosody "directory" option is set to "/var/cache/bind".
+
+if [ $# -lt 2 ]; then
+  echo "Usage: `basename $0` <domain> <c2s_port>"
+  exit 1
+fi
+
+HOSTNAME=`cat /etc/hostname`
+DOMAIN=$1
+C2S_PORT=$2
+DATE=`date +%s`
+
+mkdir -p /tmp/$DATE/
+cp -r template/* /tmp/$DATE/
+cd /tmp/$DATE
+for FILE in `find . -type f`; do
+    sed -e s/\<domain\>/$DOMAIN/g -e s/\<hostname\>/$HOSTNAME/g -e s/\<date\>/$DATE/g -e s/\<c2s_port\>/$C2S_PORT/g $FILE > `echo $FILE | sed -e 's/^.//' -e s/my.domain/$DOMAIN/`
+done
+/etc/init.d/bind9 restart
+tail /var/log/syslog
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/dns_srv/template/etc/bind/named.conf.local	Fri Jun 27 19:17:18 2014 +0200
@@ -0,0 +1,9 @@
+zone "<domain>" IN {
+  type master;
+  file "zone.<domain>";
+};
+
+zone "0.0.127.in-addr.arpa" {
+  type master;
+  file "revp.127.0.0";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/dns_srv/template/var/cache/bind/revp.127.0.0	Fri Jun 27 19:17:18 2014 +0200
@@ -0,0 +1,12 @@
+$ORIGIN 0.0.127.in-addr.arpa.
+$TTL 1D
+@     IN SOA  <hostname>.<domain>. <hostname>.<domain>. (
+              <date>     ; serial
+              28800      ; refresh (8 hours)
+              14400      ; retry (4 hours)
+              2419200    ; expire (4 weeks)
+              86400      ; minimum (1 day)
+              )
+
+              NS      <hostname>.<domain>.
+1             PTR     <hostname>.<domain>.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/dns_srv/template/var/cache/bind/zone.my.domain	Fri Jun 27 19:17:18 2014 +0200
@@ -0,0 +1,16 @@
+$ORIGIN <domain>.
+$TTL 1D
+@     IN SOA   <hostname> <hostname> (
+                        <date>    ; serial
+                        8H        ; refresh
+                        4H        ; retry
+                        4W        ; expire
+                        1D )      ; minimum
+
+                NS      <hostname>
+www             CNAME   <hostname>
+localhost       A       127.0.0.1
+<hostname>      A       127.0.0.1
+
+_xmpp-client._tcp.<domain>. 18000 IN SRV 0 5 <c2s_port> <hostname>.<domain>.
+_xmpp-server._tcp.<domain>. 18000 IN SRV 0 5 5269       <hostname>.<domain>.
--- a/scripts/launch.sh	Fri Jun 20 15:01:11 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,187 +0,0 @@
-#!/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
-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
-
-# Connection information for sat_pubsub
-SPS_JID=sat-pubsub.souliane.org
-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=(Peter Steven Dave Dino)
-# 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=1
-# 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 sat_pubsub ###########"
-    kill_process $SPS_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
-}
-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() {
-    echo "## Monitoring DBus for SąT main instance ##"
-    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) monitor;;
-    *)
-        # default: reinstall and restart all
-        stop_lib && stop_sat && stop_ser
-        clean
-        start_ser && start_sat && start_lib
-        ;;
-esac
-
-echo "Done."
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/launcher/launch.sh	Fri Jun 27 19:17:18 2014 +0200
@@ -0,0 +1,187 @@
+#!/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
+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
+
+# Connection information for sat_pubsub
+SPS_JID=sat-pubsub.souliane.org
+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=(Peter Steven Dave Dino)
+# 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=1
+# 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 sat_pubsub ###########"
+    kill_process $SPS_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
+}
+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() {
+    echo "## Monitoring DBus for SąT main instance ##"
+    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) monitor;;
+    *)
+        # default: reinstall and restart all
+        stop_lib && stop_sat && stop_ser
+        clean
+        start_ser && start_sat && start_lib
+        ;;
+esac
+
+echo "Done."