mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-01 05:14:04 +02:00
Revert 'delete' [nobuild]
This commit is contained in:
77
ente/rootfs/etc/cont-init.d/10-generate-config.sh
Executable file
77
ente/rootfs/etc/cont-init.d/10-generate-config.sh
Executable file
@@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
# Generate museum.yaml (first boot) from add-on options
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
CFG=/config/museum.yaml
|
||||||
|
|
||||||
|
if bashio::fs.file_exists "$CFG"; then
|
||||||
|
bashio::log.info "Using existing $CFG"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
bashio::log.info "Generating $CFG"
|
||||||
|
|
||||||
|
# --- options ---
|
||||||
|
USE_EXTERNAL_DB=$(bashio::config.true 'USE_EXTERNAL_DB' && echo true || echo false)
|
||||||
|
|
||||||
|
DB_HOST="localhost"
|
||||||
|
DB_PORT=5432
|
||||||
|
DB_USER="$(bashio::config 'DB_USERNAME')"
|
||||||
|
DB_PASS="$(bashio::config 'DB_PASSWORD')"
|
||||||
|
DB_NAME="$(bashio::config 'DB_DATABASE_NAME')"
|
||||||
|
|
||||||
|
if ${USE_EXTERNAL_DB}; then
|
||||||
|
# override host/port for external DB (fall back if missing)
|
||||||
|
DB_HOST="$(bashio::config 'DB_HOSTNAME')"
|
||||||
|
DB_PORT="$(bashio::config 'DB_PORT')"
|
||||||
|
bashio::log.info "museum.yaml will point to external Postgres at ${DB_HOST}:${DB_PORT}"
|
||||||
|
else
|
||||||
|
bashio::log.info "museum.yaml will use internal Postgres."
|
||||||
|
fi
|
||||||
|
|
||||||
|
MINIO_USER="$(bashio::config 'MINIO_ROOT_USER')"
|
||||||
|
MINIO_PASS="$(bashio::config 'MINIO_ROOT_PASSWORD')"
|
||||||
|
|
||||||
|
# helpers
|
||||||
|
_random_b64() { head -c "$1" /dev/urandom | base64 | tr -d '\n'; }
|
||||||
|
_random_b64_url() { head -c "$1" /dev/urandom | base64 | tr '+/' '-_' | tr -d '\n'; }
|
||||||
|
|
||||||
|
cat >"$CFG" <<EOF
|
||||||
|
key:
|
||||||
|
encryption: $(_random_b64 32)
|
||||||
|
hash: $(_random_b64 64)
|
||||||
|
|
||||||
|
jwt:
|
||||||
|
secret: $(_random_b64_url 32)
|
||||||
|
|
||||||
|
db:
|
||||||
|
host: ${DB_HOST}
|
||||||
|
port: ${DB_PORT}
|
||||||
|
name: ${DB_NAME}
|
||||||
|
user: ${DB_USER}
|
||||||
|
password: ${DB_PASS}
|
||||||
|
|
||||||
|
s3:
|
||||||
|
are_local_buckets: true
|
||||||
|
b2-eu-cen:
|
||||||
|
key: $MINIO_USER
|
||||||
|
secret: $MINIO_PASS
|
||||||
|
endpoint: localhost:3200
|
||||||
|
region: eu-central-2
|
||||||
|
bucket: b2-eu-cen
|
||||||
|
wasabi-eu-central-2-v3:
|
||||||
|
key: $MINIO_USER
|
||||||
|
secret: $MINIO_PASS
|
||||||
|
endpoint: localhost:3200
|
||||||
|
region: eu-central-2
|
||||||
|
bucket: wasabi-eu-central-2-v3
|
||||||
|
compliance: false
|
||||||
|
scw-eu-fr-v3:
|
||||||
|
key: $MINIO_USER
|
||||||
|
secret: $MINIO_PASS
|
||||||
|
endpoint: localhost:3200
|
||||||
|
region: eu-central-2
|
||||||
|
bucket: scw-eu-fr-v3
|
||||||
|
EOF
|
||||||
|
|
||||||
|
bashio::log.info "Generated $CFG"
|
||||||
Reference in New Issue
Block a user