This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit 183a5e49ab188b1eca76a023a5edc4e26ac015bd Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Mon Jul 13 14:59:00 2015 +0200 conf dir is now optionnal (/etc/mum and SCRIPT_DIR/../conf is used as default) use --conf to specify conf dir on command line --- app/mum.py | 12 +++++----- conf/mum.conf | 1 + conf/mum.devel.conf | 7 ++++++ scripts/mum-env.sh | 56 +++++++++++++++++++++++++++++++++----------- scripts/mum-install-bower.sh | 2 +- scripts/mum-install-venv.sh | 2 +- scripts/mum.sh | 2 +- 7 files changed, 59 insertions(+), 23 deletions(-) diff --git a/app/mum.py b/app/mum.py index 122757a..e531ae9 100755 --- a/app/mum.py +++ b/app/mum.py @@ -143,7 +143,7 @@ if __name__ == '__main__': epilog="The following fields must be specified on the configuration file or by " "arguments in order to launch the service: server_port, server_addr, " "db_location.") - parser.add_argument("conf_loc", help="the location of the configuration file (can be relative from the launcher)") + parser.add_argument("--conf", help="the location of the configuration file (can be relative from the launcher)") parser.add_argument("--server_port", type=int, help="the port of the service.") parser.add_argument("--server_addr", help="the address of the service.") parser.add_argument("--db_location", help="the location of the shelve database.") @@ -161,13 +161,13 @@ if __name__ == '__main__': files_to_read = [] - if os.path.isfile(args.conf_loc): + if os.path.isfile(args.conf): # the argument is a file name - files_to_read.append(args.conf_loc) + files_to_read.append(args.conf) else: # the argument is a directory name - path = args.conf_loc + '/' - for dir_content in os.listdir(args.conf_loc): + path = args.conf + '/' + for dir_content in os.listdir(args.conf): files_to_read.append(str(path + dir_content)) # sorting the list in lexicographic order files_to_read = sorted(files_to_read, key=str.lower) @@ -215,4 +215,4 @@ if __name__ == '__main__': port = int(os.environ.get('PORT', int(conf['server_port']))) run(host=conf['server_addr'], port=port, debug=True, server=GeventWebSocketServer) # after ending - ml.stop_monitoring() \ No newline at end of file + ml.stop_monitoring() diff --git a/conf/mum.conf b/conf/mum.conf index ee35c96..996b5a1 100644 --- a/conf/mum.conf +++ b/conf/mum.conf @@ -1,3 +1,4 @@ +# don't modify this file, it's better to create mum.local.conf in same directory server_port=1337 server_addr=0.0.0.0 app_location=/usr/lib/mum diff --git a/conf/mum.devel.conf b/conf/mum.devel.conf new file mode 100644 index 0000000..5eb9dd2 --- /dev/null +++ b/conf/mum.devel.conf @@ -0,0 +1,7 @@ +app_location=. +venv_location=dev_context/venv +db_location=dev_context/data/mum.db +log_location=dev_context/log/mum.log +external_modules_location=dev_context/modules/ +keys_location=dev_context/keys/ +log_level=DEBUG diff --git a/scripts/mum-env.sh b/scripts/mum-env.sh index 7caf2c2..34e65ee 100755 --- a/scripts/mum-env.sh +++ b/scripts/mum-env.sh @@ -4,12 +4,40 @@ if [ -z "$MUM_ENV" ]; then SCRIPT_DIR=$(dirname $(readlink -m $0)) -USAGE="usage $(basename $0) [config_file|config_dir]" -CONF=$1 +USAGE="usage $(basename $0) [options] [--conf config_file|config_dir]" MUM_PY=app/mum.py +# looking for --conf argument to find configuration file/dir +nb=0 +for arg in "$@"; do + nb=$(($nb+1)) + case "$arg" in + --conf=*) + CONF=${arg#*=} + break + ;; + --conf*) + nb=$(($nb+1)) + CONF=${!nb} + break + ;; + esac +done + +if [ -z "$CONF" ]; then + if [ -d "/etc/mum" ];then + # in production + CONF=/etc/mum + elif [ -d "$SCRIPT_DIR/../conf" ];then + # in development + CONF=$SCRIPT_DIR/../conf + fi +fi + +CONF=$(readlink -m $CONF) + if [ -d "$CONF" ]; then - CONF=$CONF/*.conf + CONF=$CONF/*.conf fi if [ -n "$CONF" ]; then @@ -53,20 +81,20 @@ if [ ! -x "$PYTHON_EXEC" -o ! -x "$VENV_EXEC" -o -z "$($PYTHON_EXEC -V 2>&1 |gre exit 1 fi +export CONF +export MUM_DIR=$(readlink -m $MUM_DIR) +export APP_PYTHON_DIR=$(readlink -m $MUM_DIR/app) +export APP_VIEWS_DIR=$(readlink -m $MUM_DIR/views) +export APP_STATIC_DIR=$(readlink -m $MUM_DIR/static) +export VENV_DIR=$(readlink -m $VENV_DIR) +export LOG_DIR=$(readlink -m $LOG_DIR) +export MUM_PY=$(readlink -m $MUM_PY) +export PYTHON_EXEC=$(readlink -m $PYTHON_EXEC) +export VENV_EXEC=$(readlink -m $VENV_EXEC) + mkdir -p $LOG_DIR mkdir -p $(dirname $VENV_DIR) -export CONF -export MUM_DIR -export APP_PYTHON_DIR=$MUM_DIR/app -export APP_VIEWS_DIR=$MUM_DIR/views -export APP_STATIC_DIR=$MUM_DIR/static -export VENV_DIR -export LOG_DIR -export MUM_PY -export PYTHON_EXEC -export VENV_EXEC - export MUM_ENV=true fi diff --git a/scripts/mum-install-bower.sh b/scripts/mum-install-bower.sh index ae2a926..f5cbcb8 100755 --- a/scripts/mum-install-bower.sh +++ b/scripts/mum-install-bower.sh @@ -1,7 +1,7 @@ #!/bin/bash BOWER_CONF=$(readlink -m $1) -TARGET_DIR=$2 +TARGET_DIR=$(readlink -m $2) if [ -d $MUM_DIR/bower_components ]; then ln -s $MUM_DIR/bower_components $TARGET_DIR diff --git a/scripts/mum-install-venv.sh b/scripts/mum-install-venv.sh index 0fb2c56..9c28f6c 100755 --- a/scripts/mum-install-venv.sh +++ b/scripts/mum-install-venv.sh @@ -34,7 +34,7 @@ $SCRIPT_DIR/mum-install-bower.sh $MUM_DIR/bower.json $VENV_DIR echo "Mum - Create application symlink ..." ln -s $APP_PYTHON_DIR $VENV_DIR -ln -s $APP_VIEWS_DIR $VENV_DIR +ln -s $APP_VIEWS_DIR $VENV_DIR ln -s $APP_STATIC_DIR $VENV_DIR exit 0 diff --git a/scripts/mum.sh b/scripts/mum.sh index 3195cd0..14e22cd 100755 --- a/scripts/mum.sh +++ b/scripts/mum.sh @@ -9,4 +9,4 @@ if [ ! -d "$VENV_DIR" ]; then echo "Log files will be saved on $LOG_DIR" $SCRIPT_DIR/mum-install-venv.sh 2> $LOG_DIR/mum.install.err | tee $LOG_DIR/mum.install.log | grep "Mum - " fi -exec $SCRIPT_DIR/mum-in-venv.sh python $MUM_DIR/$MUM_PY $* +exec $SCRIPT_DIR/mum-in-venv.sh python $MUM_PY $* -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.