diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 7cded66..d8ae96a 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -29,8 +29,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 - goos: [linux, windows, darwin] + goos: [linux, windows, darwin, freebsd, openbsd, netbsd] goarch: ["386", amd64, arm64] exclude: - goarch: "386" @@ -49,4 +48,5 @@ jobs: goversion: "https://dl.google.com/go/go1.20.5.linux-amd64.tar.gz" project_path: "." binary_name: "sleep-on-lan" + sha256sum: true extra_files: script/win-service-install.ps1 script/win-service-uninstall.ps1 README.md \ No newline at end of file diff --git a/Changelog.md b/Changelog.md index c46d2c0..8cf1fa6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,4 @@ -# Release 1.0.17 +# Release 1.1.0 -* Actions test +* Support extended for darwin (macos) +* Support for *BSD systems diff --git a/server/solserver.go b/server/solserver.go index 5c1412b..f77b1a8 100644 --- a/server/solserver.go +++ b/server/solserver.go @@ -21,6 +21,8 @@ type Result struct { const ( baseLinux = "systemctl" baseWindows = "shutdown -f" + baseDarwin = "shutdown" + baseBSD = "shutdown" ) var ( @@ -35,6 +37,16 @@ func init() { case "linux": fmt.Println("###############\nPlease be sure that this script has sudo priviledges in order to run commands from this script\n################") shutdownFunc = shutdownLinux + case "darwin": + fmt.Println("###############\nPlease be sure that this script has sudo priviledges in order to run commands from this script\n################") + shutdownFunc = shutdownDarwin + case "freebsd": + case "openbsd": + case "netbsd": + case "dragonfly": + case "illumos": + fmt.Println("###############\nPlease be sure that this script has sudo priviledges in order to run commands from this script\n################") + shutdownFunc = shutdownBSD default: panic("Your os is not yet supported") } @@ -109,3 +121,33 @@ func shutdownWindows(command string) error { } return nil } + +func shutdownDarwin(command string) error { + var commandEx *exec.Cmd + switch command { + case "suspend": + commandEx = exec.Command(baseDarwin, "-s") + case "hibernate": + return errors.New("Hibernate is not supported on Darwin") + case "reboot": + commandEx = exec.Command(baseDarwin, "-r now") + case "poweroff": + commandEx = exec.Command(baseDarwin, "-h now") + } + return commandEx.Run() +} + +func shutdownBSD(command string) error { + var commandEx *exec.Cmd + switch command { + case "suspend": + commandEx = exec.Command(baseBSD, "-s") + case "hibernate": + return errors.New("Hibernate is not supported on Darwin") + case "reboot": + commandEx = exec.Command(baseBSD, "-r") + case "poweroff": + commandEx = exec.Command(baseBSD, "-h") + } + return commandEx.Run() +}