# HG changeset patch
# User Goffi <goffi@goffi.org>
# Date 1408571121 -7200
# Node ID b56374a1f6d6d8e4f18a85d21a922e52bab11e5c
# Parent  7293233970ab6590fee40f1113b7c9aa1ee27b2e
misc: daemon mode refactoring:
    - there is no more daemon mode disctinction between local and installed version
    - sat is launched as daemon by default, use "sat fg" to launch it foreground

diff -r 7293233970ab -r b56374a1f6d6 setup.py
--- a/setup.py	Wed Aug 20 23:42:58 2014 +0200
+++ b/setup.py	Wed Aug 20 23:45:21 2014 +0200
@@ -65,9 +65,7 @@
         run_dir = os.path.dirname(self.sh_script_path)
         with open(self.sh_script_path, 'r') as sh_file:
             for ori_line in sh_file:
-                if ori_line.startswith('DAEMON='):
-                    dest_line = 'DAEMON=""\n'  # we want to launch sat as a daemon
-                elif ori_line.startswith('TAP_PATH='):
+                if ori_line.startswith('TAP_PATH='):
                     dest_line = 'TAP_PATH="%s/"\n' % run_dir
                 elif ori_line.startswith('PYTHON='):
                     dest_line = 'PYTHON="%s"\n' % sys.executable
diff -r 7293233970ab -r b56374a1f6d6 src/sat.sh
--- a/src/sat.sh	Wed Aug 20 23:42:58 2014 +0200
+++ b/src/sat.sh	Wed Aug 20 23:45:21 2014 +0200
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 DEBUG=""
+DAEMON=""
 PYTHON="python2"
 
 kill_process() {
@@ -59,14 +60,15 @@
     if [ $1 = "stop" ];then
         kill_process $PID_FILE "$APP_NAME"
         exit 0
-    fi
-    if [ $1 = "debug" ];then
+    elif [ $1 = "debug" ];then
         echo "Launching $APP_NAME in debug mode"
         DEBUG="--debug"
+    elif [ $1 = "fg" ];then
+        echo "Launching $APP_NAME in foreground mode"
+        DAEMON="n"
     fi
 fi
 
-DAEMON="n"
 MAIN_OPTIONS="-${DAEMON}oy"
 TAP_PATH="./"
 TAP_FILE="$APP_NAME_FILE.tac"