11#! /bin/bash
2- # shellcheck shell=dash disable=SC3010,SC3020
2+ # shellcheck shell=dash disable=SC3010,SC3020,SC3057,SC3004,SC3060,SC2030,SC2031
33#
44# This is a startup script for qutselect which initates a
5- # VNC session to a windows server via 'vncviewer'
5+ # third-party application download+install in a thinRoot
6+ # environment where qutselect is used.
67#
78# It receives the following inputs:
89#
@@ -41,27 +42,55 @@ umask 077
4142
4243TMPDIR=/tmp
4344
45+ # font descriptions
46+ YAD_FONT_DESC=" ${YAD_FONT_DESC:- DejaVu Sans 18} "
47+ OSD_FONT_DESC=" ${OSD_FONT_DESC:- -* -fixed-bold-r-* -* -30-* -* -* -* -* -* -* } "
48+
49+ # osd_cat usage helpers
50+ osd_pid=
51+
52+ osd_splash () {
53+ local msg=" $1 "
54+ local color=" ${2:- orange} "
55+ local time=" ${3:- 0} "
56+ if [ -x /usr/bin/osd_cat ]; then
57+ export LANG=en_US.UTF-8
58+ echo " ${msg} " | /usr/bin/osd_cat -A center -p top -f " ${OSD_FONT_DESC} " -c " ${color} " -s 5 -d " ${time} " &
59+ osd_pid=$!
60+ else
61+ osd_pid=
62+ fi
63+ }
64+
65+ osd_close () {
66+ if [[ -n " ${osd_pid} " ]]; then
67+ kill " ${osd_pid} " 2> /dev/null
68+ wait " ${osd_pid} " 2> /dev/null
69+ osd_pid=
70+ fi
71+ }
72+ trap ' osd_close' EXIT INT TERM
73+
4474res=2
4575if [[ " ${app} " == " zoom" ]]; then
4676
4777 if [[ ! -d /opt/zoom ]]; then
48- yad --center --text=" Downloading zoom.pkg...." --title " Zoom Installation" --no-buttons &
49- yad_pid=$!
78+ osd_splash " Downloading zoom.pkg..."
5079 /usr/bin/wget -q " ${BASE_PATH} /pkgs/zoom.pkg" -O " ${TMPDIR} /zoom.pkg"
51- kill -9 ${yad_pid}
80+ osd_close
5281
53- yad --center --text=" Installing zoom.pkg...." --title " Zoom Installation" --no-buttons &
54- yad_pid=$!
82+ osd_splash " Installing zoom.pkg..."
5583 tar -C / -xf " ${TMPDIR} /zoom.pkg"
5684 rm -f " ${TMPDIR} /zoom.pkg"
57- kill -9 ${yad_pid}
85+ osd_close
5886 fi
5987
6088 if [[ ! -x /opt/zoom/ZoomLauncher ]]; then
61- yad --center --text=" ERROR: Installation of Zoom failed"
89+ osd_splash " ERROR: Installation of Zoom failed" " red" 3
90+ wait " ${osd_pid} " 2> /dev/null
91+ exit 1
6292 else
63- yad --center --text=" Starting zoom..." --no-buttons &
64- yad_pid=$!
93+ osd_splash " Starting zoom..."
6594
6695 # remove all previous data
6796 rm -rf " ${HOME} /.zoom" " ${HOME} /.config/zoom.conf" " ${HOME} /.config/zoomus.conf"
@@ -90,29 +119,28 @@ if [[ "${app}" == "zoom" ]]; then
90119 USER=" Enter your name here" /opt/zoom/ZoomLauncher > " /tmp/zoom-${USER} -$$ .log" 2>&1 &
91120 res=$?
92121
93- kill -9 ${yad_pid}
122+ osd_close
94123 fi
95124
96125elif [[ " ${app} " == " chrome" ]] || [[ " ${app} " == " bbb" ]]; then
97126
98127 if [[ ! -d /opt/chrome ]]; then
99- yad --center --text=" Downloading chrome.pkg...." --title " Chrome Installation" --no-buttons &
100- yad_pid=$!
128+ osd_splash " Downloading chrome.pkg..."
101129 /usr/bin/wget -q " ${BASE_PATH} /pkgs/chrome.pkg" -O " ${TMPDIR} /chrome.pkg"
102- kill -9 ${yad_pid}
130+ osd_close
103131
104- yad --center --text=" Installing chrome.pkg...." --title " Chrome Installation" --no-buttons &
105- yad_pid=$!
132+ osd_splash " Installing chrome.pkg..."
106133 tar -C / -xf " ${TMPDIR} /chrome.pkg"
107134 rm -f " ${TMPDIR} /chrome.pkg"
108- kill -9 ${yad_pid}
135+ osd_close
109136 fi
110137
111138 if [[ ! -x /opt/chrome/chrome ]]; then
112- yad --center --text=" ERROR: Installation of Chrome failed"
139+ osd_splash " ERROR: Installation of Chrome failed" " red" 3
140+ wait " ${osd_pid} " 2> /dev/null
141+ exit 1
113142 else
114- yad --center --text=" Starting chrome..." --no-buttons &
115- yad_pid=$!
143+ osd_splash " Starting chrome..."
116144
117145 # remove all previous data
118146 rm -rf " ${HOME} /.config/chrome"
@@ -125,17 +153,70 @@ elif [[ "${app}" == "chrome" ]] || [[ "${app}" == "bbb" ]]; then
125153
126154 # add some options for BBB mode
127155 if [[ " ${app} " == " bbb" ]]; then
128- CMDOPT=" ${CMDOPT} --app=https://bbb.hzdr.de/"
129- if [[ " ${resolution} " == " fullscreen" ]]; then
130- CMDOPT=" ${CMDOPT} --kiosk"
131- fi
156+ (
157+ # when we start a BBB session we have to ask for a
158+ # potential room identifier
159+ BBB_BASE=" https://bbb.hzdr.de/"
160+ ROOM_RE=' ^[A-Za-z0-9]{3}(-[A-Za-z0-9]{3}){3}$' # xxx-xxx-xxx-xxx
161+ room=" "
162+
163+ while true ; do
164+ room=" $(
165+ yad --entry \
166+ --title=" https://bbb.hzdr.de/b/xxx-xxx-xxx-xxx" \
167+ --entry-text=" ${room} " \
168+ --text=" <span font_desc=\" ${YAD_FONT_DESC} \" ><b>Please enter BBB Room-ID:</b></span>\n\nFormat: xxx-xxx-xxx-xxx (part after /b/ in link)" \
169+ --window-type=dialog --on-top --sticky --center --fixed \
170+ --button=" OK" :0 --button=" No Room ID" :1 --button=" Cancel" :2
171+ ) "
172+ rc=$?
173+
174+ if [[ $rc -eq 2 ]] || [[ $rc -eq 252 ]]; then
175+ exit 0
176+ elif [[ $rc -eq 1 ]] || [[ -z " ${room} " ]]; then
177+ room=" "
178+ break
179+ fi
180+
181+ # Optional: remote whitespaces and if someone added the url, extract it
182+ room=" ${room// [[:space:]]/ } "
183+ room=" ${room# " ${BBB_BASE} " b/ } " # removes "https://bbb.hzdr.de/b/" if there
184+ room=$( echo " ${room} " | LC_ALL=C tr ' [:upper:]' ' [:lower:]' )
185+
186+ if [[ " $room " =~ $ROOM_RE ]]; then
187+ break
188+ fi
189+
190+ yad --error \
191+ --title=" Invalid Room-ID" \
192+ --text=" <span font_desc=\" ${YAD_FONT_DESC} \" ><b>The entered Room-ID was invalid.</b></span>\n\nExpected: xxx-xxx-xxx-xxx (each 3 alphanumerical characters)." \
193+ --window-type=dialog --on-top --center --fixed \
194+ --button=" Retry" :0
195+ done
196+
197+ if [[ -n " ${room} " ]]; then
198+ bbb_url=" ${BBB_BASE} b/${room} "
199+ else
200+ bbb_url=" ${BBB_BASE} "
201+ fi
202+
203+ CMDOPT=" ${CMDOPT} --app=${bbb_url} "
204+ if [[ " ${resolution} " == " fullscreen" ]]; then
205+ CMDOPT=" ${CMDOPT} --kiosk"
206+ fi
207+
208+ # shellcheck disable=SC2086
209+ /opt/chrome/chrome ${CMDOPT} --test-type --noerrdialogs --no-first-run --disable-translate --disk-cache-dir=/dev/null --disable-extensions > " /tmp/chrome-${USER} -$$ .log" 2>&1 &
210+ osd_close
211+ ) < /dev/null > /dev/null 2>&1 &
212+
213+ # parent should return immediately
214+ exit 0
215+ else
216+ /opt/chrome/chrome ${CMDOPT} --test-type --noerrdialogs --no-first-run --disable-translate --disk-cache-dir=/dev/null --disable-extensions > " /tmp/chrome-${USER} -$$ .log" 2>&1 &
217+ res=$?
218+ osd_close
132219 fi
133-
134- # shellcheck disable=SC2086
135- /opt/chrome/chrome ${CMDOPT} --test-type --noerrdialogs --no-first-run --disable-translate --disk-cache-dir=/dev/null --no-sandbox --disable-extensions > " /tmp/chrome-${USER} -$$ .log" 2>&1 &
136- res=$?
137-
138- kill -9 ${yad_pid}
139220 fi
140221
141222elif [[ " ${app} " == " firefox" ]]; then
0 commit comments