openmedialibrary/ctl

111 lines
2.1 KiB
Text
Raw Normal View History

2014-05-04 19:26:43 +02:00
#!/usr/bin/env bash
2014-05-13 01:43:27 +02:00
HOST="[::1]:9842"
2014-05-04 19:26:43 +02:00
NAME="openmedialibrary"
PID="/tmp/$NAME.pid"
cd `dirname "$0"`
if [ -e oml ]; then
cd ..
fi
BASE=`pwd`
SYSTEM=`uname -s`
2014-05-17 20:13:58 +02:00
PLATFORM=`uname -m`
2014-05-04 19:26:43 +02:00
2014-05-17 20:13:58 +02:00
if [ $SYSTEM == "Linux" ]; then
SYSTEM="${SYSTEM}_${PLATFORM}"
fi
2014-05-04 19:26:43 +02:00
export PLATFORM_ENV="$BASE/platform/$SYSTEM"
if [ $SYSTEM == "Darwin" ]; then
export DYLD_FALLBACK_LIBRARY_PATH="$PLATFORM_ENV/lib"
fi
PATH="$PLATFORM_ENV/bin:$PATH"
SHARED_ENV="$BASE/platform/Shared"
export SHARED_ENV
PATH="$SHARED_ENV/bin:$PATH"
export PATH
PYTHONPATH="$PLATFORM_ENV/lib/python2.7/site-packages:$SHARED_ENV/lib/python2.7/site-packages:$BASE/$NAME"
export PYTHONPATH
2014-05-14 20:46:31 +02:00
oxCACHE="$BASE/config/ox"
export oxCACHE
2014-05-04 19:26:43 +02:00
#must be called to update commands in $PATH
hash -r 2>/dev/null
if [ "$1" == "start" ]; then
2014-05-20 12:30:53 +02:00
cd "$BASE/$NAME"
2014-05-04 19:26:43 +02:00
if [ -e $PID ]; then
echo openmedialibrary already running
exit 1
fi
2014-05-16 10:06:11 +02:00
python2 oml server PID &
2014-05-04 19:26:43 +02:00
exit $?
fi
if [ "$1" == "debug" ]; then
2014-05-20 12:30:53 +02:00
cd "$BASE/$NAME"
2014-05-04 19:26:43 +02:00
if [ -e $PID ]; then
echo openmedialibrary already running
exit 1
fi
shift
2014-05-16 10:06:11 +02:00
python2 oml server $@
2014-05-04 19:26:43 +02:00
exit $?
fi
if [ "$1" == "stop" ]; then
test -e $PID && kill `cat $PID`
test -e $PID && rm $PID
exit $?
fi
if [ "$1" == "restart" ]; then
if [ -e $PID ]; then
2014-05-20 12:30:53 +02:00
"$0" stop
"$0" start
2014-05-04 19:26:43 +02:00
exit $?
else
exit 1
fi
fi
if [ "$1" == "open" ]; then
#time to switch to python and use webbrowser.open_tab?
if [ $SYSTEM == "Darwin" ]; then
2014-05-20 12:30:53 +02:00
open "http://$HOST/"
2014-05-04 19:26:43 +02:00
else
2014-05-20 12:30:53 +02:00
xdg-open "http://$HOST/"
2014-05-04 19:26:43 +02:00
fi
exit 0
fi
2014-05-16 17:48:48 +02:00
if [ "$1" == "ui" ]; then
shift
python2 $NAME/oml/ui.py $@
exit $?
fi
2014-05-17 13:40:51 +02:00
if [ "$1" == "update" ]; then
2014-05-20 12:30:53 +02:00
cd "$BASE/$NAME"
OLD=`"$0" version`
cd "$BASE/platform"
2014-05-18 00:32:08 +02:00
echo Update platform..
2014-05-17 13:40:51 +02:00
git pull
2014-05-18 00:32:08 +02:00
echo Update $NAME..
2014-05-20 12:30:53 +02:00
cd "$BASE/$NAME"
2014-05-17 13:40:51 +02:00
git pull
2014-05-18 00:32:08 +02:00
find . -name '*.pyc' -exec rm "{}" \;
2014-05-20 02:08:28 +02:00
$0 setup
$0 update_static > /dev/null
2014-05-20 12:30:53 +02:00
NEW=`"$0" version`
2014-05-20 02:08:28 +02:00
$0 postupdate -o $OLD -n $NEW
2014-05-17 13:40:51 +02:00
exit
fi
2014-05-19 22:14:24 +02:00
if [ "$1" == "python" ]; then
2014-05-20 12:30:53 +02:00
cd "$BASE/$NAME"
2014-05-19 22:14:24 +02:00
shift
python2 $@
exit $?
fi
2014-05-04 19:26:43 +02:00
2014-05-20 12:30:53 +02:00
cd "$BASE/$NAME"
2014-05-16 10:06:11 +02:00
python2 oml $@
2014-05-04 19:26:43 +02:00
exit $?