summaryrefslogtreecommitdiffstats
path: root/core/modules/kiosk-slxbrowser/data/opt/openslx/scripts/kiosk-launch.d/00-slxbrowser
blob: 4ec49eca9bad5c39e2259b39afed9d6b9d2fb913 (plain) (blame)
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
#!/bin/bash
# ^ sourced!

command -v slxbrowser || return 0

OPTS=()

# Ignore SSL errors
[ -n "$SLX_BROWSER_INSECURE" ] && [ "$SLX_BROWSER_INSECURE" -gt 0 ] && OPTS+=("--insecure")
# On inactivity, reload every X seconds
[ -n "$SLX_BROWSER_RELOAD_SECS" ] && [ "$SLX_BROWSER_RELOAD_SECS" -gt 0 ] && OPTS+=("--reload-interval" "$SLX_BROWSER_RELOAD_SECS")
# If we have no black- or whitelist, see if the legacy vars exist
if [ -z "$SLX_BROWSER_BLACKLIST" ] && [ -z "$SLX_BROWSER_WHITELIST" ] && [ -n "$SLX_BROWSER_URLLIST" ]; then
	# If set, is a space separated list of URLs or hosts
	if [ "$SLX_BROWSER_IS_WHITELIST" -gt 0 ]; then
		SLX_BROWSER_WHITELIST="$SLX_BROWSER_URLLIST"
	else
		SLX_BROWSER_BLACKLIST="$SLX_BROWSER_URLLIST"
	fi
fi

if [ -n "$SLX_BROWSER_BLACKLIST" ]; then
	# Turn into file with one entry per line
	bl="$( mktemp )"
	sed -r 's/\s+/\n/g' <<<"$SLX_BROWSER_BLACKLIST" > "$bl"
	OPTS+=("--blacklist" "$bl")
	# Async, clean up file after slxbrowser read it
	( sleep 4; rm -f -- "$bl" ) &
fi
if [ -n "$SLX_BROWSER_WHITELIST" ]; then
	wl="$( mktemp )"
	sed -r 's/\s+/\n/g' <<<"$SLX_BROWSER_WHITELIST" > "$wl"
	OPTS+=("--whitelist" "$wl")
	( sleep 4; rm -f -- "$wl" ) &
fi

if [ -z "${SLX_AUTOLOGIN%OFF}" ]; then
	OPTS+=("--maximized")
else
	OPTS+=("--fullscreen")
fi

if [ -n "$SLX_BROWSER_ZOOM" ]; then
	OPTS+=( "--zoom" "$SLX_BROWSER_ZOOM" )
fi

# HACK: give whatever enough time to whatever it does properly
sleep 1

exec slxbrowser "${OPTS[@]}" "$SLX_BROWSER_URL"