Switch from tini to supervisord

This commit is contained in:
Albrecht Lohofener
2024-02-18 21:59:02 +01:00
parent 0fc779a091
commit 22122a2529
3 changed files with 18 additions and 108 deletions
+4 -2
View File
@@ -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"]
-106
View File
@@ -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//</\&lt;}
s=${s//>/\&gt;}
s=${s//'"'/\&quot;}
printf -- %s "$s"
return 0
}
html()
{
local title
local body
local script
local footer
title=$(escape "$APP")
title="<title>$title</title>"
footer=$(escape "$FOOTER1")
body=$(escape "$1")
if [[ "$body" == *"..." ]]; then
body="<p class=\"loading\">${body/.../}</p>"
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" \
+14
View File
@@ -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