mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-09-26 19:33:59 +02:00
update
This commit is contained in:
@@ -105,7 +105,6 @@
|
|||||||
"cifspassword": "str?",
|
"cifspassword": "str?",
|
||||||
"cifsusername": "str?",
|
"cifsusername": "str?",
|
||||||
"data_location": "str",
|
"data_location": "str",
|
||||||
"database": "list(internal|external_postgresql)?",
|
|
||||||
"localdisks": "str?",
|
"localdisks": "str?",
|
||||||
"networkdisks": "str?"
|
"networkdisks": "str?"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,6 +2,20 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# shellcheck disable=SC2155,SC2016
|
# shellcheck disable=SC2155,SC2016
|
||||||
|
|
||||||
|
######################
|
||||||
|
# Switch of database #
|
||||||
|
######################
|
||||||
|
|
||||||
|
if [ -f /share/postgresql_immich.tar.gz ]; then
|
||||||
|
bashio::log.warning "Your previous database was exported to /share/postgresql_immich.tar.gz"
|
||||||
|
elif [ -d /data/postgresql ]; then
|
||||||
|
bashio::log.warning "------------------------------------"
|
||||||
|
bashio::log.warning "Internal postgres database detected, copying to /share/postgresql_immich.tar.gz"
|
||||||
|
bashio::log.warning "------------------------------------"
|
||||||
|
tar -zcvf /share/postgresql_immich.tar.gz /data/postgresql
|
||||||
|
rm -r /data/postgresql
|
||||||
|
fi
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Define database #
|
# Define database #
|
||||||
###################
|
###################
|
||||||
@@ -9,11 +23,7 @@
|
|||||||
bashio::log.info "Defining database"
|
bashio::log.info "Defining database"
|
||||||
bashio::log.info "-----------------"
|
bashio::log.info "-----------------"
|
||||||
|
|
||||||
case $(bashio::config 'database') in
|
bashio::log.info "Connecting to external postgresql"
|
||||||
|
|
||||||
"external_postgresql")
|
|
||||||
|
|
||||||
bashio::log.info "Using external postgresql"
|
|
||||||
bashio::log.info ""
|
bashio::log.info ""
|
||||||
|
|
||||||
# Check if values exist
|
# Check if values exist
|
||||||
@@ -22,8 +32,7 @@ case $(bashio::config 'database') in
|
|||||||
! bashio::config.has_value 'DB_PASSWORD' && \
|
! bashio::config.has_value 'DB_PASSWORD' && \
|
||||||
! bashio::config.has_value 'DB_DATABASE_NAME' && \
|
! bashio::config.has_value 'DB_DATABASE_NAME' && \
|
||||||
! bashio::config.has_value 'JWT_SECRET' && \
|
! bashio::config.has_value 'JWT_SECRET' && \
|
||||||
! bashio::config.has_value 'DB_PORT'
|
! bashio::config.has_value 'DB_PORT'; then
|
||||||
then
|
|
||||||
! bashio::exit.nok "Please make sure that the following options are set : DB_USERNAME, DB_HOSTNAME, DB_PASSWORD, DB_DATABASE_NAME, DB_PORT"
|
! bashio::exit.nok "Please make sure that the following options are set : DB_USERNAME, DB_HOSTNAME, DB_PASSWORD, DB_DATABASE_NAME, DB_PORT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -34,23 +43,6 @@ case $(bashio::config 'database') in
|
|||||||
export DB_DATABASE_NAME=$(bashio::config 'DB_DATABASE_NAME')
|
export DB_DATABASE_NAME=$(bashio::config 'DB_DATABASE_NAME')
|
||||||
export DB_PORT=$(bashio::config 'DB_PORT')
|
export DB_PORT=$(bashio::config 'DB_PORT')
|
||||||
export JWT_SECRET=$(bashio::config 'JWT_SECRET')
|
export JWT_SECRET=$(bashio::config 'JWT_SECRET')
|
||||||
;;
|
|
||||||
|
|
||||||
**)
|
|
||||||
|
|
||||||
bashio::log.info "Using internal postgresql"
|
|
||||||
bashio::log.info ""
|
|
||||||
|
|
||||||
# Settings files & permissions
|
|
||||||
ln -s /usr/lib/postgresql/14/bin/postgres /usr/bin || true
|
|
||||||
ln -s /usr/lib/postgresql/14/bin/psql /usr/psql || true
|
|
||||||
mkdir -p /data/postgresql
|
|
||||||
cp -rnf /var/lib/postgresql/14/main/* /data/postgresql/
|
|
||||||
chown -R postgres /data/postgresql
|
|
||||||
chmod -R 700 /data/postgresql
|
|
||||||
|
|
||||||
# Start postgresql
|
|
||||||
/etc/init.d/postgresql start
|
|
||||||
|
|
||||||
# Create database
|
# Create database
|
||||||
echo "CREATE ROLE root WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'securepassword';
|
echo "CREATE ROLE root WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'securepassword';
|
||||||
@@ -62,17 +54,6 @@ case $(bashio::config 'database') in
|
|||||||
sudo -iu postgres psql < setup_postgres.sql
|
sudo -iu postgres psql < setup_postgres.sql
|
||||||
rm setup_postgres.sql
|
rm setup_postgres.sql
|
||||||
|
|
||||||
# Settings parameters
|
|
||||||
export DB_USERNAME=immich
|
|
||||||
export DB_HOSTNAME=localhost
|
|
||||||
export DB_PASSWORD=immich
|
|
||||||
export DB_DATABASE_NAME=immich
|
|
||||||
export DB_PORT=5432
|
|
||||||
export JWT_SECRET=$(bashio::config 'JWT_SECRET')
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Export variables
|
# Export variables
|
||||||
if [ -d /var/run/s6/container_environment ]; then
|
if [ -d /var/run/s6/container_environment ]; then
|
||||||
printf "%s" "$DB_USERNAME" > /var/run/s6/container_environment/DB_USERNAME
|
printf "%s" "$DB_USERNAME" > /var/run/s6/container_environment/DB_USERNAME
|
||||||
|
|||||||
Reference in New Issue
Block a user