forked from rtCamp/media-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia-node.sh
executable file
·79 lines (70 loc) · 1.93 KB
/
media-node.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
command=$1
usage () {
echo "Usage: launcher COMMAND CONFIG [--skip-prereqs]"
echo "Commands:"
echo " start: Start/initialize a container"
echo " stop: Stop a running container"
echo " restart: Restart a container"
echo " logs: Docker logs for container"
exit 1
}
set_existing_container(){
existing=`docker ps -a | awk '{ print $1, $(NF) }' | grep " media-node" | awk '{ print $1 }'`
}
run_stop () {
set_existing_container
if [ ! -z $existing ]
then
(
set -x
docker stop -t 10 media-node
)
else
echo "media-node was not started !"
exit 1
fi
}
run_start () {
mkdir -p /root/media-node/{temp,completed,queued}
existing=`docker ps | awk '{ print $1, $(NF) }' | grep " media-node" | awk '{ print $1 }'`
echo $existing
if [ ! -z $existing ]
then
echo "Nothing to do, your container has already started!"
exit 1
# else
# docker run -id --name media-node --restart=always -p 1203:1203 -v /root/media-node/completed:/root/completed -v /root/media-node/temp:/root/temp -v /root/media-node/queued:/root/queued rtcamp/media-node
fi
existing=`docker ps -a | awk '{ print $1, $(NF) }' | grep " media-node" | awk '{ print $1 }'`
if [ ! -z $existing ]
then
echo "starting up existing container"
(
set -x
docker start media-node
)
exit 0
fi
docker run -id --name media-node --restart=always -p 1203:1203 -v /root/media-node/completed:/root/media-node/completed -v /root/media-node/temp:/root/media-node/temp -v /root/media-node/queued:/root/media-node/queued rtcamp/media-node
}
case "$command" in
stop)
run_stop
exit 0
;;
logs)
docker logs media-node
exit 0
;;
restart)
run_stop
run_start
exit 0
;;
start)
run_start
exit 0
;;
esac
usage