mirror of
https://github.com/TrezOne/docker-mods-uptime-kuma-timeout-fix.git
synced 2026-06-18 14:23:07 -04:00
Add the swag dashboard mod
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 308 KiB |
@@ -3,9 +3,9 @@ name: Build Image
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
|
||||
env:
|
||||
ENDPOINT: "linuxserver/mods" #don't modify
|
||||
BASEIMAGE: "replace_baseimage" #replace
|
||||
MODNAME: "replace_modname" #replace
|
||||
ENDPOINT: "linuxserver/mods"
|
||||
BASEIMAGE: "swag"
|
||||
MODNAME: "dashboard"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
FROM scratch
|
||||
|
||||
LABEL maintainer="username"
|
||||
LABEL maintainer="quietsy"
|
||||
|
||||
# copy local files
|
||||
COPY root/ /
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
## Buildstage ##
|
||||
FROM ghcr.io/linuxserver/baseimage-alpine:3.12 as buildstage
|
||||
|
||||
RUN \
|
||||
echo "**** install packages ****" && \
|
||||
apk add --no-cache \
|
||||
curl && \
|
||||
echo "**** grab rclone ****" && \
|
||||
mkdir -p /root-layer && \
|
||||
curl -o \
|
||||
/root-layer/rclone.deb -L \
|
||||
"https://downloads.rclone.org/v1.47.0/rclone-v1.47.0-linux-amd64.deb"
|
||||
|
||||
# copy local files
|
||||
COPY root/ /root-layer/
|
||||
|
||||
## Single layer deployed image ##
|
||||
FROM scratch
|
||||
|
||||
LABEL maintainer="username"
|
||||
|
||||
# Add files from buildstage
|
||||
COPY --from=buildstage /root-layer/ /
|
||||
@@ -1,17 +1,11 @@
|
||||
# Rsync - Docker mod for openssh-server
|
||||
# Dashboard Docker mod for SWAG
|
||||
|
||||
This mod adds rsync to openssh-server, to be installed/updated during container start.
|
||||
This mod adds a dashboard to SWAG powered by [Goaccess](https://goaccess.io/).
|
||||
|
||||
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync`
|
||||
# Configuration
|
||||
|
||||
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-rsync|linuxserver/mods:openssh-server-mod2`
|
||||
* Enable the dashboard by copying `/config/nginx/proxy-confs/dashboard.subdomain.conf.sample` to `/config/nginx/proxy-confs/dashboard.subdomain.conf`
|
||||
* Navigate to `dashboard.domain.com` from your LAN
|
||||
|
||||
# Mod creation instructions
|
||||
|
||||
* Fork the repo, create a new branch based on the branch `template`.
|
||||
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
|
||||
* Inspect the `root` folder contents. Edit, add and remove as necessary.
|
||||
* Edit this readme with pertinent info, delete these instructions.
|
||||
* Finally edit the `.github/workflows/BuildImage.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`.
|
||||
* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch.
|
||||
* Submit PR against the branch created by the team.
|
||||
# Example
|
||||

|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
## Version 2022/01/12
|
||||
# Make sure that your dns has a cname set for dashboard
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
server_name dashboard.*;
|
||||
|
||||
root /dashboard/www;
|
||||
index index.php;
|
||||
|
||||
include /config/nginx/ssl.conf;
|
||||
|
||||
client_max_body_size 0;
|
||||
|
||||
# enable for ldap auth, fill in ldap details in ldap.conf
|
||||
#include /config/nginx/ldap.conf;
|
||||
|
||||
# enable for Authelia
|
||||
#include /config/nginx/authelia-server.conf;
|
||||
|
||||
location / {
|
||||
# enable the next two lines for http auth
|
||||
#auth_basic "Restricted";
|
||||
#auth_basic_user_file /config/nginx/.htpasswd;
|
||||
|
||||
# enable the next two lines for ldap auth
|
||||
#auth_request /auth;
|
||||
#error_page 401 =200 /ldaplogin;
|
||||
|
||||
# enable for Authelia
|
||||
#include /config/nginx/authelia-location.conf;
|
||||
|
||||
allow 10.0.0.0/8;
|
||||
allow 172.16.0.0/12;
|
||||
allow 192.168.0.0/16;
|
||||
deny all;
|
||||
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
include /etc/nginx/fastcgi_params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import collections
|
||||
import concurrent.futures
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import requests
|
||||
import urllib3
|
||||
|
||||
|
||||
def find_apps():
|
||||
apps = {}
|
||||
file_paths = glob.glob("/config/nginx/**/*", recursive=True)
|
||||
for file_path in file_paths:
|
||||
if not os.path.isfile(file_path):
|
||||
continue
|
||||
file = open(file_path, "r")
|
||||
content = file.read()
|
||||
results = re.finditer(r"(\s+)set \$upstream_app (?P<name>\S+?);(\s+)set \$upstream_port (?P<port>\d+);\n(\s+)set \$upstream_proto (?P<proto>\w+);", content)
|
||||
for result in results:
|
||||
params = result.groupdict()
|
||||
app = f"{params['proto']}://{params['name']}:{params['port']}"
|
||||
if app not in apps:
|
||||
apps[app] = set()
|
||||
if not file_path.endswith(".sample"):
|
||||
apps[app].add(file_path)
|
||||
return apps
|
||||
|
||||
|
||||
def is_available(url):
|
||||
try:
|
||||
ans = requests.head(url, timeout=5, verify=False)
|
||||
return ans.status_code < 404
|
||||
except:
|
||||
return False
|
||||
|
||||
urllib3.disable_warnings()
|
||||
apps = find_apps()
|
||||
discovered_apps = collections.defaultdict(dict)
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor:
|
||||
futures = {executor.submit(is_available, app): app for app in apps.keys()}
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
app = futures[future]
|
||||
if not future.result() and not apps[app]:
|
||||
continue
|
||||
discovered_apps[app]["status"] = future.result()
|
||||
discovered_apps[app]["locations"] = list(apps[app])
|
||||
|
||||
print(json.dumps(discovered_apps, sort_keys=True))
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
function GetStatus() {
|
||||
$output = shell_exec("python3 /dashboard/swag-status.py");
|
||||
$results = json_decode($output);
|
||||
$status = "";
|
||||
$index = 0;
|
||||
foreach($results as $result => $data){
|
||||
$tr_class = ($index % 2 == 0) ? 'shaded' : '';
|
||||
$status .= '<tr class="'.$tr_class.'"><td><span class="status-text">'.$result.'</span></td><td class="align-td">';
|
||||
if ($data->status == 1) {
|
||||
$status .= '<span class="green-circle circle-empty"></span>';
|
||||
} else {
|
||||
$status .= '<span class="red-circle"></span>';
|
||||
}
|
||||
$status .= '</td><td class="align-td">';
|
||||
if (!empty($data->locations)) {
|
||||
$locations = $data->locations;
|
||||
$location = implode(",", $locations);
|
||||
$status .= '<span class="green-circle circle-empty"></span></td><td><span class="status-text">'.$location.'</span></td>';
|
||||
} else {
|
||||
$status .= '<span class="red-circle"></span></td><td></td>';
|
||||
}
|
||||
$status .= '</tr>';
|
||||
$index++;
|
||||
}
|
||||
return <<<HTML
|
||||
<style type="text/css">
|
||||
.status-div {
|
||||
display: inline-block;
|
||||
}
|
||||
.status-text {
|
||||
font-size: 15px;
|
||||
}
|
||||
td {
|
||||
padding: 6px;
|
||||
text-align: center;
|
||||
}
|
||||
.align-td {
|
||||
text-align: center;
|
||||
}
|
||||
.green-circle {
|
||||
padding: 2px 10px;
|
||||
border-radius: 100%;
|
||||
background-color: green;
|
||||
border: 1px solid black;
|
||||
}
|
||||
.red-circle {
|
||||
padding: 2px 10px;
|
||||
border-radius: 50%;
|
||||
background-color: red;
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
<h1>Welcome to your <a target="_blank" href="https://github.com/linuxserver/docker-swag">SWAG</a> instance</h1>
|
||||
<h4>A webserver and reverse proxy solution brought to you by <a target="_blank" href="https://www.linuxserver.io/">linuxserver.io</a> with php support and a built-in Certbot client.</h4>
|
||||
<h4>We have an article on how to use swag here: <a target="_blank" href="https://docs.linuxserver.io/general/swag">docs.linuxserver.io</a></h4>
|
||||
<h4>For help and support, please visit: <a target="_blank" href="https://www.linuxserver.io/support">linuxserver.io/support</a></h4>
|
||||
<div class="wrap-panel status-div">
|
||||
<div>
|
||||
<table class="table-hover">
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><h3>Application</h3></td>
|
||||
<td><h3>Available</h3></td>
|
||||
<td><h3>Proxied</h3></td>
|
||||
<td><h3>Location</h3></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="tbody-data">
|
||||
{$status}
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
</div>
|
||||
<br/>
|
||||
</div>
|
||||
<div class="wrap-general">
|
||||
HTML;
|
||||
}
|
||||
$access = shell_exec("cat /config/log/nginx/access.log | goaccess -a -o html --html-prefs='{\"theme\":\"darkGray\"}' --log-format COMBINED --geoip-database=/config/geoip2db/GeoLite2-City.mmdb -");
|
||||
$status = GetStatus();
|
||||
echo str_replace("<div class='wrap-general'>", $status, $access);
|
||||
?>
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
echo "Applying the SWAG dashboard mod..."
|
||||
|
||||
apk add --no-cache --upgrade goaccess
|
||||
cp -f /dashboard/dashboard.subdomain.conf.sample /config/nginx/proxy-confs/
|
||||
|
||||
echo "Applied the SWAG dashboard mod"
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# Determine if setup is needed
|
||||
if [ ! -f /usr/local/lib/python***/dist-packages/sshuttle ] && \
|
||||
[ -f /usr/bin/apt ]; then
|
||||
## Ubuntu
|
||||
apt-get update
|
||||
apt-get install --no-install-recommends -y \
|
||||
iptables \
|
||||
openssh-client \
|
||||
python3 \
|
||||
python3-pip
|
||||
pip3 install sshuttle
|
||||
fi
|
||||
if [ ! -f /usr/lib/python***/site-packages/sshuttle ] && \
|
||||
[ -f /sbin/apk ]; then
|
||||
# Alpine
|
||||
apk add --no-cache \
|
||||
iptables \
|
||||
openssh \
|
||||
py3-pip \
|
||||
python3
|
||||
pip3 install sshuttle
|
||||
fi
|
||||
|
||||
chown -R root:root /root
|
||||
chmod -R 600 /root/.ssh
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
sshuttle --dns --remote root@${HOST}:${PORT} 0/0 -x 172.17.0.0/16
|
||||
Reference in New Issue
Block a user