-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·79 lines (65 loc) · 2.13 KB
/
make.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
INSTANCE_PATH="instance"
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/cache/thumbnails"
mkdir -p "$INSTANCE_PATH/cache/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"
fi
if test -f "$INSTANCE_PATH/partitioncloud.sqlite"; then
printf "Souhaitez vous supprimer la base de données existante ? [y/n] "
read -r CONFIRMATION
[[ $CONFIRMATION == y ]] || exit 1
rm "$INSTANCE_PATH/partitioncloud.sqlite"
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é"
}
translations () {
# Rajouter les chaînes non traduites
pybabel extract -F babel.cfg -k _l -o partitioncloud/translations/messages.pot .
pybabel update -i partitioncloud/translations/messages.pot -d partitioncloud/translations/
# Compiler
pybabel compile -d partitioncloud/translations/
}
start () {
pybabel compile -d partitioncloud/translations/
flask run --port=$PORT
}
production () {
pybabel compile -d partitioncloud/translations/
FLASK_APP=partitioncloud gunicorn \
wsgi:app \
--bind 0.0.0.0:$PORT
}
load_config () {
# Load variables PORT and INSTANCE_PATH
eval $(cat $1 | grep -E "^PORT=")
eval $(cat $1 | grep -E "^INSTANCE_PATH=")
}
usage () {
echo "Usage:"
echo -e "\t$0 init"
echo -e "\t$0 start"
echo -e "\t$0 production"
echo -e "\t$0 translations"
}
RESULT=$(type "$1")
if [[ $1 && $RESULT = *"is a"*"function"* || $RESULT == *"est une fonction"* ]]; then
# Import config
load_config "default_config.py"
if test -f "instance/config.py"; then
load_config "instance/config.py"
fi
$1 ${*:2} # Call the function
else
usage
echo $RESULT
exit 1
fi