Auto-sync services from homelab repo via GenServer
ServicesSync polls ~/dev/homelab every 5 minutes: runs git pull, then re-parses ansible/roles/traefik/defaults/main.yml to derive public and internal service lists. Services with public_host are shown publicly; others require internal network access. PageController now delegates to ServicesSync instead of hardcoded module attributes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,82 +2,12 @@ defmodule HomelabDashboardWeb.PageController do
|
||||
use HomelabDashboardWeb, :controller
|
||||
import Bitwise
|
||||
|
||||
@public_services [
|
||||
%{
|
||||
name: "MTG",
|
||||
url: "https://adyrem.duckdns.org/mtg",
|
||||
description: "Magic: The Gathering collection",
|
||||
icon: "hero-sparkles"
|
||||
},
|
||||
%{
|
||||
name: "Gitea",
|
||||
url: "https://adyrem.duckdns.org/git",
|
||||
description: "Git repository hosting",
|
||||
icon: "hero-code-bracket"
|
||||
}
|
||||
]
|
||||
|
||||
@internal_services [
|
||||
%{
|
||||
name: "Proxmox",
|
||||
url: "https://proxmox.homelab",
|
||||
description: "Virtualization & container management",
|
||||
icon: "hero-server-stack"
|
||||
},
|
||||
%{
|
||||
name: "Grafana",
|
||||
url: "https://grafana.homelab",
|
||||
description: "Metrics & monitoring dashboards",
|
||||
icon: "hero-presentation-chart-line"
|
||||
},
|
||||
%{
|
||||
name: "Pi-hole",
|
||||
url: "https://pihole.homelab/admin",
|
||||
description: "Network-wide DNS ad blocker",
|
||||
icon: "hero-shield-check"
|
||||
},
|
||||
%{
|
||||
name: "Jellyfin",
|
||||
url: "https://jellyfin.homelab",
|
||||
description: "Media server",
|
||||
icon: "hero-play-circle"
|
||||
},
|
||||
%{
|
||||
name: "Jellyseerr",
|
||||
url: "https://jellyseerr.homelab",
|
||||
description: "Media request management",
|
||||
icon: "hero-queue-list"
|
||||
},
|
||||
%{
|
||||
name: "Radarr",
|
||||
url: "https://radarr.homelab",
|
||||
description: "Movie collection manager",
|
||||
icon: "hero-film"
|
||||
},
|
||||
%{
|
||||
name: "Sonarr",
|
||||
url: "https://sonarr.homelab",
|
||||
description: "TV series collection manager",
|
||||
icon: "hero-tv"
|
||||
},
|
||||
%{
|
||||
name: "Prowlarr",
|
||||
url: "https://prowlarr.homelab",
|
||||
description: "Indexer manager",
|
||||
icon: "hero-funnel"
|
||||
},
|
||||
%{
|
||||
name: "qBittorrent",
|
||||
url: "https://qbittorrent.homelab",
|
||||
description: "Torrent client",
|
||||
icon: "hero-cloud-arrow-down"
|
||||
}
|
||||
]
|
||||
|
||||
def home(conn, _params) do
|
||||
{public_services, internal_services} = HomelabDashboard.ServicesSync.get_services()
|
||||
|
||||
render(conn, :home,
|
||||
public_services: @public_services,
|
||||
internal_services: @internal_services,
|
||||
public_services: public_services,
|
||||
internal_services: internal_services,
|
||||
show_internal: internal_network?(conn.remote_ip)
|
||||
)
|
||||
end
|
||||
@@ -87,7 +17,6 @@ defmodule HomelabDashboardWeb.PageController do
|
||||
defp internal_network?({192, 168, _, _}), do: true
|
||||
defp internal_network?({172, b, _, _}) when b in 16..31, do: true
|
||||
defp internal_network?({0, 0, 0, 0, 0, 0, 0, 1}), do: true
|
||||
# IPv6-mapped IPv4: ::ffff:x.x.x.x — decode and re-check
|
||||
defp internal_network?({0, 0, 0, 0, 0, 65535, ab, cd}) do
|
||||
internal_network?({ab >>> 8, ab &&& 0xFF, cd >>> 8, cd &&& 0xFF})
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user