From 22122a25294d5caddb0aa2e2dbba46a0ca25b307 Mon Sep 17 00:00:00 2001 From: Albrecht Lohofener Date: Sun, 18 Feb 2024 21:59:02 +0100 Subject: [PATCH] Switch from tini to supervisord --- Dockerfile | 6 ++- src/reset.sh | 106 ----------------------------------------------- supervisord.conf | 14 +++++++ 3 files changed, 18 insertions(+), 108 deletions(-) create mode 100644 supervisord.conf diff --git a/Dockerfile b/Dockerfile index f8e8808..d15652e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,12 @@ FROM alpine:latest ARG NOVNC_VERSION="1.4.0" ARG OPENWRT_VERSION="23.05.2" +ARG S6_OVERLAY_VERSION="3.1.6.2" ARG VERSION_ARG "0.1" RUN apk add --no-cache \ + supervisor \ bash \ - tini \ wget \ qemu-system-aarch64 \ qemu-hw-usb-host \ @@ -43,6 +44,7 @@ RUN mkdir /var/vm \ fi ENV OPENWRT_VERSION=${OPENWRT_VERSION} +COPY supervisord.conf /etc/supervisord.conf COPY ./src /run/ COPY ./web /var/www/ COPY ./openwrt_additional /var/vm/openwrt_additional @@ -57,4 +59,4 @@ EXPOSE 8022 RUN echo "$VERSION_ARG" > /run/version -ENTRYPOINT ["/sbin/tini", "-s", "/run/entry.sh"] +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] \ No newline at end of file diff --git a/src/reset.sh b/src/reset.sh index 569562c..2b999b5 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -39,7 +39,6 @@ ARCH=$(uname -m) VERS=$(qemu-system-aarch64 --version | head -n 1 | cut -d '(' -f 1) # Check system - if [ ! -d "/dev/shm" ]; then error "Directory /dev/shm not found!" && exit 14 else @@ -47,7 +46,6 @@ else fi # Check folder - if [ ! -d "$STORAGE" ]; then error "Storage folder ($STORAGE) not found!" && exit 13 fi @@ -61,115 +59,11 @@ else cp -f /var/www/nginx.conf.u-os-app /etc/nginx/http.d/web.conf fi -# Helper functions - -isAlive() { - local pid=$1 - - if kill -0 "$pid" 2>/dev/null; then - return 0 - fi - - return 1 -} - -pKill() { - local pid=$1 - - { kill -15 "$pid" || true; } 2>/dev/null - - while isAlive "$pid"; do - sleep 0.2 - done - - return 0 -} - -fWait() { - local name=$1 - - while pgrep -f -l "$name" >/dev/null; do - sleep 0.2 - done - - return 0 -} - -fKill() { - local name=$1 - - { pkill -f "$name" || true; } 2>/dev/null - fWait "$name" - - return 0 -} - -escape () { - local s - s=${1//&/\&} - s=${s///\>} - s=${s//'"'/\"} - printf -- %s "$s" - return 0 -} - -html() -{ - local title - local body - local script - local footer - - title=$(escape "$APP") - title="$title" - footer=$(escape "$FOOTER1") - - body=$(escape "$1") - if [[ "$body" == *"..." ]]; then - body="

${body/.../}

" - fi - - [ -n "${2:-}" ] && script="$2" || script="" - - local HTML - HTML=$(<"$TEMPLATE") - HTML="${HTML/\[1\]/$title}" - HTML="${HTML/\[2\]/$script}" - HTML="${HTML/\[3\]/$body}" - HTML="${HTML/\[4\]/$footer}" - HTML="${HTML/\[5\]/$FOOTER2}" - - echo "$HTML" > "$PAGE" - echo "$body" > "$INFO" - - return 0 -} - -addPackage() { - local pkg=$1 - local desc=$2 - - if apt-mark showinstall | grep -qx "$pkg"; then - return 0 - fi - - MSG="Installing $desc..." - info "$MSG" && html "$MSG" - - DEBIAN_FRONTEND=noninteractive apt-get -qq update - DEBIAN_FRONTEND=noninteractive apt-get -qq --no-install-recommends -y install "$pkg" > /dev/null - - return 0 -} - # Start webserver cp -r /var/www/* /run/shm -html "Starting $APP for Docker..." nginx -e stderr # ******* script-server handeling ******* - # Ugly hack to enable iframe usage sed -i "s/'X-Frame-Options', 'DENY'/ \ 'X-Frame-Options', 'ALLOWALL'/g" \ diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..14d13c5 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,14 @@ +[supervisord] +nodaemon=true +logfile=/dev/null +logfile_maxbytes=0 + +[program:entry] +command=/run/entry.sh +process_name=%(program_name)s +directory=/run +autostart=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 \ No newline at end of file