diff --git a/Dockerfile b/Dockerfile index 59a7820..f8e8808 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,17 +13,21 @@ RUN apk add --no-cache \ qemu-hw-usb-redirect \ nginx \ netcat-openbsd \ + python3 \ + py3-pip \ + py3-virtualenv \ && mkdir -p /usr/share/novnc \ && wget https://github.com/novnc/noVNC/archive/refs/tags/v${NOVNC_VERSION}.tar.gz -O /tmp/novnc.tar.gz -q \ && tar -xf /tmp/novnc.tar.gz -C /tmp/ \ && cd /tmp/noVNC-${NOVNC_VERSION}\ && mv app core vendor package.json *.html /usr/share/novnc \ - && wget https://github.com/OliveTin/OliveTin/releases/latest/download/OliveTin_linux_arm64.apk \ - && apk add --allow-untrusted OliveTin_linux_arm64.apk \ + && wget https://github.com/bugy/script-server/releases/download/1.18.0/script-server.zip \ + && unzip -o script-server.zip -d /usr/share/script-server \ + && python3 -m venv /var/lib/script-server-env \ + && source /var/lib/script-server-env/bin/activate \ + && pip install -r /usr/share/script-server/requirements.txt \ && sed -i 's/^worker_processes.*/worker_processes 1;/' /etc/nginx/nginx.conf -# export OPENWRT_VERSION=`date '+%Y%M%W'`_$OPENWRT_VERSION \ - # Get OpenWrt images RUN mkdir /var/vm \ && if [ "$OPENWRT_VERSION" = "master" ] ; then \ @@ -42,6 +46,7 @@ ENV OPENWRT_VERSION=${OPENWRT_VERSION} COPY ./src /run/ COPY ./web /var/www/ COPY ./openwrt_additional /var/vm/openwrt_additional +COPY ./script-server /var/script-server RUN chmod +x /run/*.sh diff --git a/script-server/conf.json b/script-server/conf.json new file mode 100644 index 0000000..caa8a00 --- /dev/null +++ b/script-server/conf.json @@ -0,0 +1,9 @@ +{ + "title": "Openwrt control", + "port": "5000", + + "access": { + "allowed_users": "*", + "admin_users": "*" + } +} diff --git a/script-server/runners/factory_reset.json b/script-server/runners/factory_reset.json new file mode 100644 index 0000000..8c8c614 --- /dev/null +++ b/script-server/runners/factory_reset.json @@ -0,0 +1,6 @@ +{ + "name": "Apply factory reset", + "description": "Hard factory reset of Openwrt", + "script_path": "/run/qemu_qmp.sh -f" +} + diff --git a/script-server/runners/reset.json b/script-server/runners/reset.json new file mode 100644 index 0000000..426639d --- /dev/null +++ b/script-server/runners/reset.json @@ -0,0 +1,6 @@ +{ + "name": "Reset OpenWRT", + "description": "Hard reset of Openwrt VM", + "script_path": "/run/qemu_qmp.sh -r" +} + diff --git a/script-server/scripts/sample.sh b/script-server/scripts/sample.sh new file mode 100644 index 0000000..5d21cc3 --- /dev/null +++ b/script-server/scripts/sample.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo "Hello sample script" + diff --git a/src/reset.sh b/src/reset.sh index 6fcd273..569562c 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -168,8 +168,18 @@ cp -r /var/www/* /run/shm html "Starting $APP for Docker..." nginx -e stderr -# Start OliveTin -cp -f /var/www/olivetin_config.yaml /etc/OliveTin/config.yaml -OliveTin 2> /var/log/olivetin.log & +# ******* script-server handeling ******* + +# Ugly hack to enable iframe usage +sed -i "s/'X-Frame-Options', 'DENY'/ \ +'X-Frame-Options', 'ALLOWALL'/g" \ +/usr/share/script-server/src/web/server.py + +# Usage of default logging.json' +cp -f /usr/share/script-server/conf/logging.json /var/script-server/logging.json + +# Start script-server +/var/lib/script-server-env/bin/python \ +/usr/share/script-server/launcher.py -d /var/script-server > /var/log/script-server.log & return 0 diff --git a/web/css/style.css b/web/css/style.css index b8b4735..76b5130 100644 --- a/web/css/style.css +++ b/web/css/style.css @@ -2,7 +2,7 @@ div { text-align:center; } - html, body, div, iframe { height: 100%; } + html, body, div, iframe { height: 99%; } iframe { display:inline-block; diff --git a/web/index.html b/web/index.html index 237c476..4ee2602 100644 --- a/web/index.html +++ b/web/index.html @@ -10,7 +10,7 @@
- +
diff --git a/web/nginx.conf.generic b/web/nginx.conf.generic index 6cc4f42..3489a92 100644 --- a/web/nginx.conf.generic +++ b/web/nginx.conf.generic @@ -53,14 +53,17 @@ server { proxy_pass http://127.0.0.1:5700/; } - location /olivetin/ { - proxy_pass http://localhost:1337/; - proxy_redirect http://localhost:1337/ http://localhost/OliveTin/; - } - - location /websocket { - proxy_set_header Upgrade "websocket"; + location /script-server/ { + proxy_pass_header Server; + proxy_set_header Host $proxy_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://127.0.0.1:5000/; + + # needed for websockets + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; - proxy_pass http://localhost:1337/websocket; + proxy_set_header Origin http://$proxy_host; } } diff --git a/web/olivetin_config.yaml b/web/olivetin_config.yaml deleted file mode 100644 index b7dd02e..0000000 --- a/web/olivetin_config.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# There is a built-in micro proxy that will host the webui and REST API all on -# one port (this is called the "Single HTTP Frontend") and means you just need -# one open port in the container/firewalls/etc. -# -# Listen on all addresses available, port 1337 -listenAddressSingleHTTPFrontend: 0.0.0.0:1337 - -# Choose from INFO (default), WARN and DEBUG -logLevel: "INFO" - -# Actions (buttons) to show up on the WebUI: -actions: - - title: Restart Openwrt - shell: /run/qemu_qmp.sh -r - icon: restart - - - title: Factory reset - shell: /run/qemu_qmp.sh -f - icon: "⚙"