MonScoDocEssai/config/create_user_db.sh

29 lines
862 B
Bash
Raw Normal View History

2020-09-26 16:19:37 +02:00
#!/bin/bash
#
# ScoDoc: creation de la base de donnees d'utilisateurs
#
# Ce script prend en charge la creation de la base de donnees
# et doit être lancé par l'utilisateur unix root dans le repertoire .../config
2020-09-26 16:19:37 +02:00
# ^^^^^^^^^^^^^^^^^^^^^
# E. Viennet, Juin 2008
#
source config.sh
source utils.sh
2020-12-19 19:22:22 +01:00
check_uid_root "$0"
2020-09-26 16:19:37 +02:00
# --- Ensure postgres user www-data exists
init_postgres_user
db_name=SCOUSERS
echo 'Creating postgresql database ' $db_name
2020-12-19 19:22:22 +01:00
su -c "createdb -E UTF-8 -O $POSTGRES_USER -p $POSTGRES_PORT $db_name" "$POSTGRES_SUPERUSER"
2020-09-26 16:19:37 +02:00
2020-12-19 19:22:22 +01:00
echo 'Initializing tables in database ' "$db_name"
echo su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" "$POSTGRES_USER"
su -c "$PSQL -U $POSTGRES_USER -p $POSTGRES_PORT $db_name < $SCODOC_DIR/misc/create_user_table.sql" "$POSTGRES_USER"