File size: 1,178 Bytes
3866bf7 11ff439 3866bf7 11ff439 3866bf7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/bin/sh
set -eu
fix_sqlite_permissions() {
db_url="${DATABASE_URL:-file:/data/db.sqlite}"
case "$db_url" in
file:*)
db_path="${db_url#file:}"
db_path="${db_path%%\?*}"
db_path="${db_path%%\#*}"
if [ -z "$db_path" ]; then
db_path="/data/db.sqlite"
fi
case "$db_path" in
/*) ;;
*) db_path="/app/$db_path" ;;
esac
db_dir=$(dirname "$db_path")
mkdir -p "$db_dir"
if [ "$(id -u)" -eq 0 ]; then
chown -R appuser:appgroup "$db_dir"
chmod 775 "$db_dir" || true
if [ -e "$db_path" ]; then
chown appuser:appgroup "$db_path"
chmod 664 "$db_path" || true
fi
if [ -e "${db_path}-wal" ]; then
chown appuser:appgroup "${db_path}-wal"
chmod 664 "${db_path}-wal" || true
fi
if [ -e "${db_path}-shm" ]; then
chown appuser:appgroup "${db_path}-shm"
chmod 664 "${db_path}-shm" || true
fi
fi
;;
esac
}
if [ "$#" -eq 0 ]; then
set -- node scripts/start.js
fi
fix_sqlite_permissions
if [ "$(id -u)" -eq 0 ]; then
exec su-exec appuser "$@"
fi
exec "$@"
|