This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
DMCD.sh
75 lines (58 loc) · 1.23 KB
/
DMCD.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
#!/bin/bash
COMMAND=$1
start() {
pm2 start ./build/Server.js
}
stop() {
pm2 stop ./build/Server.js
}
build() {
npm run build
}
restart() {
pm2 restart ./build/Server.js
}
logs() {
pm2 logs ./build/Server.js
}
update() {
echo "* Getting the newest release"
TAG=$(curl --silent "https://api.github.com/repos/tolfix/dmcd/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/')
curl -L -o master.tar.gz https://github.com/Tolfix/dmcd/archive/refs/tags/$TAG.tar.gz
tar xf master.tar.gz -C /var/dmcd --strip-components 1
rm -r master.tar.gz
echo "* Updated DMCD"
}
commands() {
echo "
Commands:
start => Starts the application
build => Builds the application
stop => Stops the application
restart => Restarts the application
logs => Shows what it has been logging
update => Pulls new updates from github (if any)"
}
if [ "$COMMAND" = "start" ]; then
start
fi
if [ "$COMMAND" = "stop" ]; then
stop
fi
if [ "$COMMAND" = "build" ]; then
build
fi
if [ "$COMMAND" = "restart" ]; then
restart
fi
if [ "$COMMAND" = "logs" ]; then
logs
fi
if [ "$COMMAND" = "update" ]; then
update
fi
if [ ! "$COMMAND" ]; then
commands
fi