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 @@