-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.sh
executable file
·83 lines (69 loc) · 1.53 KB
/
docker.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
#!/bin/bash
# --------------------------------------------------------
# Docker helper script
# Author: Fernando Costa de Almeida
# --------------------------------------------------------
CONTAINER_NAME=torrentmanager
# Defaults. Values from .env file can overwrite those
DOCKER_USER=pr3st00
SERVER_PORT=8083
if [[ -f .env ]]; then
echo "Loading variables from .env file"
. ./.env
fi
function build() {
echo "[INFO] Building container [${CONTAINER_NAME}]"
docker build -t ${DOCKER_USER}/${CONTAINER_NAME} .
}
function run() {
echo "[INFO] Running container [${CONTAINER_NAME}]"
docker run --restart always -d -p ${SERVER_PORT}:${SERVER_PORT} \
-e DELUGE_URL=${DELUGE_URL} -e DELUGE_PASS=${DELUGE_PASS} -e DOWNLOAD_PATH=${DOWNLOAD_PATH} \
--name $CONTAINER_NAME ${DOCKER_USER}/${CONTAINER_NAME}
}
function start() {
echo "[INFO] Starting container [${CONTAINER_NAME}]"
docker start $CONTAINER_NAME
}
function stop() {
echo "[INFO] Stopping container [${CONTAINER_NAME}]"
docker stop $CONTAINER_NAME
}
function status() {
echo "[INFO] Running containers: "
echo
docker ps | grep $CONTAINER_NAME
}
function remove() {
echo "[INFO] Removing container [${CONTAINER_NAME}]"
docker rm $CONTAINER_NAME
}
case $1 in
build)
build
;;
run)
run
;;
remove)
stop && remove
;;
start)
start
;;
stop)
stop
;;
status)
status
;;
update)
stop && remove && build && run && status
;;
*)
echo "Usage: docker.sh {build|run|remove|start|stop|update|status}"
exit 1
;;
esac
exit 0
# EOF