mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-24 16:26:04 +02:00
update
This commit is contained in:
@@ -116,4 +116,4 @@ LABEL \
|
|||||||
# 6 Finish line #
|
# 6 Finish line #
|
||||||
#################
|
#################
|
||||||
# S6 will pick up run scripts from /etc/services.d supplied in rootfs
|
# S6 will pick up run scripts from /etc/services.d supplied in rootfs
|
||||||
# and launch: › minio › museum API › (optional) web‑UI
|
# and launch: › minio › museum API › (optional) web‑UI
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
"startup": "services",
|
"startup": "services",
|
||||||
"udev": true,
|
"udev": true,
|
||||||
"url": "https://github.com/alexbelgium/hassio-addons",
|
"url": "https://github.com/alexbelgium/hassio-addons",
|
||||||
"version": "1.0.0test3",
|
"version": "1.0.0test4",
|
||||||
"video": true,
|
"video": true,
|
||||||
"webui": "http://[HOST]:[PORT:3000]"
|
"webui": "http://[HOST]:[PORT:3000]"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ DB_NAME="$(bashio::config 'DB_DATABASE_NAME')"
|
|||||||
until pg_isready -q -h localhost -p 5432 -U postgres; do
|
until pg_isready -q -h localhost -p 5432 -U postgres; do
|
||||||
bashio::log.info "Waiting for Postgres to accept connections…"
|
bashio::log.info "Waiting for Postgres to accept connections…"
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
|
||||||
|
|
||||||
bashio::log.info "Creating role + database if needed…"
|
bashio::log.info "Creating role + database if needed…"
|
||||||
su - postgres -c psql <<SQL
|
su - postgres -c psql <<SQL
|
||||||
@@ -33,3 +32,5 @@ END
|
|||||||
SQL
|
SQL
|
||||||
|
|
||||||
bashio::log.info "Internal Postgres ready."
|
bashio::log.info "Internal Postgres ready."
|
||||||
|
|
||||||
|
done
|
||||||
|
|||||||
@@ -11,14 +11,55 @@ mkdir -p /config/scripts/compose
|
|||||||
|
|
||||||
bashio::log.info "Starting services"
|
bashio::log.info "Starting services"
|
||||||
|
|
||||||
# Loop through each directory in /etc/services.d/
|
################
|
||||||
|
# Run services #
|
||||||
|
################
|
||||||
|
|
||||||
for dir in /etc/services.d/*; do
|
for dir in /etc/services.d/*; do
|
||||||
# Check if the directory contains a 'run' file
|
# Check if the directory contains a 'run' file
|
||||||
if [ -f "$dir/run" ]; then
|
if [ -f "$dir/run" ]; then
|
||||||
# Execute the 'run' file
|
# Execute the 'run' file
|
||||||
echo "Starting service in $dir"
|
bashio::log.info "Starting service $dir"
|
||||||
bash "$dir/run"
|
bash "$dir/run"
|
||||||
else
|
else
|
||||||
echo "No run file found in $dir"
|
bashio::log.fatal "No run file found in $dir"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Internal db bootstrap #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
if bashio::config.true 'USE_EXTERNAL_DB'; then
|
||||||
|
bashio::log.info "External DB in use; skipping internal Postgres bootstrap."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
bashio::log.info "Bootstrapping internal Postgres cluster…"
|
||||||
|
|
||||||
|
DB_USER="$(bashio::config 'DB_USERNAME')"
|
||||||
|
DB_PASS="$(bashio::config 'DB_PASSWORD')"
|
||||||
|
DB_NAME="$(bashio::config 'DB_DATABASE_NAME')"
|
||||||
|
|
||||||
|
# Wait for postgres service (localhost)
|
||||||
|
until pg_isready -q -h localhost -p 5432 -U postgres; do
|
||||||
|
bashio::log.info "Waiting for Postgres to accept connections…"
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
bashio::log.info "Creating role + database if needed…"
|
||||||
|
su - postgres -c psql <<SQL
|
||||||
|
DO \$\$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '${DB_USER}') THEN
|
||||||
|
CREATE ROLE ${DB_USER} LOGIN PASSWORD '${DB_PASS}';
|
||||||
|
END IF;
|
||||||
|
IF NOT EXISTS (SELECT FROM pg_database WHERE datname = '${DB_NAME}') THEN
|
||||||
|
CREATE DATABASE ${DB_NAME} OWNER ${DB_USER};
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
\$\$;
|
||||||
|
SQL
|
||||||
|
|
||||||
|
bashio::log.info "Internal Postgres ready."
|
||||||
|
|
||||||
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user