From d56a8dde5395a80e8aed46b1b4b9dd8d2b6ba5d8 Mon Sep 17 00:00:00 2001 From: quietsy Date: Sat, 1 Apr 2023 10:31:15 +0300 Subject: [PATCH] Fix version links change the mod to the alpine pkg --- .github/workflows/BuildImage.yml | 4 - Dockerfile | 87 +------------------ root/dashboard/www/index.php | 36 +++++--- root/etc/cont-init.d/98-dashboard-config | 30 ------- .../init-mod-swag-dashboard-add-package/run | 10 +-- 5 files changed, 31 insertions(+), 136 deletions(-) delete mode 100644 root/etc/cont-init.d/98-dashboard-config diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml index 7b4271e..21c8db5 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -13,10 +13,6 @@ jobs: steps: - uses: actions/checkout@v2.3.3 - - name: Set up qemu - run: | - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Build image run: | docker build --no-cache -t ${{ github.sha }} . diff --git a/Dockerfile b/Dockerfile index 69f0e31..281bf57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,91 +1,6 @@ -FROM ghcr.io/linuxserver/baseimage-alpine:amd64-3.15 as build-stage-amd64 - -RUN \ - echo "**** install packages ****" && \ - apk add -U --update --no-cache --virtual=build-dependencies \ - autoconf \ - automake \ - build-base \ - git \ - glib-dev \ - libmaxminddb-dev \ - ncurses-dev && \ - mkdir -p /build && \ - mkdir -p /goaccess && \ - echo "**** build goaccess ****" && \ - git clone --shallow-submodules --recurse-submodules https://github.com/allinurl/goaccess.git /goaccess && cd /goaccess && \ - autoreconf -fiv && \ - ./configure --enable-utf8 --enable-geoip=mmdb && \ - make DESTDIR="/build" install && \ - echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ - rm -rf \ - /goaccess/* \ - /tmp/* - -FROM ghcr.io/linuxserver/baseimage-alpine:arm32v7-3.15 as build-stage-arm32v7 - -RUN \ - echo "**** install packages ****" && \ - apk add -U --update --no-cache --virtual=build-dependencies \ - autoconf \ - automake \ - build-base \ - git \ - glib-dev \ - libmaxminddb-dev \ - ncurses-dev && \ - mkdir -p /build && \ - mkdir -p /goaccess && \ - echo "**** build goaccess ****" && \ - git clone --shallow-submodules --recurse-submodules https://github.com/allinurl/goaccess.git /goaccess && cd /goaccess && \ - autoreconf -fiv && \ - ./configure --enable-utf8 --enable-geoip=mmdb && \ - make DESTDIR="/build" install && \ - echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ - rm -rf \ - /goaccess/* \ - /tmp/* - -FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.15 as build-stage-arm64v8 - -RUN \ - echo "**** install packages ****" && \ - apk add -U --update --no-cache --virtual=build-dependencies \ - autoconf \ - automake \ - build-base \ - git \ - glib-dev \ - libmaxminddb-dev \ - ncurses-dev && \ - mkdir -p /build && \ - mkdir -p /goaccess && \ - echo "**** build goaccess ****" && \ - git clone --shallow-submodules --recurse-submodules https://github.com/allinurl/goaccess.git /goaccess && cd /goaccess && \ - autoreconf -fiv && \ - ./configure --enable-utf8 --enable-geoip=mmdb && \ - make DESTDIR="/build" install && \ - echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ - rm -rf \ - /goaccess/* \ - /tmp/* - -FROM scratch as build-stage-consolidate - -COPY --from=build-stage-amd64 /build/ /goaccess/x86_64/ -COPY --from=build-stage-arm32v7 /build/ /goaccess/armv7l/ -COPY --from=build-stage-arm64v8 /build/ /goaccess/aarch64/ -COPY root/ / - FROM scratch LABEL maintainer="quietsy" # copy local files -COPY --from=build-stage-consolidate / / +COPY root/ / \ No newline at end of file diff --git a/root/dashboard/www/index.php b/root/dashboard/www/index.php index 456ccf0..647c1fb 100644 --- a/root/dashboard/www/index.php +++ b/root/dashboard/www/index.php @@ -140,29 +140,37 @@ $files = ""; $counter = 1; $conf_locations = array( + ".conf" => "https://github.com/linuxserver/docker-swag/blob/master/root/defaults/nginx/", "subdomain.conf" => "https://github.com/linuxserver/reverse-proxy-confs/blob/master/", "subfolder.conf" => "https://github.com/linuxserver/reverse-proxy-confs/blob/master/", "dashboard.subdomain.conf" => "https://github.com/linuxserver/docker-mods/blob/swag-dashboard/root/dashboard/", + "nginx.conf" => "https://github.com/linuxserver/docker-baseimage-alpine-nginx/tree/master/root/defaults/nginx/", + "ssl.conf" => "https://github.com/linuxserver/docker-baseimage-alpine-nginx/tree/master/root/defaults/nginx/", + "default.conf" => "https://github.com/linuxserver/docker-swag/blob/master/root/defaults/nginx/site-confs/", ); - $output = shell_exec("/etc/cont-init.d/85-version-checks"); + $output = shell_exec("/etc/s6-overlay/s6-rc.d/init-version-checks/run"); foreach(explode(PHP_EOL, $output) as $line) { if(substr($line, 0, 1) === "*"){ $tooltip .= str_replace("*", "", $line).PHP_EOL; - } elseif(substr($line, 0, 1) === "/") { + } elseif(str_contains($line, "/config/")) { $tr_class = ($counter % 2 == 0) ? 'shaded' : ''; - $files .= ''.htmlspecialchars($line).''; - $file_name = substr($line, strrpos($line, '/') + 1); - $link = "https://github.com/linuxserver/docker-swag/blob/master/root/defaults/nginx/".$file_name; + $clean_line = htmlspecialchars($line); + list($old_date, $new_date, $path) = explode(' │ ', $clean_line); + $old_date = trim($old_date, '│ \n\r\t\v\x00'); + $new_date = trim($new_date, '│ \n\r\t\v\x00'); + $path = trim($path, '│ \n\r\t\v\x00'); + $files .= ''; + $files .= ''.$old_date.''; + $files .= ''.$new_date.''; + $files .= ''.$path.''; + $file_name = substr($path, strrpos($path, '/') + 1); foreach($conf_locations as $key=>$value) { if (strpos($file_name, $key) !== false) { $link = $value.$file_name; } - } - if (strpos($file_name, 'subdomain.conf') !== false or strpos($file_name, 'subfolder.conf') !== false) { - $link .= '.sample'; } - $files .= ''; + $files .= ''; $counter++; } } @@ -174,6 +182,14 @@

Version Updates

+ + + + + + + + {$files} @@ -253,7 +269,7 @@ endif; $access_log = file_exists("/dashboard/logs") ? "/dashboard/logs/*.log" : "/config/log/nginx/access.log"; - $goaccess = shell_exec("cat $access_log | /usr/local/bin/goaccess -a -o html --config-file=/dashboard/goaccess.conf $geodb -"); + $goaccess = shell_exec("cat $access_log | /usr/bin/goaccess -a -o html --config-file=/dashboard/goaccess.conf $geodb -"); $goaccess = str_replace("Server Statistics", "<title>SWAG Dashboard", $goaccess); $goaccess = str_replace("<h1 class='h-dashboard'>", "<h1>", $goaccess); $goaccess = str_replace("<i class='fa fa-tachometer'></i>", "<img src='/icon.svg' width='32' height='32'> SWAG ", $goaccess); diff --git a/root/etc/cont-init.d/98-dashboard-config b/root/etc/cont-init.d/98-dashboard-config deleted file mode 100644 index ac11c0e..0000000 --- a/root/etc/cont-init.d/98-dashboard-config +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/with-contenv bash - -echo "Applying the SWAG dashboard mod..." - -ARCH=$(uname -m) -if [ -d "/goaccess/${ARCH}" ]; then - echo "**** Installing/updating goaccess ****" - cp -a /goaccess/${ARCH}/* / - rm -rf /goaccess -else - echo "**** Goaccess already installed and up to date ****" -fi - -apk add --no-cache libmaxminddb -cp -f /dashboard/dashboard.subdomain.conf.sample /config/nginx/proxy-confs/dashboard.subdomain.conf.sample -if [ ! -f /config/nginx/proxy-confs/dashboard.subdomain.conf ]; then - cp /dashboard/dashboard.subdomain.conf.sample /config/nginx/proxy-confs/dashboard.subdomain.conf -fi - -if [ "$(sed -nE 's|## Version ([0-9]{4}\/[0-9]{2}\/[0-9]{2}).*|\1|p' /dashboard/dashboard.subdomain.conf.sample)" != "$(sed -nE 's|## Version ([0-9]{4}\/[0-9]{2}\/[0-9]{2}).*|\1|p' /config/nginx/proxy-confs/dashboard.subdomain.conf)" ]; then - echo "**** The swag-dashboard conf has been updated ****" - echo "**** Compare the changes using the sample file: /config/nginx/proxy-confs/dashboard.subdomain.conf.sample" -fi - -# permissions -chown -R abc:abc \ - /dashboard \ - /config/nginx/proxy-confs/dashboard.subdomain.conf - -echo "Applied the SWAG dashboard mod" diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-swag-dashboard-add-package/run b/root/etc/s6-overlay/s6-rc.d/init-mod-swag-dashboard-add-package/run index f7f2903..f22c471 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-mod-swag-dashboard-add-package/run +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-swag-dashboard-add-package/run @@ -2,13 +2,11 @@ echo "**** Applying the SWAG dashboard mod... ****" -ARCH=$(uname -m) -if [ -d "/goaccess/${ARCH}" ]; then - echo "**** Installing/updating goaccess ****" - cp -a /goaccess/${ARCH}/* / - rm -rf /goaccess +if ! apk info 2>&1 | grep -q "goaccess"; then + echo "**** Adding goaccess to package install list ****" + echo "goaccess" >> /mod-repo-packages-to-install.list else - echo "**** Goaccess already installed and up to date ****" + echo "**** goaccess already installed, skipping ****" fi if ! apk info 2>&1 | grep -q "libmaxminddb"; then

Old Date

New Date

Path

Link