partitioncloud-server/make.sh

55 lines
1.5 KiB
Bash
Raw Permalink Normal View History

2022-08-13 16:28:57 +02:00
#!/bin/bash
INSTANCE_PATH="instance"
2022-08-13 16:28:57 +02:00
init () {
mkdir -p "$INSTANCE_PATH"
mkdir -p "$INSTANCE_PATH/partitions"
mkdir -p "$INSTANCE_PATH/attachments"
mkdir -p "$INSTANCE_PATH/search-partitions"
mkdir -p "$INSTANCE_PATH/static/thumbnails"
mkdir -p "$INSTANCE_PATH/static/search-thumbnails"
if ! test -f "$INSTANCE_PATH/config.py"; then
echo "SECRET_KEY=$(python3 -c 'import secrets; print(secrets.token_hex())')" > "$INSTANCE_PATH/config.py"
2023-09-08 13:59:22 +02:00
fi
if test -f "$INSTANCE_PATH/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
[[ $CONFIRMATION == y ]] || exit 1
2022-08-13 16:28:57 +02:00
fi
sqlite3 "$INSTANCE_PATH/partitioncloud.sqlite" '.read partitioncloud/schema.sql'
echo "Base de données créé"
sqlite3 "$INSTANCE_PATH/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_PATH/config.py" ]] && source "$INSTANCE_PATH/config.py"
2022-08-30 18:18:38 +02:00
$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