forked from phaer/kassomat-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchangeomatic.sh
executable file
·60 lines (50 loc) · 1.03 KB
/
changeomatic.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
#!/bin/bash
set -eu
SCRIPT_NAME=$0
DISPLAY=:0
JAR=/home/kassomat/changeomatic/target/changeomatic-jar-0.0.1-SNAPSHOT-jar-with-dependencies.jar
function is_running() {
$(tmux has-session -t changeomatic &> /dev/null)
test $? -eq 0 && echo yes
}
function usage() {
echo "${SCRIPT_NAME} start|stop|status"
}
function status() {
if [ $(is_running) ]
then echo "running"
else echo "stopped"
fi
}
function start() {
if [ $(is_running) ]
then
echo "changeomatic is already running"
else
echo "starting changeomatic"
tmux new-session -d -s changeomatic "DISPLAY=${DISPLAY} java -jar ${JAR}"
fi
}
function stop() {
if [ $(is_running) ]
then
tmux kill-session -t changeomatic
else
echo "changeomatic does not seem to be running"
fi
}
function attach() {
if [ $(is_running) ]
then
tmux attach -t changeomatic
else
echo "changeomatic does not seem to be running"
fi
}
case ${1:-usage} in
start) start;;
stop) stop;;
status) status;;
attach) attach;;
*) usage; exit 1;;
esac