2014-05-04 17:26:43 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-02-22 11:23:06 +00:00
|
|
|
HOST="127.0.0.1:9842"
|
2014-05-04 17:26:43 +00:00
|
|
|
NAME="openmedialibrary"
|
2014-08-17 16:11:19 +00:00
|
|
|
PID="/tmp/$NAME.$USER.pid"
|
2014-05-04 17:26:43 +00:00
|
|
|
|
2014-08-04 18:25:27 +00:00
|
|
|
cd "`dirname "$0"`"
|
2014-05-04 17:26:43 +00:00
|
|
|
if [ -e oml ]; then
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
BASE=`pwd`
|
|
|
|
SYSTEM=`uname -s`
|
2014-05-17 18:13:58 +00:00
|
|
|
PLATFORM=`uname -m`
|
2014-05-04 17:26:43 +00:00
|
|
|
|
2014-05-17 18:13:58 +00:00
|
|
|
if [ $SYSTEM == "Linux" ]; then
|
2015-11-03 17:44:34 +00:00
|
|
|
export PLATFORM_ENV="$BASE/platform/${SYSTEM}_${PLATFORM}"
|
|
|
|
else
|
|
|
|
export PLATFORM_ENV="$BASE/platform/$SYSTEM"
|
2014-05-17 18:13:58 +00:00
|
|
|
fi
|
2014-05-04 17:26:43 +00:00
|
|
|
if [ $SYSTEM == "Darwin" ]; then
|
2015-11-03 11:13:27 +00:00
|
|
|
export DYLD_FALLBACK_LIBRARY_PATH="$PLATFORM_ENV/lib"
|
2014-05-04 17:26:43 +00:00
|
|
|
fi
|
|
|
|
PATH="$PLATFORM_ENV/bin:$PATH"
|
|
|
|
|
|
|
|
SHARED_ENV="$BASE/platform/Shared"
|
|
|
|
export SHARED_ENV
|
|
|
|
|
|
|
|
PATH="$SHARED_ENV/bin:$PATH"
|
|
|
|
export PATH
|
|
|
|
|
2014-09-02 22:32:44 +00:00
|
|
|
PYTHONPATH="$PLATFORM_ENV/lib/python3.4/site-packages:$SHARED_ENV/lib/python3.4/site-packages:$BASE/$NAME"
|
2014-05-04 17:26:43 +00:00
|
|
|
export PYTHONPATH
|
|
|
|
|
2014-05-14 18:46:31 +00:00
|
|
|
oxCACHE="$BASE/config/ox"
|
|
|
|
export oxCACHE
|
|
|
|
|
2014-05-04 17:26:43 +00:00
|
|
|
#must be called to update commands in $PATH
|
|
|
|
hash -r 2>/dev/null
|
|
|
|
|
2014-05-27 18:10:30 +00:00
|
|
|
# allow more open files
|
|
|
|
ulimit -S -n 2048
|
|
|
|
|
2015-11-03 17:44:34 +00:00
|
|
|
function remove_loginscript {
|
2015-11-02 23:28:09 +00:00
|
|
|
if [ $SYSTEM == "Darwin" ]; then
|
|
|
|
launchd_name="com.openmedialibrary.loginscript"
|
|
|
|
launchd_plist="$HOME/Library/LaunchAgents/${launchd_name}.plist"
|
|
|
|
if [ -e "$launchd_plist" ]; then
|
|
|
|
launchctl stop "$launchd_name"
|
|
|
|
launchctl unload "$launchd_plist"
|
|
|
|
rm "$launchd_plist"
|
|
|
|
fi
|
|
|
|
fi
|
2015-11-03 17:44:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" == "start" ]; then
|
|
|
|
remove_loginscript
|
|
|
|
if [ $SYSTEM == "Linux" ]; then
|
2015-11-02 23:28:09 +00:00
|
|
|
if [ -e "$HOME/.config/autostart/openmedialibrary.desktop" ]; then
|
|
|
|
rm "$HOME/.config/autostart/openmedialibrary.desktop"
|
|
|
|
fi
|
|
|
|
fi
|
2014-05-20 10:30:53 +00:00
|
|
|
cd "$BASE/$NAME"
|
2014-05-04 17:26:43 +00:00
|
|
|
if [ -e $PID ]; then
|
2015-03-14 12:36:45 +00:00
|
|
|
if ps -p `cat "$PID"` > /dev/null; then
|
|
|
|
echo openmedialibrary already running
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-05-04 17:26:43 +00:00
|
|
|
fi
|
2014-08-07 09:46:23 +00:00
|
|
|
if [ ! -d "$BASE/$NAME/.git" ]; then
|
2015-11-04 18:53:43 +00:00
|
|
|
python3.4 oml install_update
|
2014-08-09 14:07:57 +00:00
|
|
|
cd "$BASE/$NAME"
|
2014-08-07 09:46:23 +00:00
|
|
|
fi
|
2015-11-04 18:53:43 +00:00
|
|
|
exec python3.4 oml server $PID
|
2014-05-04 17:26:43 +00:00
|
|
|
fi
|
|
|
|
if [ "$1" == "debug" ]; then
|
2014-05-20 10:30:53 +00:00
|
|
|
cd "$BASE/$NAME"
|
2014-05-04 17:26:43 +00:00
|
|
|
if [ -e $PID ]; then
|
|
|
|
echo openmedialibrary already running
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
shift
|
2015-11-04 18:53:43 +00:00
|
|
|
exec python3.4 oml server $@
|
2014-05-04 17:26:43 +00:00
|
|
|
fi
|
|
|
|
if [ "$1" == "stop" ]; then
|
2015-11-03 17:44:34 +00:00
|
|
|
remove_loginscript
|
2014-05-04 17:26:43 +00:00
|
|
|
test -e $PID && kill `cat $PID`
|
|
|
|
test -e $PID && rm $PID
|
|
|
|
exit $?
|
|
|
|
fi
|
|
|
|
if [ "$1" == "restart" ]; then
|
|
|
|
if [ -e $PID ]; then
|
2014-05-20 10:30:53 +00:00
|
|
|
"$0" stop
|
|
|
|
"$0" start
|
2014-05-04 17:26:43 +00:00
|
|
|
exit $?
|
|
|
|
else
|
2014-08-22 16:42:08 +00:00
|
|
|
"$0" start
|
|
|
|
exit $?
|
2014-05-04 17:26:43 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ "$1" == "open" ]; then
|
|
|
|
if [ $SYSTEM == "Darwin" ]; then
|
2015-11-03 11:13:27 +00:00
|
|
|
open "/Applications/Open Media Library.app"
|
|
|
|
fi
|
2015-11-03 17:44:34 +00:00
|
|
|
if [ $SYSTEM == "Linux" ]; then
|
2015-11-04 18:53:43 +00:00
|
|
|
exec python3.4 "$NAME/oml/gtkwebkit.py" $@
|
2014-05-04 17:26:43 +00:00
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
2014-05-16 15:48:48 +00:00
|
|
|
if [ "$1" == "ui" ]; then
|
|
|
|
shift
|
2015-11-04 18:53:43 +00:00
|
|
|
exec python3.4 "$NAME/oml/ui.py" $@
|
2014-05-16 15:48:48 +00:00
|
|
|
fi
|
2014-05-17 11:40:51 +00:00
|
|
|
if [ "$1" == "update" ]; then
|
2014-08-05 10:10:42 +00:00
|
|
|
cd "$BASE/$NAME"
|
|
|
|
if [ -d "$BASE/$NAME/.git" ]; then
|
2014-08-05 09:47:16 +00:00
|
|
|
OLD=`"$0" version`
|
|
|
|
cd "$BASE/platform"
|
|
|
|
echo Update platform..
|
|
|
|
git pull
|
|
|
|
echo Update $NAME..
|
|
|
|
cd "$BASE/$NAME"
|
2014-08-07 09:46:23 +00:00
|
|
|
find . -name "*.pyc" -exec rm "{}" \;
|
2014-08-09 20:04:23 +00:00
|
|
|
git pull
|
2014-08-05 16:04:44 +00:00
|
|
|
"$0" update_static > /dev/null
|
2014-08-05 09:47:16 +00:00
|
|
|
NEW=`"$0" version`
|
2014-08-05 16:04:44 +00:00
|
|
|
"$0" postupdate -o $OLD -n $NEW
|
2014-08-05 09:47:16 +00:00
|
|
|
else
|
2015-11-04 18:53:43 +00:00
|
|
|
python3.4 oml update
|
2014-08-05 09:47:16 +00:00
|
|
|
fi
|
2014-08-07 09:46:23 +00:00
|
|
|
exit $?
|
2014-05-17 11:40:51 +00:00
|
|
|
fi
|
2014-05-19 20:14:24 +00:00
|
|
|
if [ "$1" == "python" ]; then
|
2014-05-20 10:30:53 +00:00
|
|
|
cd "$BASE/$NAME"
|
2014-05-19 20:14:24 +00:00
|
|
|
shift
|
2015-11-04 18:53:43 +00:00
|
|
|
exec python3.4 $@
|
2014-05-19 20:14:24 +00:00
|
|
|
fi
|
2014-05-04 17:26:43 +00:00
|
|
|
|
2014-05-20 10:30:53 +00:00
|
|
|
cd "$BASE/$NAME"
|
2015-11-04 18:53:43 +00:00
|
|
|
exec python3.4 oml $@
|