From 2f8f7920f8839dea5044ddbe7e83cd1703fb297a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C5=BE=C3=ADlek?= Date: Fri, 1 May 2020 14:30:50 +0200 Subject: [PATCH] Manage script - admin account init --- manage.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/manage.sh b/manage.sh index f33f40d..9b193fd 100755 --- a/manage.sh +++ b/manage.sh @@ -29,6 +29,15 @@ prepare_db() { $run flask db upgrade } +prepare_accounts() { + $run flask shell << EOF +user = User(username='admin') +user.create_password('latexsucks') +db.session.add(user) +db.session.commit() +EOF +} + gunicorn_run() { $run gunicorn yadc:app } @@ -46,6 +55,9 @@ case $1 in "init_db") prepare_db ;; + "init_accounts") + prepare_accounts + ;; "init") prepare_venv prepare_instance @@ -55,13 +67,13 @@ case $1 in edit_config prepare_db - - echo "Now (if no error occured) you are ready to launch your application using \'$0 run\'" + prepare_accounts + echo "Now (if no error occured) you are ready to launch your application using '$0 run'" ;; "run") gunicorn_run ;; - "") + *) echo "useable parameters:" echo " run - run gunicorn listener" echo " init - complete init" @@ -69,5 +81,6 @@ case $1 in echo " init_instance" echo " config" echo " init_db" + echo " init_accounts" ;; esac \ No newline at end of file