|
|
|
#!/bin/sh
|
|
|
|
export FLASK_APP=yadc
|
|
|
|
root="."
|
|
|
|
|
|
|
|
pipenv="python3 -m pipenv"
|
|
|
|
run="$pipenv run"
|
|
|
|
editor="nano"
|
|
|
|
|
|
|
|
prepare_venv() {
|
|
|
|
$pipenv install
|
|
|
|
}
|
|
|
|
|
|
|
|
prepare_instance() {
|
|
|
|
mkdir -p instance
|
|
|
|
mkdir -p instance/post/img
|
|
|
|
mkdir -p instance/post/jpeg
|
|
|
|
mkdir -p instance/post/sample
|
|
|
|
mkdir -p instance/post/thumb_big
|
|
|
|
mkdir -p instance/post/thumb
|
|
|
|
|
|
|
|
cp yadc/config.def.py instance/config.py
|
|
|
|
}
|
|
|
|
|
|
|
|
edit_config() {
|
|
|
|
$editor instance/config.py
|
|
|
|
}
|
|
|
|
|
|
|
|
prepare_db() {
|
|
|
|
$run flask db upgrade
|
|
|
|
}
|
|
|
|
|
|
|
|
prepare_accounts() {
|
|
|
|
$run flask shell << EOF
|
|
|
|
user = User(username='admin', op_level='admin')
|
|
|
|
user.create_password('latexsucks')
|
|
|
|
db.session.add(user)
|
|
|
|
db.session.commit()
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
gunicorn_run() {
|
|
|
|
$run gunicorn yadc:app
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
"init_venv")
|
|
|
|
prepare_venv
|
|
|
|
;;
|
|
|
|
"init_instance")
|
|
|
|
prepare_instance
|
|
|
|
;;
|
|
|
|
"config")
|
|
|
|
edit_config
|
|
|
|
;;
|
|
|
|
"init_db")
|
|
|
|
prepare_db
|
|
|
|
;;
|
|
|
|
"init_accounts")
|
|
|
|
prepare_accounts
|
|
|
|
;;
|
|
|
|
"init")
|
|
|
|
prepare_venv
|
|
|
|
prepare_instance
|
|
|
|
|
|
|
|
echo "Now please configure database access credentials and preferably other relevant settings."
|
|
|
|
sleep 4
|
|
|
|
edit_config
|
|
|
|
|
|
|
|
prepare_db
|
|
|
|
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"
|
|
|
|
echo " init_venv"
|
|
|
|
echo " init_instance"
|
|
|
|
echo " config"
|
|
|
|
echo " init_db"
|
|
|
|
echo " init_accounts"
|
|
|
|
;;
|
|
|
|
esac
|