Skip to content

Commit

Permalink
Fix group membership for kiosk-browser on upgrade.
Browse files Browse the repository at this point in the history
Recovery workflow if browser window cannot be moved to correct screen.
  • Loading branch information
schlomo committed Feb 17, 2015
1 parent 1e7d3b2 commit 12c221c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: kiosk-browser
Version: 50
Version: 51
Priority: optional
Section: web
Architecture: all
Expand Down
4 changes: 3 additions & 1 deletion src/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ set -e
db_stop


if ! getent passwd kiosk-browser >/dev/null; then
if getent passwd kiosk-browser >/dev/null; then
usermod --groups video,audio kiosk-browser
else
useradd --system --user-group --groups video,audio --comment "Kiosk Browser User" --no-create-home --home-dir /var/lib/kiosk-browser kiosk-browser
mkdir -p /var/lib/kiosk-browser
fi
Expand Down
13 changes: 9 additions & 4 deletions src/usr/share/kiosk-browser/xsession.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function exittrap {
rm -Rf $HOME
) </dev/null &
}
trap exittrap TERM EXIT # kill subprocesses on exit
trap exittrap HUP TERM EXIT # kill subprocesses on exit

# Wait 30 seconds for network by checking for default route
(( end_time=SECONDS+30 ))
Expand Down Expand Up @@ -87,7 +87,7 @@ xrandr $(
xrandr_position=
for (( c=0 ; c<${#KIOSK_BROWSER_PORTS[@]} ; c++ )) ; do
port=$(xrandr_find_port "${KIOSK_BROWSER_PORTS[c]}")
echo "--output $port ${KIOSK_BROWSER_XRANDR_EXTRA_OPTS[c]} $xrandr_position --auto"
echo "--output $port ${KIOSK_BROWSER_XRANDR_EXTRA_OPTS[c]} $( ((c == 0)) && echo --primary ) $xrandr_position --auto"
xrandr_position="--right-of $port"
done
)
Expand Down Expand Up @@ -155,7 +155,7 @@ set geometry=maximized"

while true; do
# exit if no display given, use xwininfo to test for running X server
xwininfo -root &>/dev/null || exit 0
xwininfo -root &>/dev/null || exit 99

# if KIOSK_BROWSER_PORTS is set, assume that it specifies multiple screens connected.
for (( c=0 ; c<${#KIOSK_BROWSER_PORTS[@]} ; c++ )) ; do
Expand Down Expand Up @@ -187,7 +187,12 @@ while true; do
starttime=$SECONDS
while ! xdotool search --onlyvisible --pid $PID --name any windowmove --sync $port_x 0 ; do
if (( SECONDS-starttime > 30 )) ; then
break
killall -TERM ${CHROME##*/} # if we can't find a chrome window then we kill them all and try again, killall needs only basename
sleep 2 &
wait $!
killall -KILL ${CHROME##*/}
kill -KILL $(jobs -p) # kill all background jobs (= browsers) to restart outer while loop
break 2 # abort the for loop
fi
sleep 2 &
wait $!
Expand Down

0 comments on commit 12c221c

Please sign in to comment.