split platform

This commit is contained in:
j 2016-02-06 16:07:08 +05:30
commit ca62bd051f
3 changed files with 43 additions and 27 deletions

60
ctl
View file

@ -33,15 +33,25 @@ if [ ! -e "$PID" ]; then
PID="$DATA/$NAME.pid"
fi
PLATFORM_PYTHON=3.4
SHARED_PYTHON=3.4
if [ -e "$BASE/local_platform" ]; then
export PLATFORM_ENV="$BASE/local_platform"
else
if [ $SYSTEM == "Linux" ]; then
export PLATFORM_ENV="$BASE/platform/${SYSTEM}_${PLATFORM}"
else
export PLATFORM_ENV="$BASE/platform/$SYSTEM"
fi
if [ $SYSTEM == "Linux" ]; then
if [ $PLATFORM == "x86_64" ]; then
ARCH=64
else
ARCH=32
fi
PLATFORM="linux$ARCH"
fi
if [ $SYSTEM == "Darwin" ]; then
PLATFORM="darwin64"
PLATFORM_PY=3.5
fi
fi
export PLATFORM_ENV="$BASE/platform_${PLATFORM}"
PATH="$PLATFORM_ENV/bin:$PATH"
SHARED_ENV="$BASE/platform/Shared"
@ -56,7 +66,9 @@ if [ $SYSTEM == "Darwin" ]; then
export SSL_CERT_DIR="$SHARED_ENV/etc/openssl/certs"
fi
PYTHONPATH="$PLATFORM_ENV/lib/python3.4/site-packages:$SHARED_ENV/lib/python3.4/site-packages:$BASE/$NAME"
PYTHONPATH="${PLATFORM_ENV}/lib/python${PLATFORM_PYTHON}/site-packages"
PYTHONPATH="${PYTHONPATH}:${SHARED_ENV}/lib/python${SHARED_PYTHON}/site-packages"
PYTHONPATH="${PYTHONPATH}:${BASE}/${NAME}"
export PYTHONPATH
oxCACHE="$DATA/ox"
@ -68,25 +80,7 @@ hash -r 2>/dev/null
# allow more open files
ulimit -S -n 2048
function remove_autostart {
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
if [ $SYSTEM == "Linux" ]; then
if [ -e "$HOME/.config/autostart/openmedialibrary.desktop" ]; then
rm "$HOME/.config/autostart/openmedialibrary.desktop"
fi
fi
}
if [ "$1" == "start" ]; then
remove_autostart
cd "$BASE/$NAME"
if [ -e "$PID" ]; then
if ps -p `cat "$PID"` > /dev/null; then
@ -110,7 +104,6 @@ if [ "$1" == "debug" ]; then
exit $?
fi
if [ "$1" == "stop" ]; then
remove_autostart
if [ -e "$PID" ]; then
_PID=`cat "$PID"`
kill $_PID
@ -147,7 +140,7 @@ if [ "$1" == "open" ]; then
if ps -p `cat "$PID"` > /dev/null; then
xdg-open "file://${BASE}/openmedialibrary/static/html/load.html"
else
python3 "$NAME/oml/gtkstatus.py" $@
python3 "${NAME}/oml/gtkstatus.py" $@
exit $?
fi
else
@ -162,11 +155,26 @@ if [ "$1" == "ui" ]; then
python3 "$NAME/oml/ui.py" $@
exit $?
fi
if [ "$1" == "init" ]; then
if [ ! -e "${BASE}/platform" ]; then
git clone https://git.0x2620.org/openmedialibrary_platform.git "${BASE}/platform"
fi
if [ ! -e "${PLATFORM_ENV}" ]; then
git clone https://git.0x2620.org/openmedialibrary_platform_${PLATFORM}.git "${PLATFORM_ENV}"
fi
exit
fi
if [ "$1" == "update" ]; then
cd "$BASE/$NAME"
if [ -d "$BASE/$NAME/.git" ]; then
OLD=`"$0" version`
cd "$BASE/platform"
echo Update shared platform...
git pull
if [ ! -e "${PLATFORM_ENV}" ]; then
git clone https://git.0x2620.org/openmedialibrary_platform_${PLATFORM}.git "${PLATFORM_ENV}"
fi
cd "${PLATFORM_ENV}"
echo Update platform...
git pull
echo Update $NAME...