2020-09-26 16:19:37 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# ScoDoc: suppression d'un departement
|
|
|
|
|
#
|
|
|
|
|
# Ce script supprime la base de donnees ScoDoc d'un departement
|
|
|
|
|
# *** le departement doit au prealable avoir <20>t<EFBFBD> supprime via l'interface web ! ***
|
|
|
|
|
#
|
|
|
|
|
# Ne fonctionne que pour les configurations "standards" (dbname=xxx)
|
|
|
|
|
#
|
|
|
|
|
# Il doit <20>tre lanc<6E> par l'utilisateur unix root dans le repertoire .../config
|
|
|
|
|
# ^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
# E. Viennet, Sept 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
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "Ce script supprime la base de donnees ScoDoc d'un departement"
|
|
|
|
|
echo
|
|
|
|
|
echo "Attention: le departement doit au prealable avoir ete supprime via l'interface web !"
|
|
|
|
|
echo "faites le AVANT d'executer ce script !!!"
|
|
|
|
|
echo
|
|
|
|
|
echo -n "Nom du departement a supprimer (un mot sans ponctuation, exemple \"Info\"): "
|
2020-12-19 19:22:22 +01:00
|
|
|
|
read -r DEPT
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
|
if [[ ! "$DEPT" =~ ^[A-Za-z0-9]+$ ]]
|
|
|
|
|
then
|
|
|
|
|
echo "Nom de departement invalide !"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
export DEPT
|
|
|
|
|
|
|
|
|
|
cfg_pathname="${SCODOC_VAR_DIR}/config/depts/$DEPT".cfg
|
|
|
|
|
|
2020-12-19 19:22:22 +01:00
|
|
|
|
if [ -e "$cfg_pathname" ]
|
2020-09-26 16:19:37 +02:00
|
|
|
|
then
|
|
|
|
|
# arret de ScoDoc
|
2020-12-05 17:29:26 +01:00
|
|
|
|
scodocctl stop
|
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
|
# suppression de la base postgres
|
2020-12-19 19:22:22 +01:00
|
|
|
|
db_name=$(sed '/^dbname=*/!d; s///;q' < "$cfg_pathname")
|
2020-09-26 16:19:37 +02:00
|
|
|
|
echo "suppression de la base postgres $db_name"
|
2020-12-19 19:22:22 +01:00
|
|
|
|
su -c "dropdb $db_name" "$POSTGRES_SUPERUSER" || terminate "ne peux supprimer base de donnees $db_name"
|
2020-09-26 16:19:37 +02:00
|
|
|
|
# suppression du fichier de config
|
2020-12-19 19:22:22 +01:00
|
|
|
|
/bin/rm -f "$cfg_pathname" || terminate "ne peux supprimer $cfg_pathname"
|
2020-09-26 16:19:37 +02:00
|
|
|
|
# relance ScoDoc
|
|
|
|
|
echo -n "Demarrer le serveur ScoDoc ? (y/n) [n]"
|
2020-12-19 19:22:22 +01:00
|
|
|
|
read -r ans
|
2020-09-26 16:19:37 +02:00
|
|
|
|
if [ "$(norm_ans "$ans")" = 'Y' ]
|
|
|
|
|
then
|
2020-12-05 17:29:26 +01:00
|
|
|
|
scodocctl start
|
2020-09-26 16:19:37 +02:00
|
|
|
|
fi
|
|
|
|
|
exit 0
|
|
|
|
|
else
|
2020-12-19 19:22:22 +01:00
|
|
|
|
echo 'Erreur: pas de configuration trouvee pour "'"$DEPT"'"'
|
2020-09-26 16:19:37 +02:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|