summaryrefslogtreecommitdiffstats
path: root/core/modules/kiosk-chromium
diff options
context:
space:
mode:
authorSimon Rettberg2019-11-12 15:36:44 +0100
committerSimon Rettberg2019-11-12 15:36:44 +0100
commit2ec543530689bb3ee17e0b9a3a0b1adceed1e7ed (patch)
treecff71cfe49cf252a8c2c46702e6f9b157196e798 /core/modules/kiosk-chromium
parent[kiosk-*] Support SLX_BROWSER, add precheck for browser binary (diff)
downloadmltk-2ec543530689bb3ee17e0b9a3a0b1adceed1e7ed.tar.gz
mltk-2ec543530689bb3ee17e0b9a3a0b1adceed1e7ed.tar.xz
mltk-2ec543530689bb3ee17e0b9a3a0b1adceed1e7ed.zip
[kiosk-chromium] Simplify json generation, add sanity check
Only wipe chromium profile if it's actually the demo user, to be safe. Json generation of bookmarks was simplified to use jq instead of awk, with the added benefit of properly quoting special chars in URL/Name.
Diffstat (limited to 'core/modules/kiosk-chromium')
-rw-r--r--core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium70
1 files changed, 34 insertions, 36 deletions
diff --git a/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium b/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium
index caf67ab9..226b274b 100644
--- a/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium
+++ b/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium
@@ -4,51 +4,49 @@
command -v chromium-browser || return 0
# clear state of previous sessions
-[ -e "$HOME/.config/chromium" ] && rm -rf -- "$HOME/.config/chromium"
-mkdir -p "$HOME/.config/chromium/Default"
+if [ "$(whoami)" = "demo" ]; then
+ rm -rf -- "$HOME/.config/chromium"
+ mkdir -p "$HOME/.config/chromium/Default"
+fi
# Helper to json'ize bookmarks given as arguments in the form:
# <name>,<url> -> e.g. Google,https://www.google.com
json_bookmarks() {
- cur=0
- echo -n '['
+ local cur=0
while [ $# -ne 0 ]; do
- local bb="$1"
+ jq --null-input --join-output --compact-output --arg id "$(( cur++ ))" --arg name "${1%%,*}" --arg url "${1#*,}" \
+ '{"id": $id, "type": "url", "name": $name, "url": $url}'
shift
- awk -F, '{printf "%s","{\"id\": \"'$cur'\", \"type\": \"url\", \"name\": \""$1"\", \"url\": \""$2"\"}"}' <<< "$bb"
- [ $# -ne 0 ] && echo -n ','
- (( cur ++ ))
- done
- echo -n ']'
+ [ $# -ne 0 ] && printf ","
+ done
}
-jq ".roots.bookmark_bar.children += $(json_bookmarks $SLX_BROWSER_BOOKMARKS)" \
- <(cat <<-EOF
- {
- "roots": {
- "bookmark_bar": {
- "children": [ ],
- "id": "1",
- "name": "Lesezeichenleiste",
- "type": "folder"
- },
- "other": {
- "children": [ ],
- "id": "2",
- "name": "Weitere Lesezeichen",
- "type": "folder"
- },
- "synced": {
- "children": [ ],
- "id": "3",
- "name": "Mobile Lesezeichen",
- "type": "folder"
- }
- },
- "version": 1
+# Pass SLX_BROWSER_BOOKMARKS without quotes for splitting into arguments
+cat > "$HOME/.config/chromium/Default/Bookmarks" <<EOF
+{
+ "roots": {
+ "bookmark_bar": {
+ "children": [ $(json_bookmarks $SLX_BROWSER_BOOKMARKS) ],
+ "id": "1",
+ "name": "Lesezeichenleiste",
+ "type": "folder"
+ },
+ "other": {
+ "children": [ ],
+ "id": "2",
+ "name": "Weitere Lesezeichen",
+ "type": "folder"
+ },
+ "synced": {
+ "children": [ ],
+ "id": "3",
+ "name": "Mobile Lesezeichen",
+ "type": "folder"
}
- EOF
- ) > "$HOME/.config/chromium/Default/Bookmarks"
+ },
+ "version": 1
+}
+EOF
# default chromium arguments
chromium_args=("--noerrdialogs" "--disable-new-avatar-menu" "--disable-infobars" "--test-type")