2013-02-21 06:55:49 +00:00
|
|
|
#!/bin/sh
|
2015-04-28 17:35:15 +00:00
|
|
|
SERVICES="pandora pandora-tasks pandora-encoding pandora-cron pandora-websocketd"
|
2013-04-21 15:59:18 +00:00
|
|
|
if [ -z "$1" ]; then
|
2013-04-28 02:24:19 +00:00
|
|
|
echo "Usage: $0 (start|stop|restart|reload)"
|
|
|
|
exit 1
|
2013-04-21 15:59:18 +00:00
|
|
|
else
|
|
|
|
action="$1"
|
|
|
|
fi
|
2016-02-20 07:49:06 +00:00
|
|
|
if [ "$action" = "init" ]; then
|
|
|
|
cd "`dirname "$0"`"
|
|
|
|
BASE=`pwd`
|
2017-11-02 21:08:17 +00:00
|
|
|
python3 -m venv --system-site-packages .
|
2017-11-07 18:44:47 +00:00
|
|
|
|
|
|
|
# Work around broken venv module in Ubuntu 16.04 / Debian 9
|
|
|
|
if [ ! -e bin/pip ]; then
|
|
|
|
bin/python3 -m pip install -U pip
|
|
|
|
fi
|
2016-02-20 07:49:06 +00:00
|
|
|
if [ ! -d static/oxjs ]; then
|
|
|
|
git clone --depth 1 https://git.0x2620.org/oxjs.git static/oxjs
|
|
|
|
fi
|
|
|
|
mkdir -p src
|
|
|
|
if [ ! -d src/oxtimelines ]; then
|
|
|
|
git clone --depth 1 https://git.0x2620.org/oxtimelines.git src/oxtimelines
|
|
|
|
fi
|
|
|
|
for package in oxtimelines python-ox; do
|
|
|
|
cd ${BASE}
|
|
|
|
if [ ! -d src/${package} ]; then
|
|
|
|
git clone --depth 1 https://git.0x2620.org/${package}.git src/${package}
|
|
|
|
fi
|
|
|
|
cd ${BASE}/src/${package}
|
|
|
|
${BASE}/bin/python setup.py develop
|
|
|
|
done
|
|
|
|
cd ${BASE}
|
|
|
|
./bin/pip install -r requirements.txt
|
2016-03-07 08:55:24 +00:00
|
|
|
if [ ! -e pandora/gunicorn_config.py ]; then
|
|
|
|
cp pandora/gunicorn_config.py.in pandora/gunicorn_config.py
|
|
|
|
fi
|
2016-02-20 07:49:06 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
2013-04-28 02:24:19 +00:00
|
|
|
if [ `whoami` != 'root' ]; then
|
|
|
|
echo you have to be root or run $0 with sudo
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-01-19 17:40:32 +00:00
|
|
|
if [ "$action" = "install" ]; then
|
|
|
|
cd "`dirname "$0"`"
|
|
|
|
BASE=`pwd`
|
|
|
|
if [ -x /bin/systemctl ]; then
|
2016-06-09 10:38:13 +00:00
|
|
|
if [ -d /etc/systemd/system/ ]; then
|
2016-06-13 09:28:57 +00:00
|
|
|
for service in $SERVICES; do
|
|
|
|
if [ -e /lib/systemd/system/${service}.service ]; then
|
|
|
|
rm -f /lib/systemd/system/${service}.service \
|
|
|
|
/etc/systemd/system/multi-user.target.wants/${service}.service
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2016-06-09 10:50:34 +00:00
|
|
|
cp $BASE/etc/systemd/system/*.service /etc/systemd/system/
|
2016-06-09 10:38:13 +00:00
|
|
|
cp $BASE/etc/tmpfiles.d/pandora.conf /etc/tmpfiles.d/
|
|
|
|
systemd-tmpfiles --create /etc/tmpfiles.d/pandora.conf >/dev/null || true
|
2016-03-07 08:55:24 +00:00
|
|
|
systemctl daemon-reload
|
2015-04-28 17:35:15 +00:00
|
|
|
for service in $SERVICES; do
|
2015-01-19 17:40:32 +00:00
|
|
|
systemctl enable ${service}.service
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -d /etc/init ]; then
|
|
|
|
cp $BASE/etc/init/* /etc/init/
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
2015-04-28 17:35:15 +00:00
|
|
|
for service in $SERVICES; do
|
2013-04-21 15:59:18 +00:00
|
|
|
service $service $action
|
2013-02-21 06:55:49 +00:00
|
|
|
done
|