diff --git a/entrypoint.sh b/entrypoint.sh index 1c1d6ab..626236b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,7 +6,7 @@ if [ "${UID}" = "" ] || [ "${GID}" = "" ]; then exit 1 fi -if [ "${USER}" = "" ] || [ "${USER}" = "root"]; then +if [ "${USER}" = "" ] || [ "${USER}" = "root" ]; then echo "USER variable is not properly set, current value: ${USER}" exit 1 fi @@ -20,4 +20,4 @@ fi groupadd -g ${GID} user useradd ${USER} -d ${HOME} -s /bin/bash -u ${UID} -g ${GID} -sudo -Eu ${USER} "/opt/SMART Technologies/Notebook Software/bin/Notebook/notebook" ${SMART_ARGS} \ No newline at end of file +sudo -Eu ${USER} "/opt/SMART Technologies/Notebook Software/bin/Notebook/notebook" ${SMART_ARGS} diff --git a/start.sh b/start.sh index 076931c..f8c52b2 100644 --- a/start.sh +++ b/start.sh @@ -3,17 +3,39 @@ # Allow local and docker connections to X11 on the host xhost + local:docker >/dev/null -# TODO: Add /media to mapped directories to allow removable media +# Populate required variables if empty +[ "${USER}" = "" ] && USER=$(whoami) +[ "${HOME}" = "" ] && HOME="/home/${USER}" +[ "${HOSTNAME}" = "" ] && HOSTNAME=$(hostname) +[ "${UID}" = "" ] && UID=$(id -u) +[ "${GID}" = "" ] && GID=$(id -g "${USER}") + +# Include /media/$USER folder if it exists for removable media +if [ -d "/media/${USER}" ]; then + echo "Finding mounted removable media:" + for i in $(find "/media/${USER}/" -mindepth 1 -maxdepth 1 -type d); do + echo " Found ${i}" + USER_MEDIA_DIR_ARG="${USER_MEDIA_DIR_ARG} -v ${i}:${i}" + done +fi + +# Notebook writes some licensing data under /opt, so this +# dir gets mapped to the current users home directory too +LICENSE_DIR="${HOME}/.config/smart-notebook-license" +LICENSE_DIR_CONTAINER="/opt/SMART Technologies/common/data/" +[ ! -d "${LICENSE_DIR}" ] && mkdir -p "${LICENSE_DIR}" # Run docker container docker run \ -v /tmp/.X11-unix:/tmp/.X11-unix \ - -v ${HOME}:${HOME} \ - -e DISPLAY=${DISPLAY} \ - -e HOME=${HOME} \ - -e USER=${USER} \ - -e UID=${UID} \ - -e GID=$(id -g ${USER}) \ - -e SMART_ARGS=${@} \ - -h ${HOSTNAME} \ - notebook-gui \ No newline at end of file + -v "${LICENSE_DIR}":"${LICENSE_DIR_CONTAINER}" \ + -v "${HOME}":"${HOME}" \ + ${USER_MEDIA_DIR_ARG} \ + -e DISPLAY="${DISPLAY}" \ + -e HOME="${HOME}" \ + -e USER="${USER}" \ + -e UID="${UID}" \ + -e GID="${GID}" \ + -e SMART_ARGS="${@}" \ + -h "${HOSTNAME}" \ + notebook-gui