ScoDoc/tools/create_database.sh

29 lines
597 B
Bash
Executable File

#!/bin/bash
# Create database for a ScoDoc departement
# This script must be executed as postgres super user
#
# $db_name is passed as an environment variable
die() {
echo
echo "Erreur: $1"
echo
exit 1
}
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"