From 8b1de46a6da181bf9fe411dea9fa546d40e413a7 Mon Sep 17 00:00:00 2001 From: "Josh.5" Date: Sat, 17 Sep 2022 18:00:37 +1200 Subject: [PATCH] Add Niko server as an alternative to noVNC --- Dockerfile | 17 +++++++++++++++-- overlay/etc/cont-init.d/70-configure_neko.sh | 18 ++++++++++++++++++ overlay/etc/cont-init.d/70-configure_vnc.sh | 5 ++--- overlay/etc/supervisor.d/neko.ini | 16 ++++++++++++++++ 4 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 overlay/etc/cont-init.d/70-configure_neko.sh create mode 100644 overlay/etc/supervisor.d/neko.ini diff --git a/Dockerfile b/Dockerfile index 5a2f9c7..baa99cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -224,6 +224,10 @@ RUN \ && \ echo +# Install Neko server +COPY --from=m1k1o/neko:base /usr/bin/neko /usr/bin/neko +COPY --from=m1k1o/neko:base /var/www /var/www + # Install noVNC ARG NOVNC_VERSION=1.2.0 RUN \ @@ -421,7 +425,12 @@ RUN \ && useradd -d ${USER_HOME} -s /bin/bash ${USER} \ && chown -R ${USER} \ ${USER_HOME} \ - && echo "${USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers + && echo "${USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \ + && adduser ${USER} audio \ + && adduser ${USER} video \ + && adduser ${USER} pulse \ + && \ + echo # Add FS overlay COPY overlay / @@ -442,6 +451,9 @@ ENV \ ENV \ MODE="primary" \ WEB_UI_MODE="vnc" \ + ENABLE_VNC_AUDIO="true" \ + NEKO_PASSWORD=neko \ + NEKO_PASSWORD_ADMIN=admin # Configure required ports ENV \ @@ -449,7 +461,8 @@ ENV \ PORT_VNC="5900" \ PORT_AUDIO_STREAM="5901" \ PORT_NOVNC_WEB="8083" \ - PORT_AUDIO_WEBSOCKET="32123" + PORT_AUDIO_WEBSOCKET="32123" \ + NEKO_NAT1TO1="" # Expose the required ports EXPOSE 2222 diff --git a/overlay/etc/cont-init.d/70-configure_neko.sh b/overlay/etc/cont-init.d/70-configure_neko.sh new file mode 100644 index 0000000..07f88e4 --- /dev/null +++ b/overlay/etc/cont-init.d/70-configure_neko.sh @@ -0,0 +1,18 @@ + +echo "**** Configure Neko ****" + + +if ([ ${WEB_UI_MODE} = "neko" ] && [ "${MODE}" != "s" ] && [ "${MODE}" != "secondary" ]); then + echo "Enable Neko server" + sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/neko.ini + if [[ -z ${NEKO_NAT1TO1} ]]; then + export NEKO_NAT1TO1=$(ip route get 1 | awk '{print $(NF-2);exit}') + echo "Setting NEKO_NAT1TO1=${NEKO_NAT1TO1}" + else + echo "User provided setting NEKO_NAT1TO1=${NEKO_NAT1TO1}" + fi +else + echo "Disable Neko server" +fi + +echo "DONE" diff --git a/overlay/etc/cont-init.d/70-configure_vnc.sh b/overlay/etc/cont-init.d/70-configure_vnc.sh index b920fcb..b778476 100644 --- a/overlay/etc/cont-init.d/70-configure_vnc.sh +++ b/overlay/etc/cont-init.d/70-configure_vnc.sh @@ -2,10 +2,8 @@ echo "**** Configure VNC ****" if ([ ${WEB_UI_MODE} = "vnc" ] && [ "${MODE}" != "s" ] && [ "${MODE}" != "secondary" ]); then - echo "Enable VNC server" sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/vnc.ini - if [[ "${ENABLE_VNC_AUDIO}" == "true" ]]; then # Credits for this audio patch: # - https://github.com/novnc/noVNC/issues/302 @@ -34,7 +32,8 @@ if ([ ${WEB_UI_MODE} = "vnc" ] && [ "${MODE}" != "s" ] && [ "${MODE}" != "second # Disable supervisord script sed -i 's|^autostart.*=.*$|autostart=false|' /etc/supervisor.d/vnc-audio.ini fi - +else + echo "Disable VNC server" fi echo "DONE" diff --git a/overlay/etc/supervisor.d/neko.ini b/overlay/etc/supervisor.d/neko.ini new file mode 100644 index 0000000..7eeb7db --- /dev/null +++ b/overlay/etc/supervisor.d/neko.ini @@ -0,0 +1,16 @@ + +[program:neko] +autostart=false +autorestart=true +priority=30 +user=%(ENV_USER)s +command=/usr/bin/neko serve --static "/var/www" --display %(ENV_DISPLAY)s --bind :%(ENV_PORT_NOVNC_WEB)s +environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s",DISPLAY="%(ENV_DISPLAY)s" +stopsignal=INT +stopwaitsecs=5 +stdout_logfile=/home/%(ENV_USER)s/.cache/log/neko.log +stdout_logfile_maxbytes=10MB +stdout_logfile_backups=7 +stderr_logfile=/home/%(ENV_USER)s/.cache/log/neko.err.log +stderr_logfile_maxbytes=10MB +stderr_logfile_backups=7