Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
charliemaiors committed Jun 26, 2023
2 parents 222e4d7 + 18169d5 commit acbc908
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
5 changes: 3 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Release 1.0.17
# Release 1.1.0

* Actions test
* Support extended for darwin (macos)
* Support for *BSD systems
42 changes: 42 additions & 0 deletions server/solserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type Result struct {
const (
baseLinux = "systemctl"
baseWindows = "shutdown -f"
baseDarwin = "shutdown"
baseBSD = "shutdown"
)

var (
Expand All @@ -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")
}
Expand Down Expand Up @@ -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()
}

0 comments on commit acbc908

Please # to comment.