1
0
forked from ScoDoc/ScoDoc
ScoDoc/tools/create_database.sh

27 lines
639 B
Bash
Raw Normal View History

2020-09-26 16:19:37 +02:00
#!/bin/bash
# Create database for ScoDoc
# This script must be executed as user "scodoc"
2020-09-26 16:19:37 +02:00
2021-07-30 17:34:47 +02:00
die() {
echo
echo "Erreur: $1"
echo
exit 1
}
[ $# = 1 ] || die "Usage $0 db_name"
db_name="$1"
2020-09-26 16:19:37 +02:00
# Le répertoire de ce script:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2021-07-30 17:34:47 +02:00
source "$SCRIPT_DIR"/config.sh || die "config.sh not found, exiting"
source "$SCRIPT_DIR"/utils.sh || die "config.sh not found, exiting"
[ "$USER" = "$SCODOC_USER" ] || die "$0 must run as user $SCODOC_USER"
2021-07-27 13:27:21 +02:00
# ---
2021-07-30 17:34:47 +02:00
echo 'Creating postgresql database ' "$db_name"
createdb -E UTF-8 -p "$POSTGRES_PORT" -O "$POSTGRES_USER" "$db_name"
2020-09-26 16:19:37 +02:00