view src/sat.sh @ 361:141eeb7cd9e6

Quizz game: first draft
author Goffi <goffi@goffi.org>
date Sun, 12 Jun 2011 16:28:33 +0200
parents f147b778511a
children e83d0c21d64d
line wrap: on
line source

#!/bin/sh

#if there is one argument which is "stop", then we kill SàT
DEBUG=""
if [ $# -eq 1 ];then
	if [ $1 = "stop" ];then
		echo "Terminating Salut à Toi"
		pkill -f "twistd.*/sat.tac"
		exit 0
	fi
	if [ $1 = "debug" ];then
		echo "Launching SàT in debug mode"
		DEBUG="--debug"
	fi
fi

NAME='sat'

if [ -n "$SAT_CONST_local_dir" ];then
	echo "Using overidded local dir: $SAT_CONST_local_dir"
	PID_FILE="$SAT_CONST_local_dir/$NAME.pid"
	LOG_FILE="$SAT_CONST_local_dir/$NAME.log"
else
	PID_FILE="/tmp/$NAME.pid"
	LOG_FILE=~/".$NAME/$NAME.log"
fi
DAEMON="n"
MAIN_OPTIONS="-${DAEMON}oy"
TAP_PATH="./"
TAP_FILE="$NAME.tac"

#Don't change the next line
AUTO_OPTIONS=""
ADDITIONAL_OPTIONS="--pidfile $PID_FILE --logfile $LOG_FILE $AUTO_OPTIONS $DEBUG"

log_dir=`dirname "$LOG_FILE"`
if [ ! -d $log_dir ] ; then
	mkdir $log_dir
fi

twistd $MAIN_OPTIONS $TAP_PATH$TAP_FILE $ADDITIONAL_OPTIONS