From 262e908db971d897c0f79e3833656e3c44503aa5 Mon Sep 17 00:00:00 2001 From: Apoorv Vyavahare Date: Thu, 12 Aug 2021 19:35:07 +0000 Subject: [PATCH] novnc to purevnc --- Dockerfile | 43 ++++++++--------------- Dockerfile.heroku | 18 ---------- conf.d/1-xvfb.conf | 2 +- conf.d/{4-fluxbox.conf => 2-fluxbox.conf} | 4 +-- conf.d/{2-vnc.conf => 3-vnc.conf} | 2 +- conf.d/3-websockify.conf | 6 ---- conf.d/4-ngrok_tunnel.conf | 11 ++++++ conf.d/5-port-forward.conf | 6 ++++ conf.d/ngrok_tunnel.py | 21 +++++++++++ supervisord.conf | 5 --- 10 files changed, 57 insertions(+), 61 deletions(-) delete mode 100644 Dockerfile.heroku rename conf.d/{4-fluxbox.conf => 2-fluxbox.conf} (55%) rename conf.d/{2-vnc.conf => 3-vnc.conf} (95%) delete mode 100755 conf.d/3-websockify.conf create mode 100755 conf.d/4-ngrok_tunnel.conf create mode 100644 conf.d/5-port-forward.conf create mode 100644 conf.d/ngrok_tunnel.py delete mode 100755 supervisord.conf diff --git a/Dockerfile b/Dockerfile index ffddf6e..37574d4 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM ubuntu:20.04 +FROM vital987/supervisor:ubuntu20.04 -LABEL AboutImage "Ubuntu20.04_Fluxbox_NoVNC" +LABEL AboutImage "Ubuntu20.04_Fluxbox_PureVNC" LABEL Maintainer "Apoorv Vyavahare " @@ -15,16 +15,19 @@ ENV DEBIAN_FRONTEND=noninteractive \ VNC_RESOLUTION="1280x720" \ #Local Display Server Port DISPLAY=:0 \ -#NoVNC Port - NOVNC_PORT=$PORT \ #Locale LANG=en_US.UTF-8 \ LANGUAGE=en_US.UTF-8 \ LC_ALL=C.UTF-8 \ - TZ="Asia/Kolkata" + TZ="Asia/Kolkata" \ +#Ngrok Specific + NGROK_BINDTLS=1 \ + NGROK_METHOD=tcp \ + NGROK_PORT=5900 COPY . /app - +COPY conf.d/*.conf /config/supervisor/ +COPY conf.d/*.py /config/ RUN rm -rf /etc/apt/sources.list && \ #All Official Focal Repos bash -c 'echo -e "deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse\ndeb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse\ndeb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse\ndeb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse\ndeb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse\ndeb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse\ndeb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse\ndeb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse\ndeb http://archive.canonical.com/ubuntu focal partner\ndeb-src http://archive.canonical.com/ubuntu focal partner" >/etc/apt/sources.list' && \ @@ -40,13 +43,14 @@ RUN rm -rf /etc/apt/sources.list && \ curl \ vim \ zip \ + socat \ sudo \ net-tools \ iputils-ping \ build-essential \ - #python3 \ - #python3-pip \ - #python-is-python3 \ + python3 \ + python3-pip \ + python-is-python3 \ #perl \ #ruby \ #golang \ @@ -70,34 +74,21 @@ RUN rm -rf /etc/apt/sources.list && \ libreoffice \ pcmanfm \ terminator \ - supervisor \ x11vnc \ xvfb \ gnupg \ dirmngr \ gdebi-core \ nginx \ - novnc \ - openvpn \ ffmpeg \ pluma \ #Fluxbox /app/fluxbox-mod.deb && \ -#Websockify - npm i websockify && \ -#MATE Desktop - #apt install -y \ - #ubuntu-mate-core \ - #ubuntu-mate-desktop && \ -#XFCE Desktop - #apt install -y \ - #xubuntu-desktop && \ +#PyNgrok + pip3 install pyngrok && \ #TimeZone ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \ echo $TZ > /etc/timezone && \ -#NoVNC - cp /usr/share/novnc/vnc.html /usr/share/novnc/index.html && \ - openssl req -new -newkey rsa:4096 -days 36500 -nodes -x509 -subj "/C=IN/ST=Maharastra/L=Private/O=Dis/CN=www.google.com" -keyout /etc/ssl/novnc.key -out /etc/ssl/novnc.cert && \ #VS Code wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg && \ install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/ && \ @@ -129,7 +120,3 @@ RUN rm -rf /etc/apt/sources.list && \ apt install -y /tmp/packages-microsoft-prod.deb && \ apt update && \ apt-get install -y powershell - -ENTRYPOINT ["supervisord", "-l", "/app/supervisord.log", "-c"] - -CMD ["/app/supervisord.conf"] diff --git a/Dockerfile.heroku b/Dockerfile.heroku deleted file mode 100644 index c0f6f60..0000000 --- a/Dockerfile.heroku +++ /dev/null @@ -1,18 +0,0 @@ -FROM vital987/vubuntu:latest - -ENV DEBIAN_FRONTEND=noninteractive \ -#VNC Server Password - VNC_PASS="samplepass" \ -#VNC Server Title(w/o spaces) - VNC_TITLE="Vubuntu" \ -#VNC Resolution(720p is preferable) - VNC_RESOLUTION="1280x720" \ -#NoVNC Port - NOVNC_PORT=5900 \ -#PORT - PORT=80 \ -#Locale - LANG=en_US.UTF-8 \ - LANGUAGE=en_US.UTF-8 \ - LC_ALL=C.UTF-8 \ - TZ="Asia/Kolkata" diff --git a/conf.d/1-xvfb.conf b/conf.d/1-xvfb.conf index f173f50..a4e0379 100755 --- a/conf.d/1-xvfb.conf +++ b/conf.d/1-xvfb.conf @@ -3,4 +3,4 @@ command=bash -c 'Xvfb $DISPLAY -screen 0 $VNC_RESOLUTION"x24" -nolisten unix' autostart=true autorestart=true stderr_logfile=/var/log/Xvfb.stderr.log -priority=999 +priority=1 diff --git a/conf.d/4-fluxbox.conf b/conf.d/2-fluxbox.conf similarity index 55% rename from conf.d/4-fluxbox.conf rename to conf.d/2-fluxbox.conf index 03b36ba..9d46876 100755 --- a/conf.d/4-fluxbox.conf +++ b/conf.d/2-fluxbox.conf @@ -2,5 +2,5 @@ command=fluxbox autostart=true autorestart=true -priority=996 -stderr_logfile=/var/log/fluxbox.err.log \ No newline at end of file +priority=2 +stderr_logfile=/var/log/fluxbox.err.log diff --git a/conf.d/2-vnc.conf b/conf.d/3-vnc.conf similarity index 95% rename from conf.d/2-vnc.conf rename to conf.d/3-vnc.conf index e9a894d..1d53dfe 100755 --- a/conf.d/2-vnc.conf +++ b/conf.d/3-vnc.conf @@ -3,4 +3,4 @@ command=bash -c 'x11vnc -storepasswd $VNC_PASS /app/.xpass && x11vnc -usepw -rfb autostart=true autorestart=false stderr_logfile=/var/log/x11vnc.stderr.log -priority=998 +priority=3 diff --git a/conf.d/3-websockify.conf b/conf.d/3-websockify.conf deleted file mode 100755 index 08ef69c..0000000 --- a/conf.d/3-websockify.conf +++ /dev/null @@ -1,6 +0,0 @@ -[program:websockify] -command=bash -c 'websockify --cert /etc/ssl/novnc.cert --key /etc/ssl/novnc.key -D --web=/usr/share/novnc/ $PORT localhost:5900' -autostart=true -autorestart=false -stderr_logfile=/var/log/websockify.stderr.log -priority=997 diff --git a/conf.d/4-ngrok_tunnel.conf b/conf.d/4-ngrok_tunnel.conf new file mode 100755 index 0000000..4f4698a --- /dev/null +++ b/conf.d/4-ngrok_tunnel.conf @@ -0,0 +1,11 @@ +[program:NGROK_TUNNEL] +command=python3 /config/ngrok_tunnel.py +autostart=true +autorestart=false +priority=4 +stdout_logfile=/dev/stdout +stderr_logfile=/dev/stderr +stdout_maxbytes=0 +stderr_maxbytes=0 +stdout_logfile_maxbytes = 0 +stderr_logfile_maxbytes = 0 diff --git a/conf.d/5-port-forward.conf b/conf.d/5-port-forward.conf new file mode 100644 index 0000000..9ab8333 --- /dev/null +++ b/conf.d/5-port-forward.conf @@ -0,0 +1,6 @@ +[program:portforward] +command=bash -c 'socat TCP-LISTEN:$PORT,fork TCP:127.0.0.1:4040' +stderr_logfile=/var/log/socat.err.log +priority=1 +autostart=true +autorestart=false diff --git a/conf.d/ngrok_tunnel.py b/conf.d/ngrok_tunnel.py new file mode 100644 index 0000000..6e7cac5 --- /dev/null +++ b/conf.d/ngrok_tunnel.py @@ -0,0 +1,21 @@ +#!/usr/bin/python3 +import os +try: + from pyngrok import ngrok, conf +except: + os.system('pip3 install pyngrok') + from pyngrok import ngrok, conf +try: + AUTH_TOKEN=os.environ['NGROK_AUTH_TOKEN'] +except: + print('[!] Ngrok token not found, assign the token to NGROK_AUTH_TOKEN environment variable & try again.\n[-] Terminating...') + exit() +ngrok.set_auth_token(AUTH_TOKEN) +conf.get_default().region = "in" +try: + primary_tunnel = ngrok.connect(os.environ['NGROK_PORT'], os.environ['NGROK_METHOD'], bind_tls=bool(int(os.getenv('NGROK_BINDTLS', 1)))) +except: + print('[!] NGROK_PORT or NGROK_METHOD environment variables has not been set properly, NGROK_METHOD should be http or tcp') +url=primary_tunnel.public_url +print(f'[>NGROK]: {url}') +input() diff --git a/supervisord.conf b/supervisord.conf deleted file mode 100755 index ebe3525..0000000 --- a/supervisord.conf +++ /dev/null @@ -1,5 +0,0 @@ -[supervisord] -nodaemon=true - -[include] -files = /app/conf.d/*.conf \ No newline at end of file