1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/immich_ynh.git synced 2024-09-03 20:36:24 +02:00

Redefine postgresql_version as a function because helpers don't exist yet at _common.sh sourcing time

This commit is contained in:
Salamandar 2024-04-01 00:17:55 +02:00
parent 5922713a29
commit a4202015cc
2 changed files with 9 additions and 9 deletions

View file

@ -7,12 +7,6 @@
# NodeJS required version # NodeJS required version
nodejs_version=20 nodejs_version=20
# PostgreSQL required version
postgresql_version=$(
ynh_read_manifest --manifest_key="resources.apt.extras.postgresql.packages" \
| grep -o 'postgresql-[0-9][0-9]-pgvector' | head -n1 | cut -d'-' -f2
)
# Fail2ban # Fail2ban
failregex="immich-server.*Failed login attempt for user.+from ip address\s?<ADDR>" failregex="immich-server.*Failed login attempt for user.+from ip address\s?<ADDR>"
@ -20,6 +14,12 @@ failregex="immich-server.*Failed login attempt for user.+from ip address\s?<ADDR
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
# PostgreSQL required version
postgresql_version() {
ynh_read_manifest --manifest_key="resources.apt.extras.postgresql.packages" \
| grep -o 'postgresql-[0-9][0-9]-pgvector' | head -n1 | cut -d'-' -f2
}
# Retrieve full latest python version from major version # Retrieve full latest python version from major version
# usage: py_latest_from_major --python="3.8" # usage: py_latest_from_major --python="3.8"
# | arg: -p, --python= - the major python version # | arg: -p, --python= - the major python version
@ -230,7 +230,7 @@ myynh_execute_psql_as_root() {
fi fi
sudo --login --user=postgres PGUSER=postgres PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" \ sudo --login --user=postgres PGUSER=postgres PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" \
psql --cluster="$postgresql_version/main" "$database" --command="$sql" psql --cluster="$(postgresql_version)/main" "$database" --command="$sql"
} }
# Install the database # Install the database
@ -264,7 +264,7 @@ myynh_restore_psql_db() {
--replace_string="SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);" --target_file="db.sql" --replace_string="SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);" --target_file="db.sql"
sudo --login --user=postgres PGUSER=postgres PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" \ sudo --login --user=postgres PGUSER=postgres PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" \
psql --cluster="$postgresql_version/main" --dbname="$app" < ./db.sql psql --cluster="$(postgresql_version)/main" --dbname="$app" < ./db.sql
} }
#================================================= #=================================================

View file

@ -41,7 +41,7 @@ db_pwd=$(ynh_string_random)
myynh_create_psql_db myynh_create_psql_db
db_port=$(myynh_execute_psql_as_root --sql="\conninfo" | cut -d'"' -f8) db_port=$(myynh_execute_psql_as_root --sql="\conninfo" | cut -d'"' -f8)
ynh_app_setting_set --app="$app" --key=psql_pwd --value="$db_pwd" ynh_app_setting_set --app="$app" --key=psql_pwd --value="$db_pwd"
ynh_app_setting_set --app="$app" --key=psql_version --value="$postgresql_version" ynh_app_setting_set --app="$app" --key=psql_version --value="$(postgresql_version)"
ynh_app_setting_set --app="$app" --key=psql_port --value="$db_port" ynh_app_setting_set --app="$app" --key=psql_port --value="$db_port"
#================================================= #=================================================