-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate from user profile dir to registry and tmp folders
- Loading branch information
1 parent
ce8ac51
commit 9fdf908
Showing
11 changed files
with
654 additions
and
325 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/kardianos/service" | ||
) | ||
|
||
func main() { | ||
svcConfig := &service.Config{ | ||
Name: "ProxmoxBackupAgent", | ||
DisplayName: "Proxmox Backup Agent", | ||
Description: "Agent for orchestrating backups with Proxmox Backup Server", | ||
UserName: "", | ||
} | ||
|
||
prg := &agentService{} | ||
s, err := service.New(prg, svcConfig) | ||
if err != nil { | ||
fmt.Println("Failed to initialize service:", err) | ||
return | ||
} | ||
|
||
tray := &agentTray{svc: s} | ||
|
||
if len(os.Args) > 1 { | ||
cmd := os.Args[1] | ||
switch cmd { | ||
case "install": | ||
err = s.Install() | ||
if err != nil { | ||
fmt.Println("Failed to install service:", err) | ||
} else { | ||
fmt.Println("Service installed") | ||
} | ||
return | ||
case "uninstall": | ||
err = s.Uninstall() | ||
if err != nil { | ||
fmt.Println("Failed to uninstall service:", err) | ||
} else { | ||
fmt.Println("Service uninstalled") | ||
} | ||
return | ||
case "start": | ||
err = s.Start() | ||
if err != nil { | ||
fmt.Println("Failed to start service:", err) | ||
} else { | ||
fmt.Println("Service started") | ||
} | ||
return | ||
case "stop": | ||
err = s.Stop() | ||
if err != nil { | ||
fmt.Println("Failed to stop service:", err) | ||
} else { | ||
fmt.Println("Service stopped") | ||
} | ||
return | ||
default: | ||
fmt.Println("Unknown command:", cmd) | ||
fmt.Println("Available commands: install, uninstall, start, stop") | ||
return | ||
} | ||
} | ||
|
||
if isWindowsService() { | ||
err = s.Run() | ||
if err != nil { | ||
fmt.Println("Error running service:", err) | ||
} | ||
} else { | ||
if !isAdmin() { | ||
runAsAdmin() | ||
return | ||
} | ||
|
||
err = tray.foregroundTray() | ||
} | ||
} |
Oops, something went wrong.