nexus/start.sh

40 lines
1.8 KiB
Bash
Raw Normal View History

2023-11-14 23:40:27 +01:00
#!/bin/bash
2023-11-15 00:38:53 +01:00
set -euo pipefail
2023-11-14 23:40:27 +01:00
echo "---------------"
echo "Nexus Dashboard"
echo "by Aaron Riedel"
echo "---------------"
2023-11-15 00:38:53 +01:00
echo "performing pre start check"
2023-11-14 23:40:27 +01:00
# check if necessary variables are set
[[ -z "${APP_SECRET_KEY}" ]] && echo "APP_SECRET_KEY not set" && exit 1
[[ -z "${APP_DATABASE_URI}" ]] && echo "APP_DATABASE_URI not set" && exit 1
2023-11-15 00:38:53 +01:00
# check if client is mounted
2023-11-15 13:27:47 +01:00
[ ! -d ~/NexusDashboard/app/luclient ] && echo "LU client not found" && exit 1
[ ! -d ~/NexusDashboard/app/luclient/res ] && echo "LU client is missing res folder" && exit 1
[ ! -d ~/NexusDashboard/app/luclient/locale ] && echo "LU client is missing locale folder" && exit 1
2023-11-15 00:38:53 +01:00
# check if brickdb needs to be unzipped
2023-11-15 13:27:47 +01:00
if [ -f ~/NexusDashboard/app/luclient/res/brickdb.zip ]; then
2023-11-15 00:38:53 +01:00
echo "brickdb.zip found"
unzip ~/NexusDashboard/app/luclient/res/brickdb.zip
rm ~/NexusDashboard/app/luclient/res/brickdb.zip
echo "brickdb.zip unpacked and removed"
fi
2023-11-15 13:59:22 +01:00
echo "check cdclient.sqlite"
2023-11-15 00:38:53 +01:00
# rename ~/NexusDashboard/app/luclient/res/CDServer.sqlite
2023-11-15 13:27:47 +01:00
if [ -f ~/NexusDashboard/app/luclient/res/CDServer.sqlite ]; then
2023-11-15 00:38:53 +01:00
echo "moving CDServer.sqlite to cdclient.sqlite"
mv ~/NexusDashboard/app/luclient/res/CDServer.sqlite ~/NexusDashboard/app/luclient/res/cdclient.sqlite
fi
2023-11-15 13:48:57 +01:00
[ ! -f ~/NexusDashboard/app/luclient/res/cdclient.sqlite ] && echo "cdclient.sqlite not found" && exit 1
2023-11-15 13:59:22 +01:00
echo "check settings_example.py"
if [ ! -f ~/NexusDashboard/app/settings.py ]; then
echo "settings.py not found. Copy settings_example.py to settings.py"
cp ~/NexusDashboard/app/settings_example.py ~/NexusDashboard/app/settings.py
fi
[ -f ~/NexusDashboard/app/settings_example.py ] && rm ~/NexusDashboard/app/settings_example.py && echo "settings_example.py removed"
2023-11-15 13:48:57 +01:00
echo "pre-check done"
2023-11-15 00:38:53 +01:00
cd ~/NexusDashboard
echo "run database migration"
flask db upgrade
echo "start server"
gunicorn -b :8000 -w 4 wsgi:app