Fix script mode and add safety check

This commit is contained in:
Emmanuel Viennet 2021-07-30 18:34:47 +03:00
parent c0f5292db8
commit fc59018688
2 changed files with 17 additions and 5 deletions

View File

@ -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"

0
tools/create_users_database.sh Normal file → Executable file
View File