-
Notifications
You must be signed in to change notification settings - Fork 1
/
ov
executable file
·85 lines (65 loc) · 2.17 KB
/
ov
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
80
81
82
83
84
85
#!/bin/bash
HELP="Open Vault init script\n\n
USAGE:\n\n
./ov COMMAND [args] \n\n
COMMANDS:\n\n
\t b | build \t build the docker images \n
\t backup | dump \t create a backup of the database \n
\t c | cmd \t run a compose command \n
\t d | dev \t start a development server \n
\t deploy \t run a deploy command
\t i | init \t run initialization script \n
\t h | help \t prints this help text \n
\t m | manage \t run a wagtail manage.py command \n
\t restore | load\t restore a database backup \n
\t s | shell \t run a django shell command with the app context
"
OV_UID=$(id -u)
OV_GID=$(id -g)
COMPOSE="docker compose -f docker-compose.yml -f ov-wag/docker-compose.yml"
DEPLOY="-f deploy.yml"
MANAGE="run -it --entrypoint python wagtail manage.py"
if [ -z $1 ]; then
echo -e $HELP
elif [ $1 = "build" -o $1 = "b" ]; then
shift
docker compose build "$@"
elif [ $1 = "cmd" -o $1 = "c" ]; then
shift
# docker run -it -v $(pwd)/:/app/ ov "$@"
$COMPOSE $DEPLOY "$@"
elif [ $1 = "dev" -o $1 = "d" ]; then
shift
# docker run -itp 8000:8000 -v $(pwd)/:/app/ ov "$@"
$COMPOSE $DEPLOY up
elif [ $1 = "deploy" ]; then
shift
./deploy "$@"
elif [ $1 = "docs" ]; then
shift
docker run --rm -it -p 8001:8001 -v ${PWD}:/docs wgbhmla/ov-docs serve -a 0.0.0.0:8001
elif [ $1 = "init" -o $1 = "i" ]; then
shift
# build docker files
./ov build &&
# install npm requirements
./ov c run -it front npm install &&
echo "Open Vault initialized successfully!"
elif [ $1 = "manage" -o $1 = "m" ]; then
shift
# docker run -it -v $(pwd)/:/app/ ov python3 manage.py "$@"
$COMPOSE $DEPLOY $MANAGE "$@"
elif [ $1 = "shell" -o $1 = "s" ]; then
shift
# docker run -it -v $(pwd)/:/app/ ov python3 manage.py shell "$@"
$COMPOSE $DEPLOY $MANAGE shell "$@"
elif [ $1 = "dump" -o $1 = "backup" ]; then
shift
TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S`
$COMPOSE $DEPLOY exec -it db pg_dump -Fc -U postgres postgres > db_$TIMESTAMP.sql
elif [ $1 = "load" -o $1 = "restore" ]; then
shift
# Restore a database from a dump file $1
$COMPOSE $DEPLOY exec -iT db pg_restore --verbose --clean --no-acl --no-owner -U postgres -d postgres < $1
else echo -e $HELP
fi