1
0
forked from ScoDoc/ScoDoc

Merge branch 'ScoDoc8' of https://scodoc.org/git/viennet/ScoDoc into onedb

.
This commit is contained in:
Emmanuel Viennet 2021-08-09 17:02:10 +02:00
commit 2f9c784566
4 changed files with 15 additions and 25 deletions

View File

@ -168,7 +168,7 @@ de votre installation ScoDoc 7 pour passer à ScoDoc 8 (*ne pas utiliser en prod
## Création d'un département ## Création d'un département
sudo su su scodoc # si besoin
cd /opt/scodoc cd /opt/scodoc
source venv/bin/activate source venv/bin/activate
flask sco-create-dept DEPT flask sco-create-dept DEPT
@ -177,7 +177,7 @@ où `DEPT` est le nom du département (un acronyme en majuscule, comme "RT", "GE
### Suppression d'un département ### Suppression d'un département
sudo su su scodoc # si besoin
cd /opt/scodoc cd /opt/scodoc
source venv/bin/activate source venv/bin/activate
flask sco-delete-dept DEPT flask sco-delete-dept DEPT

View File

@ -165,10 +165,7 @@ def user_password(username, password=None): # user-password
@click.argument("dept") @click.argument("dept")
def sco_delete_dept(dept): # sco-delete-dept def sco_delete_dept(dept): # sco-delete-dept
"Delete existing departement" "Delete existing departement"
if os.getuid() != 0: if os.system('tools/delete_dept.sh -n "{}"'.format(dept)):
sys.stderr.write("sco_delete_dept: must be run by root\n")
return 1
if os.system('cd tools && ./delete_dept.sh -n "{}"'.format(dept)):
sys.stderr.write("error deleting dept " + dept) sys.stderr.write("error deleting dept " + dept)
return 1 return 1
return 0 return 0
@ -178,10 +175,7 @@ def sco_delete_dept(dept): # sco-delete-dept
@click.argument("dept") @click.argument("dept")
def sco_create_dept(dept): # sco-create-dept def sco_create_dept(dept): # sco-create-dept
"Create new departement" "Create new departement"
if os.getuid() != 0: if os.system(f'tools/create_dept.sh -n "{dept}"'):
sys.stderr.write("sco_create_dept: must be run by root\n")
return 1
if os.system(f'cd tools && ./create_dept.sh -n "{dept}"'):
sys.stderr.write(f"error creating dept {dept}\n") sys.stderr.write(f"error creating dept {dept}\n")
return 1 return 1
return 0 return 0

View File

@ -17,7 +17,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$SCRIPT_DIR/config.sh" source "$SCRIPT_DIR/config.sh"
source "$SCRIPT_DIR/utils.sh" source "$SCRIPT_DIR/utils.sh"
check_uid_root "$0" [ "$USER" = "$SCODOC_USER" ] || die "$0 must run as user $SCODOC_USER"
cd "$SCRIPT_DIR" cd "$SCRIPT_DIR"
@ -61,19 +61,17 @@ then
exit 1 exit 1
fi fi
# --- Ensure postgres user "scodoc" ($POSTGRES_USER) exists
init_postgres_user
# ----------------------- Create Dept database # ----------------------- Create Dept database
su -c ./create_database.sh "$POSTGRES_SUPERUSER" # (créée en tant qu'utilisateur scodoc)
./create_database.sh
# ----------------------- Initialize table database # ----------------------- Initialize table database
# POSTGRES_USER == regular unix user (scodoc) # POSTGRES_USER == regular unix user (scodoc)
if [ "$interactive" = 1 ] if [ "$interactive" = 1 ]
then then
su -c ./initialize_database.sh "$POSTGRES_USER" ./initialize_database.sh
else else
su -c ./initialize_database.sh "$POSTGRES_USER" > /dev/null 2>&1 ./initialize_database.sh > /dev/null 2>&1
fi fi
@ -84,17 +82,10 @@ echo "dbname=${db_name}" > "$cfg_pathname"
if [ "$interactive" = 1 ] if [ "$interactive" = 1 ]
then then
# ----------------------- Force mise à jour
echo -n "Voulez vous mettre a jour ScoDoc (tres recommande) ? (y/n) [y] "
read -r ans
if [ "$(norm_ans "$ans")" != 'N' ]
then
(cd "$SCODOC_DIR/tools" || terminate "no config directory"; ./upgrade.sh)
fi
# ----------------------- # -----------------------
echo echo
echo " Departement $DEPT cree" echo " Departement $DEPT cree"
echo echo
echo " Attention: la base de donnees n'a pas de copies de sauvegarde" echo " Attention: la base de donnees n'a pas de copies de sauvegarde"
echo echo "(XXX section à revoir en ScoDoc 8.1)" # #sco8
fi fi

View File

@ -105,6 +105,11 @@ then
yes | ufw enable yes | ufw enable
fi fi
# --- POSTGRESQL
# --- Ensure postgres user "scodoc" ($POSTGRES_USER) exists
init_postgres_user
# --- XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX --- # --- XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX ---
echo echo
echo "WARNING: version ScoDoc8 expérimentale" echo "WARNING: version ScoDoc8 expérimentale"