diff --git a/wger/rootfs/run.sh b/wger/rootfs/run.sh index 11ea87383..885b3fc4a 100644 --- a/wger/rootfs/run.sh +++ b/wger/rootfs/run.sh @@ -6,13 +6,21 @@ sed -i "s|/usr/bin/with-contenv|/usr/bin/env|g" /etc/cont-init.d/* LOCATION=/data mkdir -p "$LOCATION" -touch "$LOCATION"/database.sqlite || true -chown -R wger "$LOCATION" || true -chmod -R 777 "$LOCATION" || true + +if [ ! -f "$LOCATION"/database.sqlite ]; then + if [ -f "/home/wger/db/database.sqlite" ]; then + cp /home/wger/db/database.sqlite "$LOCATION"/database.sqlite + else + touch "$LOCATION"/database.sqlite + fi +fi + +chown -R wger "$LOCATION" +chmod -R 777 "$LOCATION" rm /home/wger/db/database.sqlite &>/dev/null || true ln -s "$LOCATION"/database.sqlite /home/wger/db python3 manage.py migrate || true echo "Launch app" -su -m -l wger -c "cd /home/wger/src && export FROM_EMAIL='wger Workout Manager ' && exec /home/wger/entrypoint.sh" +su -l wger -c "cd /home/wger/src && export FROM_EMAIL='wger Workout Manager ' && exec /home/wger/entrypoint.sh"