fix: working init
This commit is contained in:
parent
b29fd50985
commit
7633896a45
12
compose.yml
12
compose.yml
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue