From b17d6646522d7b55fa10c5da063047cb340c628c Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 27 Jul 2021 14:27:21 +0300 Subject: [PATCH] Fix install scripts --- VERSION | 2 +- scodoc.py | 4 ++-- tools/create_database.sh | 10 ++++------ tools/utils.sh | 1 + 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index cd1d2e94f..8b22a322d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0.1 +8.0.2 diff --git a/scodoc.py b/scodoc.py index cbe5f715a..2ef00eff7 100755 --- a/scodoc.py +++ b/scodoc.py @@ -136,7 +136,7 @@ def sco_delete_dept(dept): if os.getuid() != 0: sys.stderr.write("sco_delete_dept: must be run by root\n") return 1 - if os.system('cd config; ./delete_dept.sh -n "{}"'.format(dept)): + if os.system('cd tools && ./delete_dept.sh -n "{}"'.format(dept)): sys.stderr.write("error deleting dept " + dept) return 1 return 0 @@ -149,7 +149,7 @@ def sco_create_dept(dept): if os.getuid() != 0: sys.stderr.write("sco_create_dept: must be run by root\n") return 1 - if os.system('cd config; ./create_dept.sh -n "{}"'.format(dept)): + if os.system('cd tools && ./create_dept.sh -n "{}"'.format(dept)): sys.stderr.write("error deleting dept " + dept) return 1 return 0 diff --git a/tools/create_database.sh b/tools/create_database.sh index 9637ac11f..164a4b9fc 100755 --- a/tools/create_database.sh +++ b/tools/create_database.sh @@ -1,22 +1,20 @@ #!/bin/bash # Create database for a ScoDoc instance -# This script must be executed as postgres user +# This script must be executed as root # # $db_name is passed as an environment variable source config.sh source utils.sh -if [ $(id -n -u) != "$POSTGRES_SUPERUSER" ] -then - die "$0 must be run as user $POSTGRES_SUPERUSER" -fi +check_uid_root "$0" # 1--- CREATION UTILISATEUR POSTGRESQL init_postgres_user # 2--- CREATION BASE UTILISATEURS echo 'Creating postgresql database for users:' "$SCODOC_USER_DB" -createdb -E UTF-8 -p "$POSTGRES_PORT" -O "$POSTGRES_USER" "$SCODOC_USER_DB" +su -c "createdb -E UTF-8 -p $POSTGRES_PORT -O $POSTGRES_USER $SCODOC_USER_DB" $POSTGRES_SUPERUSER + diff --git a/tools/utils.sh b/tools/utils.sh index 4cff511a8..53965b493 100644 --- a/tools/utils.sh +++ b/tools/utils.sh @@ -80,6 +80,7 @@ change_scodoc_file_ownership() { # Création du répertoire local (scodoc-data) et vérification du propriétaire set_scodoc_var_dir() { echo "Checking $SCODOC_VAR_DIR..." + [ -d "$SCODOC_VAR_DIR" ] || mkdir "$SCODOC_VAR_DIR" || die "can't create $SCODOC_VAR_DIR directory" for d in archives photos tmp log config config/version config/depts config/logos do [ -d "$SCODOC_VAR_DIR/$d" ] || mkdir "$SCODOC_VAR_DIR/$d" || die "can't create $SCODOC_VAR_DIR/$d subdirectory"