diff --git a/tools/create_database.sh b/tools/create_database.sh index ee90346b63..fe1ff40329 100755 --- a/tools/create_database.sh +++ b/tools/create_database.sh @@ -5,12 +5,24 @@ # # $db_name is passed as an environment variable -source config.sh -source utils.sh +die() { + echo + echo "Erreur: $1" + echo + exit 1 +} -echo 'Creating postgresql database' +source config.sh || die "config.sh not found, exiting" +source utils.sh || die "config.sh not found, exiting" + +if [ "$db_name" == "" ] +then + echo "Error: env var db_name unset" + echo "(ce script ne doit pas ĂȘtre lancĂ© directement !)" + exit 1 +fi # --- -echo 'Creating postgresql database ' $db_name -createdb -E UTF-8 -p $POSTGRES_PORT -O $POSTGRES_USER $db_name +echo 'Creating postgresql database ' "$db_name" +createdb -E UTF-8 -p "$POSTGRES_PORT" -O "$POSTGRES_USER" "$db_name" diff --git a/tools/create_users_database.sh b/tools/create_users_database.sh old mode 100644 new mode 100755