From a50bede41aec348a71a5810cee06d192377edd21 Mon Sep 17 00:00:00 2001 From: Jocelyn Le Sage Date: Fri, 7 Oct 2022 22:36:46 -0400 Subject: [PATCH] Added support for enabling kiosk mode and opening an URL at launch. --- Dockerfile | 5 +++++ README.md | 2 ++ appdefs.yml | 14 +++++++++++++- rootfs/etc/services.d/app/params | 22 ++++++++++++++++++++++ rootfs/startapp.sh | 2 +- 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 rootfs/etc/services.d/app/params diff --git a/Dockerfile b/Dockerfile index fbf0f5e..9a1f2d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -119,6 +119,11 @@ RUN \ set-cont-env DOCKER_IMAGE_VERSION "$DOCKER_IMAGE_VERSION" && \ true +# Set public environment variables. +ENV \ + FF_OPEN_URL= \ + FF_KIOSK=0 + # Define mountable directories. VOLUME ["/config"] diff --git a/README.md b/README.md index eb7ff19..996f881 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,8 @@ of this parameter has the format `=`. |`VNC_LISTENING_PORT`| Port used by the VNC server to serve the UI of the application. This port is used internally by the container and it is usually not required to be changed. By default, a container is created with the default bridge network, meaning that, to be accessible, each internal container port must be mapped to an external port (using the `-p` or `--publish` argument). However, if the container is created with another network type, changing the port used by the container might be useful to prevent conflict with other services/containers. **NOTE**: a value of `-1` disables listening, meaning that the application's UI won't be accessible over VNC. | `5900` | |`VNC_PASSWORD`| Password needed to connect to the application's GUI. See the [VNC Password](#vnc-password) section for more details. | `""` | |`ENABLE_CJK_FONT`| When set to `1`, open-source computer font `WenQuanYi Zen Hei` is installed. This font contains a large range of Chinese/Japanese/Korean characters. | `0` | +|`FF_OPEN_URL`| The URL to open when Firefox starts. | (unset) | +|`FF_KIOSK`| Set to `1` to enable kiosk mode. This mode launches Firefox in a very restricted and limited mode best suitable for public areas or customer-facing displays. | `0` | ### Data Volumes diff --git a/appdefs.yml b/appdefs.yml index abab75e..2e68149 100644 --- a/appdefs.yml +++ b/appdefs.yml @@ -261,7 +261,19 @@ container: unsupported_volume: /storage # Environment variables. - environment_variables: [] + environment_variables: + - name: FF_OPEN_URL + description: >- + The URL to open when {{ app.friendly_name }} starts. + type: public + default: + - name: FF_KIOSK + description: >- + Set to `1` to enable kiosk mode. This mode launches Firefox in a very + restricted and limited mode best suitable for public areas or + customer-facing displays. + type: public + default: 0 # Volumes volumes: [] diff --git a/rootfs/etc/services.d/app/params b/rootfs/etc/services.d/app/params new file mode 100755 index 0000000..ad9410b --- /dev/null +++ b/rootfs/etc/services.d/app/params @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e # Exit immediately if a command exits with a non-zero status. +set -u # Treat unset variables as an error. + +# Set location of profile. +echo "--profile" +echo "/config/profile" + +# Make sure we don't get ask to be the default browser. +echo "--setDefaultBrowser" + +# Check if kiosk mode is enabled. +if [ "${FF_KIOSK:-0}" == 1 ]; then + echo "--kiosk" +fi + +# URL to open. +# NOTE: This should be the last argument. +if [ -n "${FF_OPEN_URL:-}" ]; then + echo "$FF_OPEN_URL" +fi diff --git a/rootfs/startapp.sh b/rootfs/startapp.sh index 0140226..c861cc4 100755 --- a/rootfs/startapp.sh +++ b/rootfs/startapp.sh @@ -6,4 +6,4 @@ set -u # Treat unset variables as an error. export HOME=/config /usr/bin/firefox --version -exec /usr/bin/firefox --profile /config/profile --setDefaultBrowser >> /config/log/firefox/output.log 2>> /config/log/firefox/error.log +exec /usr/bin/firefox "$@" >> /config/log/firefox/output.log 2>> /config/log/firefox/error.log