-
Notifications
You must be signed in to change notification settings - Fork 42
/
run.sh
executable file
·73 lines (59 loc) · 1.77 KB
/
run.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
#!/bin/bash
function showHelp {
echo -e "Usage: c9vnc <args>"
echo -e " -h Print this message"
echo -e " -f Run in the foreground"
echo -e " -k Kill running daemon"
echo -e "No arguments will try to start daemon process"
}
function runningMessage {
echo VNC client running at https://$C9_HOSTNAME/vnc.html
}
function foregroundStart {
#Run C9vnc in foreground
#Set environment variables
export XDG_RUNTIME_DIR=/tmp/C9VNC
export DISPLAY=:99.0
#Back up existing conf
cp ${HOME}/.config/supervisord.conf ${HOME}/.config/supervisord.conf.bak
#Modify supervisord.conf
sed -i -e 's/nodaemon=false/nodaemon=true/' ${HOME}/.config/supervisord.conf
#Run supervisord
supervisord -c ${HOME}/.config/supervisord.conf
#Revert back to original
mv ${HOME}/.config/supervisord.conf.bak ${HOME}/.config/supervisord.conf
}
function daemonStart {
echo -e "Starting c9vnc daemon"
{
#Set environment variables
export XDG_RUNTIME_DIR=/tmp/C9VNC
export DISPLAY=:99.0
#Run supervisord
supervisord -c ${HOME}/.config/supervisord.conf
}&> /dev/null
}
function daemonStop {
{
#Stop all C9vnc sub-processes
supervisorctl stop novnc
supervisorctl stop fluxbox
supervisorctl stop x11vnc
supervisorctl stop xvfb
#If that fails, killall
killall Xvfb x11vnc websockify supervisord
}&> /dev/null
}
# No arguments, default to starting the daemon
if [ $# -eq 0 ]
then
runningMessage; daemonStart ; sleep 5 ; exit ;
fi
while getopts :hfk opt; do
case $opt in
h) showHelp; exit ;;
f) runningMessage; foregroundStart ;;
k) daemonStop ; exit ;;
\?) echo "Unknown option -$OPTARG"; exit 1;;
esac
done