From a1c674b2b3e6183917241caab7c34399fcf73846 Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 26 Dec 2022 16:04:10 +0100 Subject: [PATCH 01/19] Added README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..6b6aa1b --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Main Page Repository + +Release URL: (www.neshweb.net)[https://www.neshweb.net] +Development URL: (wip.neshweb.net)[https://wip.neshweb.net] \ No newline at end of file From d4f1dd63e4009bf042a323409a29569f06a74d08 Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 26 Dec 2022 15:05:54 +0000 Subject: [PATCH 02/19] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6b6aa1b..844adaf 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Main Page Repository -Release URL: (www.neshweb.net)[https://www.neshweb.net] -Development URL: (wip.neshweb.net)[https://wip.neshweb.net] \ No newline at end of file +Release URL: [www.neshweb.net](https://www.neshweb.net) + +Development URL: [wip.neshweb.net](https://wip.neshweb.net) From 684a4a5435a9d6b3f2736ef2756e2ade2c5d112a Mon Sep 17 00:00:00 2001 From: Neshura Date: Wed, 18 Jan 2023 10:22:49 +0000 Subject: [PATCH 03/19] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a90b352..9a1c765 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,7 @@ RUN yarn build FROM node:18-alpine AS runner LABEL author="neshura@proton.me" -WORKDIR /usr/src/app +WORKDIR /app ENV NODE_ENV production From 28cd2ba8b1913c6e1212c09d268d21f37279c0a8 Mon Sep 17 00:00:00 2001 From: Neshura Date: Wed, 18 Jan 2023 10:32:28 +0000 Subject: [PATCH 04/19] Test changed import for pages.json --- pages/services.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/services.tsx b/pages/services.tsx index 9a24a5a..97a355a 100644 --- a/pages/services.tsx +++ b/pages/services.tsx @@ -4,7 +4,7 @@ import Dockerode from 'dockerode'; import { ReactElement } from 'react' import useSWR from 'swr'; import { CardContentService, PageContentBox, PageDescription, PageTitle } from '../components/styles/content'; -import ServiceList from '../public/pages.json'; +import ServiceList from '/data/pages.json'; const fetcher = (url: string) => fetch(url).then((res) => res.json()) @@ -184,4 +184,4 @@ function useServices() { }; } -export default Services \ No newline at end of file +export default Services From 7ec531bd42062d5c3f1515c855c5563de9e934e0 Mon Sep 17 00:00:00 2001 From: Neshura Date: Wed, 18 Jan 2023 10:33:10 +0000 Subject: [PATCH 05/19] add pages.json in public/data/ --- public/data/pages.json | 160 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 public/data/pages.json diff --git a/public/data/pages.json b/public/data/pages.json new file mode 100644 index 0000000..f7378c9 --- /dev/null +++ b/public/data/pages.json @@ -0,0 +1,160 @@ +{ + "services": [ + { + "name": "Nextcloud", + "icon": "/icons/nextcloud-logo.svg", + "href": "https://nextcloud.neshweb.net/", + "desc": "Self-hosted Cloud Storage Service", + "warn": "Note: Registration requires approval", + "type": "docker", + "docker_container_name": "nextcloud", + "location": "brr7-4800u" + }, + { + "name": "Komga", + "icon": "/icons/komga-logo.png", + "href": "https://komga.neshweb.net/", + "desc": "Self-hosted Comic Library", + "warn": "Note: Registration only via Admin", + "type": "docker", + "docker_container_name": "komga", + "location": "brr7-4800u" + }, + { + "name": "Calibre Web", + "icon": "/icons/calibre-logo.ico", + "href": "https://calibre.neshweb.net/", + "desc": "Self-hosted Ebook Library Service", + "warn": "Note: Registration only via Admin", + "type": "app", + "location": "brr7-4800u" + }, + { + "name": "PeerTube", + "icon": "/icons/peertube-logo.svg", + "href": "https://tube.neshweb.net/", + "desc": "Self-hosted PeerTube Instance", + "warn": "Note: Registration only via Admin", + "type": "docker", + "docker_container_name": "peertube", + "location": "brr7-4800u" + }, + { + "name": "Mastodon", + "icon": "/icons/mastodon-logo.svg", + "href": "https://mastodon.neshweb.net/", + "desc": "Self-hosted Mastodon Instance", + "warn": "Note: Registration requires approval", + "type": "docker", + "docker_container_name": "mastodon-web", + "location": "brr7-4800u" + }, + { + "name": "File Browser", + "href": "https://files.neshweb.net/", + "desc": "Server File Browser", + "warn": "Note: Registration only via Admin", + "type": "docker", + "docker_container_name": "filebrowser", + "location": "brr7-4800u" + }, + { + "name": "Jellyfin", + "icon": "/icons/jellyfin-logo.svg", + "href": "https://jellyfin.neshweb.net/", + "desc": "Open-Source, Self-Hosted Media Platform", + "warn": "Note: Registration only via Admin", + "type": "docker", + "docker_container_name": "jellyfin", + "location": "brr7-4800u" + }, + { + "name": "Navidrome", + "icon": "/icons/navidrome-logo.png", + "href": "https://navidrome.neshweb.net/", + "desc": "Open-Source, Self-Hosted Music Streaming Platform", + "warn": "Note: Registration only via Admin", + "type": "docker", + "docker_container_name": "navidrome", + "location": "brr7-4800u" + }, + { + "name": "Picard", + "href": "https://picard.neshweb.net/", + "desc": "MP3 Tagger", + "warn": "Note: Access only via Admin", + "type": "docker", + "docker_container_name": "picard", + "location": "brr7-4800u" + }, + { + "name": "Gitlab", + "icon": "/icons/gitlab-logo.svg", + "href": "https://gitlab.neshweb.net/", + "desc": "Self-hosted Git Service", + "warn": "Note: Registration only via Admin", + "type": "docker", + "docker_container_name": "gitlab", + "location": "brr7-4800u" + }, + { + "name": "Portainer", + "icon": "/icons/portainer-logo.png", + "href": "https://portainer.neshweb.net/", + "desc": "Docker Container Manager", + "warn": "Note: Admin Only", + "type": "docker", + "docker_container_name": "portainer", + "location": "brr7-4800u" + }, + { + "name": "Nginx Proxy Manager", + "icon": "/icons/npm-logo.png", + "href": "https://nginx.neshweb.net/", + "desc": "Web-based Nginx Proxy Manager", + "warn": "Note: Admin Only", + "type": "docker", + "docker_container_name": "nginx-prox", + "location": "brr7-4800u" + }, + { + "name": "Grafana", + "icon": "/icons/grafana-logo.svg", + "href": "https://monitoring.neshweb.net/", + "desc": "Server Monitoring Utility", + "warn": "Note: Admin Only", + "type": "docker", + "docker_container_name": "grafana", + "location": "brr7-4800u" + }, + { + "name": "Matomo", + "href": "https://tracking.neshweb.net/", + "desc": "Traffic Tracking Utility", + "warn": "Note: Admin Only", + "type": "docker", + "docker_container_name": "matomo-web", + "location": "brr7-4800u" + } + ], + "games": { + "minecraft": { + "name": "Minecraft", + "icon": "/icons/minecraft-logo.png", + "href": "https://minecraft.neshweb.net/", + "desc": "View all currently available Minecraft Servers and their mods" + }, + "ready_or_not": { + "name": "Ready or Not", + "icon": "/icons/ron-logo.png", + "href": "https://readyornot.neshweb.net/", + "desc": "Collection of Floor Plans for the Game 'Ready or Not'" + }, + "zomboid": { + "name": "Zomboid", + "icon": "/icons/zomboid-logo.png", + "ip": "91.13.248.30", + "status": "Online" + } + } +} From 34b038e4d14894bd8a5e0f9c0b66cecf63df10cb Mon Sep 17 00:00:00 2001 From: Neshura Date: Wed, 18 Jan 2023 10:36:40 +0000 Subject: [PATCH 06/19] Update services.tsx --- pages/services.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/services.tsx b/pages/services.tsx index 97a355a..0d754e3 100644 --- a/pages/services.tsx +++ b/pages/services.tsx @@ -4,7 +4,7 @@ import Dockerode from 'dockerode'; import { ReactElement } from 'react' import useSWR from 'swr'; import { CardContentService, PageContentBox, PageDescription, PageTitle } from '../components/styles/content'; -import ServiceList from '/data/pages.json'; +import ServiceList from '/public/data/pages.json'; const fetcher = (url: string) => fetch(url).then((res) => res.json()) From 1f223677c638635b6953b0e75498daf94b7ddc78 Mon Sep 17 00:00:00 2001 From: Neshura Date: Wed, 18 Jan 2023 10:39:39 +0000 Subject: [PATCH 07/19] Update services.tsx --- pages/services.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/services.tsx b/pages/services.tsx index 0d754e3..a42efab 100644 --- a/pages/services.tsx +++ b/pages/services.tsx @@ -4,7 +4,7 @@ import Dockerode from 'dockerode'; import { ReactElement } from 'react' import useSWR from 'swr'; import { CardContentService, PageContentBox, PageDescription, PageTitle } from '../components/styles/content'; -import ServiceList from '/public/data/pages.json'; +import ServiceList from '../public/data/pages.json'; const fetcher = (url: string) => fetch(url).then((res) => res.json()) From 6ed9341887aea296711aa0936ef45d0216eb66ad Mon Sep 17 00:00:00 2001 From: Neshura Date: Wed, 18 Jan 2023 10:47:37 +0000 Subject: [PATCH 08/19] Update pages.json --- public/data/pages.json | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/public/data/pages.json b/public/data/pages.json index f7378c9..d82c7a3 100644 --- a/public/data/pages.json +++ b/public/data/pages.json @@ -3,17 +3,27 @@ { "name": "Nextcloud", "icon": "/icons/nextcloud-logo.svg", - "href": "https://nextcloud.neshweb.net/", + "href": "https://nextcloud.neshweb.net", "desc": "Self-hosted Cloud Storage Service", "warn": "Note: Registration requires approval", "type": "docker", "docker_container_name": "nextcloud", "location": "brr7-4800u" }, + { + "name": "Kavita", + "icon": "/icons/kavita-logo.svg", + "href": "https://kavita.neshweb.net", + "desc": "Self-hosted Manga Library", + "warn": "Registration via Admin invite", + "type": "docker", + "docker_container_name": "kavita", + "location": "brr7-4800u" + }, { "name": "Komga", "icon": "/icons/komga-logo.png", - "href": "https://komga.neshweb.net/", + "href": "https://komga.neshweb.net", "desc": "Self-hosted Comic Library", "warn": "Note: Registration only via Admin", "type": "docker", @@ -32,7 +42,7 @@ { "name": "PeerTube", "icon": "/icons/peertube-logo.svg", - "href": "https://tube.neshweb.net/", + "href": "https://tube.neshweb.net", "desc": "Self-hosted PeerTube Instance", "warn": "Note: Registration only via Admin", "type": "docker", @@ -42,7 +52,7 @@ { "name": "Mastodon", "icon": "/icons/mastodon-logo.svg", - "href": "https://mastodon.neshweb.net/", + "href": "https://mastodon.neshweb.net", "desc": "Self-hosted Mastodon Instance", "warn": "Note: Registration requires approval", "type": "docker", @@ -155,6 +165,14 @@ "icon": "/icons/zomboid-logo.png", "ip": "91.13.248.30", "status": "Online" + }, + "factorio": { + "name": "Factorio", + "status": "Online" + }, + "space_engineers": { + "name": "Space Engineers", + "status": "Online" } } } From b28cb684f6bad55899bbb94c64c2172ea3d7b965 Mon Sep 17 00:00:00 2001 From: Neshura Date: Fri, 27 Jan 2023 00:12:54 +0100 Subject: [PATCH 09/19] Updated Pages Added vaultwarden --- public/data/pages.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/data/pages.json b/public/data/pages.json index d82c7a3..57aff98 100644 --- a/public/data/pages.json +++ b/public/data/pages.json @@ -59,6 +59,17 @@ "docker_container_name": "mastodon-web", "location": "brr7-4800u" }, + + { + "name": "Vaultwarden", + "icon": "/icons/vaultwarden-logo.svg", + "href": "https://vault.neshweb.net", + "desc": "Self-hosted Password Manager", + "warn": "Note: Invite only", + "type": "docker", + "docker_container_name": "vaultwarden", + "location": "brr7-4800u" + }, { "name": "File Browser", "href": "https://files.neshweb.net/", From 21a099a02b8ea3fa294806bea75e45ce5cf234d1 Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 6 Mar 2023 18:22:51 +0100 Subject: [PATCH 10/19] Changed Port to 8001 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index dbf4333..55bf653 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "0.2.0", "private": true, "scripts": { - "dev:debug": "NODE_OPTIONS='--inspect' next dev -p 4040", - "dev": "next dev -p 4040", + "dev:debug": "NODE_OPTIONS='--inspect' next dev -p 8001", + "dev": "next dev -p 8001", "build": "next build", "start": "next start", "lint": "next lint" From e47e4e7a58cf34f3c94ee04dc83bbf0e45e8f20f Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 6 Mar 2023 18:39:45 +0100 Subject: [PATCH 11/19] Changed Port for Production --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 55bf653..6bf31b6 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dev:debug": "NODE_OPTIONS='--inspect' next dev -p 8001", "dev": "next dev -p 8001", "build": "next build", - "start": "next start", + "start": "next start -p 8001", "lint": "next lint" }, "dependencies": { From 4d1393d8a0be569505739c718a88c7a5f75720a2 Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 6 Mar 2023 18:47:22 +0100 Subject: [PATCH 12/19] Change Host to IPv6 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6bf31b6..bc21cd6 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,10 @@ "version": "0.2.0", "private": true, "scripts": { - "dev:debug": "NODE_OPTIONS='--inspect' next dev -p 8001", - "dev": "next dev -p 8001", + "dev:debug": "NODE_OPTIONS='--inspect' next dev -H :: -p 8001", + "dev": "next dev -H :: -p 8001", "build": "next build", - "start": "next start -p 8001", + "start": "next start -H :: -p 8001", "lint": "next lint" }, "dependencies": { From 2eb8d03cd63bee08d9792032b9acf8c7e29d1d91 Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 14 Mar 2023 20:35:05 +0100 Subject: [PATCH 13/19] Remove Dockerfile --- Dockerfile | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 9a1c765..0000000 --- a/Dockerfile +++ /dev/null @@ -1,45 +0,0 @@ -## INIT STEP -# Install dependencies only when needed -FROM node:18-alpine AS deps - -RUN apk add --no-cache libc6-compat -WORKDIR /app - -# Copy the files needed to install deps -COPY package.json yarn.lock ./ -RUN yarn install --frozen-lockfile - -## BUILD STEP -# Rebuild the source code only when needed -FROM node:18-alpine AS builder - -WORKDIR /app - -# Copy node_modules installed by the deps step -COPY --from=deps /app/node_modules ./node_modules - -COPY . . - -RUN yarn build - -## RUN STEP -FROM node:18-alpine AS runner - -LABEL author="neshura@proton.me" -WORKDIR /app - -ENV NODE_ENV production - -COPY --from=builder /app/public ./public -COPY --from=builder /app/node_modules ./node_modules - -# Automatically leverage output traces to reduce image size -# https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder /app/.next/standalone ./ -COPY --from=builder /app/.next/static ./.next/static - -# expose port 3000 -ENV PORT 3000 -EXPOSE 3000 - -CMD [ "yarn", "start" ] From 2dc752734b5ac651c9595d6b9dc9bee3441d2774 Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 14 Mar 2023 21:21:40 +0100 Subject: [PATCH 14/19] Update About content, change "Games" to "Server" --- pages/about.tsx | 3 ++- pages/{games.tsx => servers.tsx} | 2 +- public/data/navbar.json | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) rename pages/{games.tsx => servers.tsx} (93%) diff --git a/pages/about.tsx b/pages/about.tsx index 4874605..89768c9 100644 --- a/pages/about.tsx +++ b/pages/about.tsx @@ -14,7 +14,8 @@ export default function About() { About - This website is primarily for managing my game servers in one spot + I'm currently expanding what I want to do with this site. + Currently a list of available services and servers is available via the respective navbar entry. ) diff --git a/pages/games.tsx b/pages/servers.tsx similarity index 93% rename from pages/games.tsx rename to pages/servers.tsx index f57ba1b..1acfe95 100644 --- a/pages/games.tsx +++ b/pages/servers.tsx @@ -9,7 +9,7 @@ function Servers() { return ( <> - Neshweb - Games + Neshweb - Servers diff --git a/public/data/navbar.json b/public/data/navbar.json index 613e960..cf2227b 100644 --- a/public/data/navbar.json +++ b/public/data/navbar.json @@ -9,8 +9,8 @@ "href": "/about" }, { - "name": "Games", - "href": "/games" + "name": "Servers", + "href": "/servers" }, { "name": "Services", From 0a841d0b5875f24873b0f2d792ebbfa14d5859af Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 14 Mar 2023 21:32:15 +0100 Subject: [PATCH 15/19] remove Matomo Tracking --- components/layout.tsx | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/components/layout.tsx b/components/layout.tsx index 6a2f966..9205de4 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -48,24 +48,6 @@ const Layout = ({ children }: { children: React.ReactNode }) => { defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "826fc083aa86417890c0ceb3e0a597fa"}'> -
From c77fc441721d09dfa6da6ece465222c7875a83b0 Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 14 Mar 2023 21:32:43 +0100 Subject: [PATCH 16/19] Add 'private' dir to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 67d0346..3751439 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ yarn-error.log* # production /build/ /data/ -/confs/ \ No newline at end of file +/confs/ +/private/ \ No newline at end of file From a1bf08ddced692a5ee866b095f596248273d63b5 Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 14 Mar 2023 22:13:49 +0100 Subject: [PATCH 17/19] Switched over to using Docker API ToDo: Change location to actual location --- interfaces/CardTypes.ts | 1 + interfaces/DockerStatus.ts | 9 +++++++++ pages/api/containers.tsx | 26 ++++++++++++++++++++------ pages/services.tsx | 11 ++++++----- 4 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 interfaces/DockerStatus.ts diff --git a/interfaces/CardTypes.ts b/interfaces/CardTypes.ts index aabe411..bae386c 100644 --- a/interfaces/CardTypes.ts +++ b/interfaces/CardTypes.ts @@ -32,6 +32,7 @@ export enum Status { export enum ServiceLocation { brr7_4800u = "brr7-4800u", + tower_0 = "tower-0", other = "" } diff --git a/interfaces/DockerStatus.ts b/interfaces/DockerStatus.ts new file mode 100644 index 0000000..b3bc696 --- /dev/null +++ b/interfaces/DockerStatus.ts @@ -0,0 +1,9 @@ +export interface DockerInfo { + name: string, + status: DockerStatus, + id: string +} + +export enum DockerStatus { + running = "running", +} diff --git a/pages/api/containers.tsx b/pages/api/containers.tsx index 6f75e6e..d83f405 100644 --- a/pages/api/containers.tsx +++ b/pages/api/containers.tsx @@ -1,13 +1,27 @@ import Docker from 'dockerode' +import ApiSecret from '../../private/portainer_api_secret.json' +import { DockerInfo } from '../../interfaces/DockerStatus'; export default async function ContainersAPI(req: any, res: any) { + const token = JSON.parse(JSON.stringify(ApiSecret.token)); + try { - const options = { - socketPath: '/var/run/docker.sock', - path: '/v1.41/containers/json' - }; - var docker = new Docker({ socketPath: options.socketPath }); - const list = await docker.listContainers({ all: true }) + const res1 = await fetch('https://portainer.neshweb.net/api/endpoints/2/docker/containers/json', { + method: "GET", + headers: {"X-API-Key": token} + }); + + const unparsed = await res1.json(); + let list: DockerInfo[] = []; + + unparsed.forEach((entry: any) => { + let newEntry = {} as DockerInfo; + + newEntry.name = entry.Names[0].substring(1); + newEntry.status = entry.State; + newEntry.id = entry.Id; + list.push(newEntry); + }); res.status(200).json(list); } diff --git a/pages/services.tsx b/pages/services.tsx index a42efab..8793aba 100644 --- a/pages/services.tsx +++ b/pages/services.tsx @@ -5,6 +5,7 @@ import { ReactElement } from 'react' import useSWR from 'swr'; import { CardContentService, PageContentBox, PageDescription, PageTitle } from '../components/styles/content'; import ServiceList from '../public/data/pages.json'; +import { DockerInfo } from '../interfaces/DockerStatus'; const fetcher = (url: string) => fetch(url).then((res) => res.json()) @@ -56,7 +57,7 @@ function Services() { ) } -async function getStatus(entry: Service, containers: Dockerode.ContainerInfo[]) { +async function getStatus(entry: Service, containers: DockerInfo[]) { // Currently the only location supporting different fetching depending on type is brr7-4800u // Others to follow but low prio as this is currently the only location used @@ -93,14 +94,14 @@ async function getStatus(entry: Service, containers: Dockerode.ContainerInfo[]) for (let i = 0; i < containers.length; i++) { const container = containers[i]; // Docker API returns container names with / prepended - if (containers[i].Names.includes("/" + entry.docker_container_name)) { + if (container.name === entry.docker_container_name) { // so far only "running" is properly implemented, mroe cases to follow as needed - switch (container.State) { + switch (container.status) { case "running": entry.status = Status.online; break; default: - console.log("Container Status " + container.State + " has no case implemented"); + console.log("Container Status " + container.status + " has no case implemented"); entry.status = Status.offline; } found = true; @@ -162,7 +163,7 @@ async function getStatus(entry: Service, containers: Dockerode.ContainerInfo[]) return entry; } -const fetchFullDataArray = (containerData: Dockerode.ContainerInfo[], dataSet: Service[]) => { +const fetchFullDataArray = (containerData: DockerInfo[], dataSet: Service[]) => { const fetchStatus = (entry: Service) => getStatus(entry, containerData); return Promise.all(dataSet.map(fetchStatus)); } From 26f9ac2099027bcad976d13d5903658168159912 Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 14 Mar 2023 22:32:42 +0100 Subject: [PATCH 18/19] Move pages.conf to public folder --- public/data/pages.json | 61 ++++++---------- public/pages.json | 160 ----------------------------------------- 2 files changed, 21 insertions(+), 200 deletions(-) delete mode 100644 public/pages.json diff --git a/public/data/pages.json b/public/data/pages.json index 57aff98..32e48a2 100644 --- a/public/data/pages.json +++ b/public/data/pages.json @@ -8,7 +8,7 @@ "warn": "Note: Registration requires approval", "type": "docker", "docker_container_name": "nextcloud", - "location": "brr7-4800u" + "location": "tower-0" }, { "name": "Kavita", @@ -18,17 +18,7 @@ "warn": "Registration via Admin invite", "type": "docker", "docker_container_name": "kavita", - "location": "brr7-4800u" - }, - { - "name": "Komga", - "icon": "/icons/komga-logo.png", - "href": "https://komga.neshweb.net", - "desc": "Self-hosted Comic Library", - "warn": "Note: Registration only via Admin", - "type": "docker", - "docker_container_name": "komga", - "location": "brr7-4800u" + "location": "tower-0" }, { "name": "Calibre Web", @@ -36,8 +26,9 @@ "href": "https://calibre.neshweb.net/", "desc": "Self-hosted Ebook Library Service", "warn": "Note: Registration only via Admin", - "type": "app", - "location": "brr7-4800u" + "type": "docker", + "docker_container_name": "calibre-web", + "location": "tower-0" }, { "name": "PeerTube", @@ -47,7 +38,7 @@ "warn": "Note: Registration only via Admin", "type": "docker", "docker_container_name": "peertube", - "location": "brr7-4800u" + "location": "tower-0" }, { "name": "Mastodon", @@ -57,7 +48,7 @@ "warn": "Note: Registration requires approval", "type": "docker", "docker_container_name": "mastodon-web", - "location": "brr7-4800u" + "location": "tower-0" }, { @@ -68,7 +59,7 @@ "warn": "Note: Invite only", "type": "docker", "docker_container_name": "vaultwarden", - "location": "brr7-4800u" + "location": "tower-0" }, { "name": "File Browser", @@ -77,7 +68,7 @@ "warn": "Note: Registration only via Admin", "type": "docker", "docker_container_name": "filebrowser", - "location": "brr7-4800u" + "location": "tower-0" }, { "name": "Jellyfin", @@ -87,7 +78,7 @@ "warn": "Note: Registration only via Admin", "type": "docker", "docker_container_name": "jellyfin", - "location": "brr7-4800u" + "location": "tower-0" }, { "name": "Navidrome", @@ -97,7 +88,7 @@ "warn": "Note: Registration only via Admin", "type": "docker", "docker_container_name": "navidrome", - "location": "brr7-4800u" + "location": "tower-0" }, { "name": "Picard", @@ -106,7 +97,7 @@ "warn": "Note: Access only via Admin", "type": "docker", "docker_container_name": "picard", - "location": "brr7-4800u" + "location": "tower-0" }, { "name": "Gitlab", @@ -116,7 +107,7 @@ "warn": "Note: Registration only via Admin", "type": "docker", "docker_container_name": "gitlab", - "location": "brr7-4800u" + "location": "tower-0" }, { "name": "Portainer", @@ -126,7 +117,7 @@ "warn": "Note: Admin Only", "type": "docker", "docker_container_name": "portainer", - "location": "brr7-4800u" + "location": "tower-0" }, { "name": "Nginx Proxy Manager", @@ -136,26 +127,16 @@ "warn": "Note: Admin Only", "type": "docker", "docker_container_name": "nginx-prox", - "location": "brr7-4800u" + "location": "tower-0" }, { - "name": "Grafana", - "icon": "/icons/grafana-logo.svg", - "href": "https://monitoring.neshweb.net/", - "desc": "Server Monitoring Utility", + "name": "Proxmox", + "icon": "/icons/proxmox-logo.png", + "href": "https://proxmox.neshweb.net/", + "desc": "Hypervisor Webinterface", "warn": "Note: Admin Only", - "type": "docker", - "docker_container_name": "grafana", - "location": "brr7-4800u" - }, - { - "name": "Matomo", - "href": "https://tracking.neshweb.net/", - "desc": "Traffic Tracking Utility", - "warn": "Note: Admin Only", - "type": "docker", - "docker_container_name": "matomo-web", - "location": "brr7-4800u" + "type": "app", + "location": "" } ], "games": { diff --git a/public/pages.json b/public/pages.json deleted file mode 100644 index f7378c9..0000000 --- a/public/pages.json +++ /dev/null @@ -1,160 +0,0 @@ -{ - "services": [ - { - "name": "Nextcloud", - "icon": "/icons/nextcloud-logo.svg", - "href": "https://nextcloud.neshweb.net/", - "desc": "Self-hosted Cloud Storage Service", - "warn": "Note: Registration requires approval", - "type": "docker", - "docker_container_name": "nextcloud", - "location": "brr7-4800u" - }, - { - "name": "Komga", - "icon": "/icons/komga-logo.png", - "href": "https://komga.neshweb.net/", - "desc": "Self-hosted Comic Library", - "warn": "Note: Registration only via Admin", - "type": "docker", - "docker_container_name": "komga", - "location": "brr7-4800u" - }, - { - "name": "Calibre Web", - "icon": "/icons/calibre-logo.ico", - "href": "https://calibre.neshweb.net/", - "desc": "Self-hosted Ebook Library Service", - "warn": "Note: Registration only via Admin", - "type": "app", - "location": "brr7-4800u" - }, - { - "name": "PeerTube", - "icon": "/icons/peertube-logo.svg", - "href": "https://tube.neshweb.net/", - "desc": "Self-hosted PeerTube Instance", - "warn": "Note: Registration only via Admin", - "type": "docker", - "docker_container_name": "peertube", - "location": "brr7-4800u" - }, - { - "name": "Mastodon", - "icon": "/icons/mastodon-logo.svg", - "href": "https://mastodon.neshweb.net/", - "desc": "Self-hosted Mastodon Instance", - "warn": "Note: Registration requires approval", - "type": "docker", - "docker_container_name": "mastodon-web", - "location": "brr7-4800u" - }, - { - "name": "File Browser", - "href": "https://files.neshweb.net/", - "desc": "Server File Browser", - "warn": "Note: Registration only via Admin", - "type": "docker", - "docker_container_name": "filebrowser", - "location": "brr7-4800u" - }, - { - "name": "Jellyfin", - "icon": "/icons/jellyfin-logo.svg", - "href": "https://jellyfin.neshweb.net/", - "desc": "Open-Source, Self-Hosted Media Platform", - "warn": "Note: Registration only via Admin", - "type": "docker", - "docker_container_name": "jellyfin", - "location": "brr7-4800u" - }, - { - "name": "Navidrome", - "icon": "/icons/navidrome-logo.png", - "href": "https://navidrome.neshweb.net/", - "desc": "Open-Source, Self-Hosted Music Streaming Platform", - "warn": "Note: Registration only via Admin", - "type": "docker", - "docker_container_name": "navidrome", - "location": "brr7-4800u" - }, - { - "name": "Picard", - "href": "https://picard.neshweb.net/", - "desc": "MP3 Tagger", - "warn": "Note: Access only via Admin", - "type": "docker", - "docker_container_name": "picard", - "location": "brr7-4800u" - }, - { - "name": "Gitlab", - "icon": "/icons/gitlab-logo.svg", - "href": "https://gitlab.neshweb.net/", - "desc": "Self-hosted Git Service", - "warn": "Note: Registration only via Admin", - "type": "docker", - "docker_container_name": "gitlab", - "location": "brr7-4800u" - }, - { - "name": "Portainer", - "icon": "/icons/portainer-logo.png", - "href": "https://portainer.neshweb.net/", - "desc": "Docker Container Manager", - "warn": "Note: Admin Only", - "type": "docker", - "docker_container_name": "portainer", - "location": "brr7-4800u" - }, - { - "name": "Nginx Proxy Manager", - "icon": "/icons/npm-logo.png", - "href": "https://nginx.neshweb.net/", - "desc": "Web-based Nginx Proxy Manager", - "warn": "Note: Admin Only", - "type": "docker", - "docker_container_name": "nginx-prox", - "location": "brr7-4800u" - }, - { - "name": "Grafana", - "icon": "/icons/grafana-logo.svg", - "href": "https://monitoring.neshweb.net/", - "desc": "Server Monitoring Utility", - "warn": "Note: Admin Only", - "type": "docker", - "docker_container_name": "grafana", - "location": "brr7-4800u" - }, - { - "name": "Matomo", - "href": "https://tracking.neshweb.net/", - "desc": "Traffic Tracking Utility", - "warn": "Note: Admin Only", - "type": "docker", - "docker_container_name": "matomo-web", - "location": "brr7-4800u" - } - ], - "games": { - "minecraft": { - "name": "Minecraft", - "icon": "/icons/minecraft-logo.png", - "href": "https://minecraft.neshweb.net/", - "desc": "View all currently available Minecraft Servers and their mods" - }, - "ready_or_not": { - "name": "Ready or Not", - "icon": "/icons/ron-logo.png", - "href": "https://readyornot.neshweb.net/", - "desc": "Collection of Floor Plans for the Game 'Ready or Not'" - }, - "zomboid": { - "name": "Zomboid", - "icon": "/icons/zomboid-logo.png", - "ip": "91.13.248.30", - "status": "Online" - } - } -} From 795609f0a0672f5f06cbcd4ff86be69f3f60b660 Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 14 Mar 2023 22:32:53 +0100 Subject: [PATCH 19/19] Add Location handling --- interfaces/DockerStatus.ts | 2 + pages/api/containers.tsx | 2 + pages/servers.tsx | 2 +- pages/services.tsx | 117 ++++++++++++++----------------------- 4 files changed, 48 insertions(+), 75 deletions(-) diff --git a/interfaces/DockerStatus.ts b/interfaces/DockerStatus.ts index b3bc696..910f222 100644 --- a/interfaces/DockerStatus.ts +++ b/interfaces/DockerStatus.ts @@ -1,7 +1,9 @@ +import { ServiceLocation } from './CardTypes'; export interface DockerInfo { name: string, status: DockerStatus, id: string + location: ServiceLocation, } export enum DockerStatus { diff --git a/pages/api/containers.tsx b/pages/api/containers.tsx index d83f405..7f6a6d2 100644 --- a/pages/api/containers.tsx +++ b/pages/api/containers.tsx @@ -1,6 +1,7 @@ import Docker from 'dockerode' import ApiSecret from '../../private/portainer_api_secret.json' import { DockerInfo } from '../../interfaces/DockerStatus'; +import { ServiceLocation } from '../../interfaces/CardTypes'; export default async function ContainersAPI(req: any, res: any) { const token = JSON.parse(JSON.stringify(ApiSecret.token)); @@ -20,6 +21,7 @@ export default async function ContainersAPI(req: any, res: any) { newEntry.name = entry.Names[0].substring(1); newEntry.status = entry.State; newEntry.id = entry.Id; + newEntry.location = ServiceLocation.tower_0; list.push(newEntry); }); diff --git a/pages/servers.tsx b/pages/servers.tsx index 1acfe95..c193a49 100644 --- a/pages/servers.tsx +++ b/pages/servers.tsx @@ -1,7 +1,7 @@ import Head from 'next/head' import { Game } from '../interfaces/CardTypes'; import { PageContentBox, PageDescription, PageTitle, CardContentGame } from '../components/styles/content' -import GameList from '../public/pages.json'; +import GameList from '../public/data/pages.json'; function Servers() { // TODO: unuggly this shit diff --git a/pages/services.tsx b/pages/services.tsx index 8793aba..fce23f6 100644 --- a/pages/services.tsx +++ b/pages/services.tsx @@ -61,78 +61,8 @@ async function getStatus(entry: Service, containers: DockerInfo[]) { // Currently the only location supporting different fetching depending on type is brr7-4800u // Others to follow but low prio as this is currently the only location used - // Location BRR7-4800U - if (entry.location === ServiceLocation.brr7_4800u) { - // Type APP - if (entry.type === ServiceType.app) { - await fetch(entry.href) - .then((response) => { - if (response.ok) { - switch (response.status) { - case 200: - case 301: - case 302: - entry.status = Status.online; - break; - default: - entry.status = Status.offline; - } - } - else { - entry.status = Status.offline; - } - }) - .catch((error) => { - console.error("Error pinging Website: ", error); - entry.status = Status.error; - }) - } - // Type Docker - else if (entry.type === ServiceType.docker) { - if (entry.name !== null) { - let found = false; - for (let i = 0; i < containers.length; i++) { - const container = containers[i]; - // Docker API returns container names with / prepended - if (container.name === entry.docker_container_name) { - // so far only "running" is properly implemented, mroe cases to follow as needed - switch (container.status) { - case "running": - entry.status = Status.online; - break; - default: - console.log("Container Status " + container.status + " has no case implemented"); - entry.status = Status.offline; - } - found = true; - // cancel the for - break; - } - // If container name is not missing the container is set to offline - else { - entry.status = Status.offline; - } - } - if (!found) { - console.warn("Container for " + entry.name + " could not be found"); - } - } - // if name is null do not enter for loop - else { - console.error("Container Name not specified"); - entry.status = Status.error; - } - } - // If no Type matches - else { - console.warn("Service Type for Service " + entry.name + " not specified or invalid"); - entry.status = Status.error; - } - } - // Location Other - // TODO: implement docker type for other locations - else if (entry.location === ServiceLocation.other) { - // Currently uses the same handling as app type for the other location + // Type APP + if (entry.type === ServiceType.app) { await fetch(entry.href) .then((response) => { if (response.ok) { @@ -155,9 +85,48 @@ async function getStatus(entry: Service, containers: DockerInfo[]) { entry.status = Status.error; }) } - // If no Location matches + // Type Docker + else if (entry.type === ServiceType.docker) { + if (entry.name !== null) { + let found = false; + for (let i = 0; i < containers.length; i++) { + const container = containers[i]; + // Docker API returns container names with / prepended + if (container.name === entry.docker_container_name) { + + if (container.location === entry.location) { + // so far only "running" is properly implemented, mroe cases to follow as needed + switch (container.status) { + case "running": + entry.status = Status.online; + break; + default: + console.log("Container Status " + container.status + " has no case implemented"); + entry.status = Status.offline; + } + found = true; + // cancel the for + break; + } + } + // If container name is not missing the container is set to offline + else { + entry.status = Status.offline; + } + } + if (!found) { + console.warn("Container for " + entry.name + " could not be found"); + } + } + // if name is null do not enter for loop + else { + console.error("Container Name not specified"); + entry.status = Status.error; + } + } + // If no Type matches else { - console.warn("Service Location for Service " + entry.name + " not specified"); + console.warn("Service Type for Service " + entry.name + " not specified or invalid"); entry.status = Status.error; } return entry;