Skip to content

Commit 33ba5f3

Browse files
authored
Merge pull request #613 from quietsy/swag-dashboard
Fix version links and change the mod to use the alpine package
2 parents 6e6ddfb + d56a8dd commit 33ba5f3

5 files changed

Lines changed: 31 additions & 136 deletions

File tree

.github/workflows/BuildImage.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v2.3.3
1515

16-
- name: Set up qemu
17-
run: |
18-
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
19-
2016
- name: Build image
2117
run: |
2218
docker build --no-cache -t ${{ github.sha }} .

Dockerfile

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,6 @@
1-
FROM ghcr.io/linuxserver/baseimage-alpine:amd64-3.15 as build-stage-amd64
2-
3-
RUN \
4-
echo "**** install packages ****" && \
5-
apk add -U --update --no-cache --virtual=build-dependencies \
6-
autoconf \
7-
automake \
8-
build-base \
9-
git \
10-
glib-dev \
11-
libmaxminddb-dev \
12-
ncurses-dev && \
13-
mkdir -p /build && \
14-
mkdir -p /goaccess && \
15-
echo "**** build goaccess ****" && \
16-
git clone --shallow-submodules --recurse-submodules https://github.com/allinurl/goaccess.git /goaccess && cd /goaccess && \
17-
autoreconf -fiv && \
18-
./configure --enable-utf8 --enable-geoip=mmdb && \
19-
make DESTDIR="/build" install && \
20-
echo "**** cleanup ****" && \
21-
apk del --purge \
22-
build-dependencies && \
23-
rm -rf \
24-
/goaccess/* \
25-
/tmp/*
26-
27-
FROM ghcr.io/linuxserver/baseimage-alpine:arm32v7-3.15 as build-stage-arm32v7
28-
29-
RUN \
30-
echo "**** install packages ****" && \
31-
apk add -U --update --no-cache --virtual=build-dependencies \
32-
autoconf \
33-
automake \
34-
build-base \
35-
git \
36-
glib-dev \
37-
libmaxminddb-dev \
38-
ncurses-dev && \
39-
mkdir -p /build && \
40-
mkdir -p /goaccess && \
41-
echo "**** build goaccess ****" && \
42-
git clone --shallow-submodules --recurse-submodules https://github.com/allinurl/goaccess.git /goaccess && cd /goaccess && \
43-
autoreconf -fiv && \
44-
./configure --enable-utf8 --enable-geoip=mmdb && \
45-
make DESTDIR="/build" install && \
46-
echo "**** cleanup ****" && \
47-
apk del --purge \
48-
build-dependencies && \
49-
rm -rf \
50-
/goaccess/* \
51-
/tmp/*
52-
53-
FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.15 as build-stage-arm64v8
54-
55-
RUN \
56-
echo "**** install packages ****" && \
57-
apk add -U --update --no-cache --virtual=build-dependencies \
58-
autoconf \
59-
automake \
60-
build-base \
61-
git \
62-
glib-dev \
63-
libmaxminddb-dev \
64-
ncurses-dev && \
65-
mkdir -p /build && \
66-
mkdir -p /goaccess && \
67-
echo "**** build goaccess ****" && \
68-
git clone --shallow-submodules --recurse-submodules https://github.com/allinurl/goaccess.git /goaccess && cd /goaccess && \
69-
autoreconf -fiv && \
70-
./configure --enable-utf8 --enable-geoip=mmdb && \
71-
make DESTDIR="/build" install && \
72-
echo "**** cleanup ****" && \
73-
apk del --purge \
74-
build-dependencies && \
75-
rm -rf \
76-
/goaccess/* \
77-
/tmp/*
78-
79-
FROM scratch as build-stage-consolidate
80-
81-
COPY --from=build-stage-amd64 /build/ /goaccess/x86_64/
82-
COPY --from=build-stage-arm32v7 /build/ /goaccess/armv7l/
83-
COPY --from=build-stage-arm64v8 /build/ /goaccess/aarch64/
84-
COPY root/ /
85-
861
FROM scratch
872

883
LABEL maintainer="quietsy"
894

905
# copy local files
91-
COPY --from=build-stage-consolidate / /
6+
COPY root/ /

root/dashboard/www/index.php

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,29 +140,37 @@ function GetTemplates() {
140140
$files = "";
141141
$counter = 1;
142142
$conf_locations = array(
143+
".conf" => "https://github.com/linuxserver/docker-swag/blob/master/root/defaults/nginx/",
143144
"subdomain.conf" => "https://github.com/linuxserver/reverse-proxy-confs/blob/master/",
144145
"subfolder.conf" => "https://github.com/linuxserver/reverse-proxy-confs/blob/master/",
145146
"dashboard.subdomain.conf" => "https://github.com/linuxserver/docker-mods/blob/swag-dashboard/root/dashboard/",
147+
"nginx.conf" => "https://github.com/linuxserver/docker-baseimage-alpine-nginx/tree/master/root/defaults/nginx/",
148+
"ssl.conf" => "https://github.com/linuxserver/docker-baseimage-alpine-nginx/tree/master/root/defaults/nginx/",
149+
"default.conf" => "https://github.com/linuxserver/docker-swag/blob/master/root/defaults/nginx/site-confs/",
146150
);
147-
$output = shell_exec("/etc/cont-init.d/85-version-checks");
151+
$output = shell_exec("/etc/s6-overlay/s6-rc.d/init-version-checks/run");
148152

149153
foreach(explode(PHP_EOL, $output) as $line) {
150154
if(substr($line, 0, 1) === "*"){
151155
$tooltip .= str_replace("*", "", $line).PHP_EOL;
152-
} elseif(substr($line, 0, 1) === "/") {
156+
} elseif(str_contains($line, "/config/")) {
153157
$tr_class = ($counter % 2 == 0) ? 'shaded' : '';
154-
$files .= '<tr class="'.$tr_class.'"><td class="left-text"><span class="status-text">'.htmlspecialchars($line).'</span></td>';
155-
$file_name = substr($line, strrpos($line, '/') + 1);
156-
$link = "https://github.com/linuxserver/docker-swag/blob/master/root/defaults/nginx/".$file_name;
158+
$clean_line = htmlspecialchars($line);
159+
list($old_date, $new_date, $path) = explode('', $clean_line);
160+
$old_date = trim($old_date, '│ \n\r\t\v\x00');
161+
$new_date = trim($new_date, '│ \n\r\t\v\x00');
162+
$path = trim($path, '│ \n\r\t\v\x00');
163+
$files .= '<tr class="'.$tr_class.'">';
164+
$files .= '<td class="left-text"><span class="status-text">'.$old_date.'</span></td>';
165+
$files .= '<td class="left-text"><span class="status-text">'.$new_date.'</span></td>';
166+
$files .= '<td class="left-text"><span class="status-text">'.$path.'</span></td>';
167+
$file_name = substr($path, strrpos($path, '/') + 1);
157168
foreach($conf_locations as $key=>$value) {
158169
if (strpos($file_name, $key) !== false) {
159170
$link = $value.$file_name;
160171
}
161-
}
162-
if (strpos($file_name, 'subdomain.conf') !== false or strpos($file_name, 'subfolder.conf') !== false) {
163-
$link .= '.sample';
164172
}
165-
$files .= '<td><a href="'.$link.'"><i class="fas fa-edit"></i></a></td></tr>';
173+
$files .= '<td><a href="'.$link.'.sample"><i class="fas fa-edit"></i></a></td></tr>';
166174
$counter++;
167175
}
168176
}
@@ -174,6 +182,14 @@ function GetTemplates() {
174182
<div>
175183
<h2>Version Updates <i class="fas fa-info-circle" title="{$tooltip}"></i></h2>
176184
<table class="table-hover">
185+
<thead>
186+
<tr>
187+
<td><h3>Old Date</h3></td>
188+
<td><h3>New Date</h3></td>
189+
<td><h3>Path</h3></td>
190+
<td><h3>Link</h3></td>
191+
</tr>
192+
</thead>
177193
<tbody class="tbody-data">
178194
{$files}
179195
</tbody>
@@ -253,7 +269,7 @@ function GetGoaccess() {
253269
endif;
254270

255271
$access_log = file_exists("/dashboard/logs") ? "/dashboard/logs/*.log" : "/config/log/nginx/access.log";
256-
$goaccess = shell_exec("cat $access_log | /usr/local/bin/goaccess -a -o html --config-file=/dashboard/goaccess.conf $geodb -");
272+
$goaccess = shell_exec("cat $access_log | /usr/bin/goaccess -a -o html --config-file=/dashboard/goaccess.conf $geodb -");
257273
$goaccess = str_replace("<title>Server&nbsp;Statistics", "<title>SWAG&nbsp;Dashboard", $goaccess);
258274
$goaccess = str_replace("<h1 class='h-dashboard'>", "<h1>", $goaccess);
259275
$goaccess = str_replace("<i class='fa fa-tachometer'></i>", "<img src='/icon.svg' width='32' height='32'>&nbsp;SWAG&nbsp;", $goaccess);

root/etc/cont-init.d/98-dashboard-config

Lines changed: 0 additions & 30 deletions
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-swag-dashboard-add-package/run

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
echo "**** Applying the SWAG dashboard mod... ****"
44

5-
ARCH=$(uname -m)
6-
if [ -d "/goaccess/${ARCH}" ]; then
7-
echo "**** Installing/updating goaccess ****"
8-
cp -a /goaccess/${ARCH}/* /
9-
rm -rf /goaccess
5+
if ! apk info 2>&1 | grep -q "goaccess"; then
6+
echo "**** Adding goaccess to package install list ****"
7+
echo "goaccess" >> /mod-repo-packages-to-install.list
108
else
11-
echo "**** Goaccess already installed and up to date ****"
9+
echo "**** goaccess already installed, skipping ****"
1210
fi
1311

1412
if ! apk info 2>&1 | grep -q "libmaxminddb"; then

0 commit comments

Comments
 (0)