forked from arjones/bigdata-workshop-es
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcontrol-env.sh
executable file
·108 lines (85 loc) · 1.75 KB
/
control-env.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
function stop {
echo "Stopping and removing containers"
docker-compose --project-name wksp down
}
function cleanup {
echo "Removing volume"
docker volume rm wksp_postgres-data
docker volume rm wksp_superset
docker volume rm wksp_postgres-airflow-data
}
function start {
echo "Starting up"
docker-compose --project-name wksp up -d
}
function update {
echo "Updating code ..."
git pull --all
echo "Updating docker images ..."
docker-compose --project-name wksp pull
echo "You probably should restart"
}
function info {
echo '
Everything is ready, access your host to learn more (ie: http://localhost/)
'
}
function token {
echo 'Your TOKEN for Jupyter Notebook is:'
SERVER=$(docker exec -it jupyter jupyter notebook list)
echo "${SERVER}" | grep '/notebook' | sed -E 's/^.*=([a-z0-9]+).*$/\1/'
}
function superset-init {
echo 'Initializing Superset database using sqlite'
docker exec -it superset superset-init
}
function superset-start {
echo 'Starting Superset container'
docker container start superset
}
function superset-stop {
echo 'Stopping Superset container'
docker container stop superset
}
function psql {
docker exec -it postgres psql -U workshop workshop
}
case $1 in
start )
start
info
;;
stop )
stop
;;
cleanup )
stop
cleanup
;;
update )
update
;;
logs )
docker-compose --project-name wksp logs -f
;;
token )
token
;;
superset-start )
superset-start
;;
superset-stop )
superset-stop
;;
superset-init )
superset-init
;;
psql )
psql
;;
* )
printf "ERROR: Missing command\n Usage: `basename $0` (start|stop|cleanup|token|logs|update|superset-start|superset-stop|superset-init)\n"
exit 1
;;
esac