-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockapp-start
executable file
·71 lines (56 loc) · 1.52 KB
/
dockapp-start
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
#!/bin/bash
# Initialize variables
resolution="1024x780x24"
additional_cmd="ls -l"
x11vnc_args=""
unixsockonly=0
while getopts "h?r:a:x:fu" opt; do
printf " -%s '%s'\n" $OPTION $OPTARG
case "$opt" in
h|\?)
help
exit 0
;;
r) resolution=$OPTARG
;;
a) additional_cmd=$OPTARG
;;
f) x11vnc_args+="-forever "
;;
u) unixsockonly=1
;;
esac
done
shift $((OPTIND-1))
help() {
echo "./dockapp-start [arg...]"
}
echo "resolution='$resolution'"
echo "cmd='$cmd'"
echo "x11vnc_args='$x11vnc_args'"
echo "leftovers: $@"
# start framebuffer display server
Xvfb :1 -extension GLX -screen 0 $resolution &
# export DISPLAY or you have to use "DISPLAY=:1 /usr/bin/cmd"
export DISPLAY=:1
/usr/bin/openbox-session &
# Wait a bit until the X server is ready
sleep 1
# Launch an additional command in the background
$additional_cmd &
# Launch an xterm
xterm &
# Without using the -forever flag the container will stop
# as soon as vncviewer disconnects
#x11vnc -usepw -display :1 -forever
if [ $unixsockonly -eq 0 ]; then
x11vnc -usepw -display :1 $x11vnc_args
else
# switch to user app so that the socket gets created
# with the correct user:group on the host
su app -c"/x11vnc-0.9.13/x11vnc/x11vnc -unixsockonly /share/x11vnc-socket -display :1 $x11vnc_args"
fi
# To make sure we can restart this container properly
# Fatal server error: Server is already active for display 1
# If this server is no longer running, remove /tmp/.X1-lock
rm /tmp/.X1-lock