2022-08-13 16:28:57 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
init () {
|
2022-08-13 23:36:10 +02:00
|
|
|
mkdir -p "instance"
|
2022-08-16 18:58:34 +02:00
|
|
|
mkdir -p "partitioncloud/partitions"
|
2022-08-17 14:24:14 +02:00
|
|
|
mkdir -p "partitioncloud/search-partitions"
|
2022-08-16 18:58:34 +02:00
|
|
|
mkdir -p "partitioncloud/static/thumbnails"
|
2022-08-17 14:24:14 +02:00
|
|
|
mkdir -p "partitioncloud/static/search-thumbnails"
|
2023-03-04 19:49:15 +01:00
|
|
|
|
2023-09-08 13:53:56 +02:00
|
|
|
if ! test -f "instance/config.py"; then
|
|
|
|
echo "SECRET_KEY=$(python3 -c 'import secrets; print(secrets.token_hex())')" > instance/config.py
|
|
|
|
done
|
|
|
|
|
2023-03-04 19:49:15 +01:00
|
|
|
if test -f "instance/partitioncloud.sqlite"; then
|
2022-08-13 16:28:57 +02:00
|
|
|
printf "Souhaitez vous supprimer la base de données existante ? [y/n] "
|
|
|
|
read -r CONFIRMATION
|
2023-03-04 19:49:15 +01:00
|
|
|
[[ $CONFIRMATION == y ]] || exit 1
|
2022-08-13 16:28:57 +02:00
|
|
|
fi
|
2022-08-13 23:36:10 +02:00
|
|
|
sqlite3 "instance/partitioncloud.sqlite" '.read partitioncloud/schema.sql'
|
2023-03-04 19:49:15 +01:00
|
|
|
echo "Base de données créé"
|
|
|
|
sqlite3 "instance/partitioncloud.sqlite" '.read partitioncloud/init.sql'
|
|
|
|
echo "Utilisateur root:root ajouté"
|
2022-08-13 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
start () {
|
2022-08-30 18:18:38 +02:00
|
|
|
flask run --port=$PORT
|
|
|
|
}
|
|
|
|
|
|
|
|
production () {
|
|
|
|
FLASK_APP=partitioncloud /usr/bin/gunicorn \
|
|
|
|
wsgi:app \
|
|
|
|
--bind 0.0.0.0:$PORT
|
2022-08-13 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
usage () {
|
|
|
|
echo "Usage:"
|
|
|
|
echo -e "\t$0 init"
|
|
|
|
echo -e "\t$0 start"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ $1 && $(type "$1") = *"is a"*"function"* || $(type "$1") == *"est une fonction"* ]]; then
|
2022-08-30 18:18:38 +02:00
|
|
|
# Import config
|
|
|
|
source "default_config.py"
|
|
|
|
[[ ! -x instance/config.py ]] && source "instance/config.py"
|
|
|
|
$1 ${*:2} # Call the function
|
2022-08-13 16:28:57 +02:00
|
|
|
else
|
|
|
|
usage
|
|
|
|
echo $(type "$1")
|
|
|
|
exit 1
|
2022-08-13 23:36:10 +02:00
|
|
|
fi
|