fix: working init

This commit is contained in:
decentral1se 2021-11-30 13:36:17 +01:00
parent b29fd50985
commit 7633896a45
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
3 changed files with 46 additions and 0 deletions

1
abra.sh Normal file
View File

@ -0,0 +1 @@
export APP_ENTRYPOINT_VERSION=v1

View File

@ -11,9 +11,14 @@ services:
- PUID=1000
- TZ
volumes:
- config:/config
- books:/books
networks:
- proxy
configs:
- source: app_entrypoint
target: /config/custom-cont-init.d/entrypoint.sh
mode: 0555
deploy:
restart_policy:
condition: on-failure
@ -36,3 +41,10 @@ networks:
volumes:
books:
config:
configs:
app_entrypoint:
name: ${STACK_NAME}_app_entrypoint_${APP_ENTRYPOINT_VERSION}
file: entrypoint.sh.tmpl
template_driver: golang

33
entrypoint.sh.tmpl Normal file
View File

@ -0,0 +1,33 @@
#!/bin/bash
set -e
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
if [ ! -f "/books/metadata.db" ]; then
/usr/bin/mkdir -p /books
/usr/bin/calibredb restore_database --really-do-it --with-library /books
/usr/bin/chown abc:abc /books/metadata.db
else
echo "/books/metadata.db exists, not creating another one"
fi