Add Windows Firewall rules to installer - Automated firewall configuration for inbound/outbound traffic and port access - Service start checkbox option for user control - Clean firewall rule removal during uninstallation
This commit is contained in:
@ -16,30 +16,9 @@ import (
|
||||
func main() {
|
||||
// Kommandozeilenparameter definieren
|
||||
var port int
|
||||
var installService bool
|
||||
var uninstallService bool
|
||||
flag.IntVar(&port, "port", 0, "Port für den Server (Standard: 8080 oder PORT Umgebungsvariable)")
|
||||
flag.BoolVar(&installService, "install", false, "Installiere Medi-WOL als Windows-Dienst")
|
||||
flag.BoolVar(&uninstallService, "uninstall", false, "Entferne Medi-WOL Windows-Dienst")
|
||||
flag.Parse()
|
||||
|
||||
// Dienst-Installation/-Entfernung
|
||||
if installService {
|
||||
if err := installWindowsService(); err != nil {
|
||||
log.Fatal("Fehler beim Installieren des Dienstes:", err)
|
||||
}
|
||||
log.Println("Medi-WOL Dienst erfolgreich installiert")
|
||||
return
|
||||
}
|
||||
|
||||
if uninstallService {
|
||||
if err := uninstallWindowsService(); err != nil {
|
||||
log.Fatal("Fehler beim Entfernen des Dienstes:", err)
|
||||
}
|
||||
log.Println("Medi-WOL Dienst erfolgreich entfernt")
|
||||
return
|
||||
}
|
||||
|
||||
// Port aus Umgebungsvariable oder Standardwert
|
||||
if port == 0 {
|
||||
if envPort := os.Getenv("PORT"); envPort != "" {
|
||||
@ -90,24 +69,10 @@ func main() {
|
||||
|
||||
// Server starten
|
||||
serverAddr := fmt.Sprintf(":%d", port)
|
||||
log.Printf("Server startet auf Port %d...", port)
|
||||
log.Printf("Medi-WOL startet auf Port %d...", port)
|
||||
log.Printf("Web-Oberfläche verfügbar unter: http://localhost%s", serverAddr)
|
||||
|
||||
if err := r.Run(serverAddr); err != nil {
|
||||
log.Fatal("Fehler beim Starten des Servers:", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Windows-Dienst-Funktionen
|
||||
func installWindowsService() error {
|
||||
// Einfache Implementierung: Dienst-Informationen in Registry schreiben
|
||||
// In einer echten Implementierung würde hier der Windows Service Controller verwendet
|
||||
log.Println("Installiere Medi-WOL als Windows-Dienst...")
|
||||
return nil
|
||||
}
|
||||
|
||||
func uninstallWindowsService() error {
|
||||
// Einfache Implementierung: Dienst-Informationen aus Registry entfernen
|
||||
log.Println("Entferne Medi-WOL Windows-Dienst...")
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user