From 67a2cbf6bc2b93b0ef1dfcc068186b1ba778cadc Mon Sep 17 00:00:00 2001 From: Vitalie Date: Fri, 27 Mar 2020 19:21:35 +0200 Subject: [PATCH 1/7] update 27.03.2020 --- go.mod | 2 +- readme.md | 4 +++- tests-as-root/main.go | 53 +++++++++++++++++++++++-------------------- tests/helpers_unix.go | 14 ------------ tests/install_test.go | 2 +- 5 files changed, 34 insertions(+), 41 deletions(-) diff --git a/go.mod b/go.mod index 2a6f1c1..9c92b4d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/codemodify/systemkit-service -go 1.13 +go 1.14 require ( github.com/codemodify/systemkit-helpers v1.7.7 diff --git a/readme.md b/readme.md index 070ee81..b186c30 100644 --- a/readme.md +++ b/readme.md @@ -5,7 +5,9 @@ [![Test Status](https://github.com/danawoodman/systemservice/workflows/Test/badge.svg)](https://github.com/danawoodman/systemservice/actions) ![code size](https://img.shields.io/github/languages/code-size/codemodify/SystemKit?style=flat-square) -#### Robust Cross platform Create/Start/Stop/Delete system or user service +# Cross platform

`CREATE/START/STOP/UNINSTALL` SYSTEM / USER SERVICE +## How to use? + - Download a sample service definiton from here and save/extract to your `~/Downloads` folder: #### Supported: Linux, Raspberry Pi, FreeBSD, Mac OS, Windows, Solaris diff --git a/tests-as-root/main.go b/tests-as-root/main.go index 16f5c92..4c6cc30 100644 --- a/tests-as-root/main.go +++ b/tests-as-root/main.go @@ -1,24 +1,29 @@ -package main - -import ( - "fmt" - - // helpersErrors "github.com/codemodify/systemkit-helpers" - "github.com/codemodify/systemkit-service/tests" -) - -func main() { - service := tests.CreateRemoteitService() - - // err := service.Stop() - // if helpersErrors.Is(err, Service.ErrServiceDoesNotExist) { - // // this is a good thing - // } else if err != nil { - // fmt.Println(err.Error()) - // } - - err := service.Uninstall() - if err != nil { - fmt.Println(err.Error()) - } -} +// +build darwin + +package main + +import ( + "fmt" + "os/user" + + "github.com/codemodify/SystemKit/Service" +) + +func main() { + usr, _ := user.Current() + + service := Service.New(Service.Command{ + Name: "MY_SERVICE", + DisplayLabel: "My Service", + Description: "This service is a test service", + DocumentationURL: "", + Executable: usr.HomeDir + "/Downloads/service.sh", + Args: []string{""}, + WorkingDirectory: usr.HomeDir, + }) + + err := service.Uninstall() + if err != nil { + fmt.Println(err.Error()) + } +} diff --git a/tests/helpers_unix.go b/tests/helpers_unix.go index 785baf5..72751bb 100644 --- a/tests/helpers_unix.go +++ b/tests/helpers_unix.go @@ -38,17 +38,3 @@ func createRandomService() service.SystemService { RunAsUser: "user", }) } - -func CreateRemoteitService() service.SystemService { - return service.New(service.Command{ - Name: "it.remote.cli", - DisplayLabel: "it.remote.cli", - Description: "it.remote.cli", - DocumentationURL: "", - Executable: "/Users/nicolae/Downloads/remoteit_mac-osx_x86_64", - Args: []string{"watch", "-v", "-c", "/etc/remoteit/config.json"}, - WorkingDirectory: "", - StdOutPath: "null", - RunAsUser: "user", - }) -} diff --git a/tests/install_test.go b/tests/install_test.go index 39b644b..0ba3f5f 100644 --- a/tests/install_test.go +++ b/tests/install_test.go @@ -5,7 +5,7 @@ import ( ) func Test_install(t *testing.T) { - service := CreateRemoteitService() + service := CreateService() err := service.Install(false) if err != nil { From b58877612e0998501bddf7c5b2b0087715e97def Mon Sep 17 00:00:00 2001 From: Vitalie Date: Sat, 28 Mar 2020 11:16:21 +0200 Subject: [PATCH 2/7] Update-readme.md --- readme.md | 4 +++- {tests-as-root => test-as-root}/main.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) rename {tests-as-root => test-as-root}/main.go (94%) diff --git a/readme.md b/readme.md index b186c30..7176e73 100644 --- a/readme.md +++ b/readme.md @@ -7,9 +7,11 @@ # Cross platform

`CREATE/START/STOP/UNINSTALL` SYSTEM / USER SERVICE ## How to use? + +# ![](https://fonts.gstatic.com/s/i/materialicons/label_important/v4/24px.svg) MacOS ![](https://img.icons8.com/ios-filled/30/000000/mac-os.png) - Download a sample service definiton from here and save/extract to your `~/Downloads` folder: -#### Supported: Linux, Raspberry Pi, FreeBSD, Mac OS, Windows, Solaris +> `ghttps://github.com/codemodify/systemkit-service/samples/service.sh` # ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Install ```go diff --git a/tests-as-root/main.go b/test-as-root/main.go similarity index 94% rename from tests-as-root/main.go rename to test-as-root/main.go index 4c6cc30..7dfd01b 100644 --- a/tests-as-root/main.go +++ b/test-as-root/main.go @@ -22,7 +22,7 @@ func main() { WorkingDirectory: usr.HomeDir, }) - err := service.Uninstall() + err := service.Install(true) if err != nil { fmt.Println(err.Error()) } From 8bbce5f82a222645e55aebd688b52e4b4ee30b53 Mon Sep 17 00:00:00 2001 From: Vitalie Date: Sat, 28 Mar 2020 21:28:18 +0200 Subject: [PATCH 3/7] Update Test_MacOSX --- system-service_darwin.go | 2 +- tests/install_test.go | 2 +- tests/restart_test.go | 2 +- tests/start_test.go | 2 +- tests/status_test.go | 2 +- tests/stop_test.go | 2 +- tests/uninstall_test.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/system-service_darwin.go b/system-service_darwin.go index bae7666..856f0cf 100644 --- a/system-service_darwin.go +++ b/system-service_darwin.go @@ -106,7 +106,7 @@ func (thisRef MacOSService) Install(start bool) error { // Start - func (thisRef MacOSService) Start() error { - // 1. + output, _ := runLaunchCtlCommand("load", "-w", thisRef.FilePath()) if strings.Contains(output, "No such file or directory") { return ErrServiceDoesNotExist diff --git a/tests/install_test.go b/tests/install_test.go index 0ba3f5f..f0b6e34 100644 --- a/tests/install_test.go +++ b/tests/install_test.go @@ -5,7 +5,7 @@ import ( ) func Test_install(t *testing.T) { - service := CreateService() + service := createService() err := service.Install(false) if err != nil { diff --git a/tests/restart_test.go b/tests/restart_test.go index 8bf316a..2efa03f 100644 --- a/tests/restart_test.go +++ b/tests/restart_test.go @@ -5,7 +5,7 @@ import ( ) func Test_restart(t *testing.T) { - service := CreateRemoteitService() + service := createService() err := service.Restart() if err != nil { diff --git a/tests/start_test.go b/tests/start_test.go index 74734f6..cd1e402 100644 --- a/tests/start_test.go +++ b/tests/start_test.go @@ -5,7 +5,7 @@ import ( ) func Test_start(t *testing.T) { - service := CreateRemoteitService() + service := createService() err := service.Start() if err != nil { diff --git a/tests/status_test.go b/tests/status_test.go index 9bd0d98..7f83ed0 100644 --- a/tests/status_test.go +++ b/tests/status_test.go @@ -6,7 +6,7 @@ import ( ) func Test_status(t *testing.T) { - service := CreateRemoteitService() + service := createService() serviceStatus := service.Status() if serviceStatus.Error != nil { diff --git a/tests/stop_test.go b/tests/stop_test.go index 52921d0..20cddc6 100644 --- a/tests/stop_test.go +++ b/tests/stop_test.go @@ -8,7 +8,7 @@ import ( ) func Test_stop(t *testing.T) { - systemService := CreateRemoteitService() + systemService := createService() err := systemService.Stop() if helpersErrors.Is(err, service.ErrServiceDoesNotExist) { diff --git a/tests/uninstall_test.go b/tests/uninstall_test.go index d0da1fe..d9198ef 100644 --- a/tests/uninstall_test.go +++ b/tests/uninstall_test.go @@ -5,7 +5,7 @@ import ( ) func Test_uninstall(t *testing.T) { - service := CreateRemoteitService() + service := createService() err := service.Uninstall() if err != nil { From 53d2127d6d1e69ac80a606fec60e32e3e2be4eb5 Mon Sep 17 00:00:00 2001 From: Vitalie Date: Sun, 29 Mar 2020 14:19:23 +0300 Subject: [PATCH 4/7] Update readme.md --- readme.md | 61 ++++++++++++++++++++++++++++++-- samples/MacOSX/main.go | 29 +++++++++++++++ samples/MacOSX/readme.md | 74 +++++++++++++++++++++++++++++++++++++++ samples/MacOSX/service.sh | 6 ++++ 4 files changed, 167 insertions(+), 3 deletions(-) create mode 100644 samples/MacOSX/main.go create mode 100644 samples/MacOSX/readme.md create mode 100755 samples/MacOSX/service.sh diff --git a/readme.md b/readme.md index 7176e73..7d9c9c0 100644 --- a/readme.md +++ b/readme.md @@ -13,7 +13,62 @@ > `ghttps://github.com/codemodify/systemkit-service/samples/service.sh` -# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Install ```go -go get github.com/codemodify/systemkit-service -``` \ No newline at end of file +package main + +import ( + "fmt" + + "https://github.com/codemodify/systemkit-service/" +) + +func main() { + +// Create service definition + + usr, _ := user.Current() + service := Service.New(Service.Command{ + Name: "MY_SERVICE", + DisplayLabel: "My Service", + Description: "This service is a test service", + DocumentationURL: "", + Executable: usr.HomeDir + "/Downloads/service.sh"), + Args: []string{""}, + WorkingDirectory: usr.HomeDir, + }) + +// Instal and start + + err := service.Install(true) + if err != nil { + fmt.Println(err.Error()) + } +} + +// Done +``` + +--- +#### `INSTALL WITHOUT START ` +```go + err := service.Install(false) + if err != nil { + fmt.Println(err.Error()) + +``` +--- +#### `STOP SERVICE ` +```go + err := service.Stop + if err != nil { + fmt.Println(err.Error()) +``` +#### `UNINSTALL SERVICE ` +```go + err := service.Uninstall + if err != nil { + fmt.Println(err.Error()) +``` +--- +#### `IMPORTANT NOTE` +### If this is executed as `SUDO` then a system service will be created instead of user service diff --git a/samples/MacOSX/main.go b/samples/MacOSX/main.go new file mode 100644 index 0000000..7dfd01b --- /dev/null +++ b/samples/MacOSX/main.go @@ -0,0 +1,29 @@ +// +build darwin + +package main + +import ( + "fmt" + "os/user" + + "github.com/codemodify/SystemKit/Service" +) + +func main() { + usr, _ := user.Current() + + service := Service.New(Service.Command{ + Name: "MY_SERVICE", + DisplayLabel: "My Service", + Description: "This service is a test service", + DocumentationURL: "", + Executable: usr.HomeDir + "/Downloads/service.sh", + Args: []string{""}, + WorkingDirectory: usr.HomeDir, + }) + + err := service.Install(true) + if err != nil { + fmt.Println(err.Error()) + } +} diff --git a/samples/MacOSX/readme.md b/samples/MacOSX/readme.md new file mode 100644 index 0000000..f87e0a8 --- /dev/null +++ b/samples/MacOSX/readme.md @@ -0,0 +1,74 @@ +# ![](https://fonts.gstatic.com/s/i/materialicons/label_important/v4/24px.svg) Service +[![GoDoc](https://godoc.org/github.com/codemodify/SystemKit?status.svg)](https://godoc.org/github.com/codemodify/SystemKit) +[![0-License](https://img.shields.io/badge/license-0--license-brightgreen)](https://github.com/codemodify/TheFreeLicense) +[![Go Report Card](https://goreportcard.com/badge/github.com/codemodify/SystemKit)](https://goreportcard.com/report/github.com/codemodify/SystemKit) +[![Test Status](https://github.com/danawoodman/systemservice/workflows/Test/badge.svg)](https://github.com/danawoodman/systemservice/actions) +![code size](https://img.shields.io/github/languages/code-size/codemodify/SystemKit?style=flat-square) + +# Cross platform

`CREATE/START/STOP/UNINSTALL` SYSTEM / USER SERVICE +## How to use? + +# ![](https://fonts.gstatic.com/s/i/materialicons/label_important/v4/24px.svg) MacOS ![](https://img.icons8.com/ios-filled/30/000000/mac-os.png) + - Download a sample service definiton from here and save/extract to your `~/Downloads` folder: + +> `https://github.com/codemodify/systemkit-service/samples/service.sh` + +```go +package main + +import ( + "fmt" + + "https://github.com/codemodify/systemkit-service/" +) + +func main() { + +// Create service definition + + usr, _ := user.Current() + service := Service.New(Service.Command{ + Name: "MY_SERVICE", + DisplayLabel: "My Service", + Description: "This service is a test service", + DocumentationURL: "", + Executable: usr.HomeDir + "/Downloads/service.sh"), + Args: []string{""}, + WorkingDirectory: usr.HomeDir, + }) + +// Instal and start + + err := service.Install(true) + if err != nil { + fmt.Println(err.Error()) + } +} + +// Done +``` + +--- +#### `INSTALL WITHOUT START ` +```go + err := service.Install(false) + if err != nil { + fmt.Println(err.Error()) + +``` +--- +#### `STOP SERVICE ` +```go + err := service.Stop + if err != nil { + fmt.Println(err.Error()) +``` +#### `UNINSTALL SERVICE ` +```go + err := service.Uninstall + if err != nil { + fmt.Println(err.Error()) +``` +--- +#### `IMPORTANT NOTE` +### If this is executed as `SUDO` then a system service will be created instead of user service diff --git a/samples/MacOSX/service.sh b/samples/MacOSX/service.sh new file mode 100755 index 0000000..85697f1 --- /dev/null +++ b/samples/MacOSX/service.sh @@ -0,0 +1,6 @@ +#!/bin/bash +NEXT_WAIT_TIME=0 +until say 'done' && [ $NEXT_WAIT_TIME -eq 4 ]; do +$(( NEXT_WAIT_TIME++ )) +sleep 5s +done \ No newline at end of file From d4b787c15759819dc7d254ba6ab4d6d6094cd441 Mon Sep 17 00:00:00 2001 From: Vitalie Date: Sun, 29 Mar 2020 14:31:17 +0300 Subject: [PATCH 5/7] Update readme.md --- readme.md | 3 +++ test-as-root/main.go | 29 ----------------------------- 2 files changed, 3 insertions(+), 29 deletions(-) delete mode 100644 test-as-root/main.go diff --git a/readme.md b/readme.md index 7d9c9c0..521bf68 100644 --- a/readme.md +++ b/readme.md @@ -5,6 +5,9 @@ [![Test Status](https://github.com/danawoodman/systemservice/workflows/Test/badge.svg)](https://github.com/danawoodman/systemservice/actions) ![code size](https://img.shields.io/github/languages/code-size/codemodify/SystemKit?style=flat-square) +Cross platform Create/Start/Stop/Delete system or user service + - How to use? + # Cross platform

`CREATE/START/STOP/UNINSTALL` SYSTEM / USER SERVICE ## How to use? diff --git a/test-as-root/main.go b/test-as-root/main.go deleted file mode 100644 index 7dfd01b..0000000 --- a/test-as-root/main.go +++ /dev/null @@ -1,29 +0,0 @@ -// +build darwin - -package main - -import ( - "fmt" - "os/user" - - "github.com/codemodify/SystemKit/Service" -) - -func main() { - usr, _ := user.Current() - - service := Service.New(Service.Command{ - Name: "MY_SERVICE", - DisplayLabel: "My Service", - Description: "This service is a test service", - DocumentationURL: "", - Executable: usr.HomeDir + "/Downloads/service.sh", - Args: []string{""}, - WorkingDirectory: usr.HomeDir, - }) - - err := service.Install(true) - if err != nil { - fmt.Println(err.Error()) - } -} From f824b31a7027012a5cd8764db5e1ef31ee1901b9 Mon Sep 17 00:00:00 2001 From: Vitalie Date: Mon, 30 Mar 2020 10:59:00 +0300 Subject: [PATCH 6/7] /systemkit-service update readme.md --- go.mod | 1 + go.sum | 12 ++++++++++++ readme.md | 55 +++++++++++++++++++++++-------------------------------- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/go.mod b/go.mod index 9c92b4d..49f3473 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/codemodify/systemkit-service go 1.14 require ( + github.com/codemodify/SystemKit v1.7.4 github.com/codemodify/systemkit-helpers v1.7.7 github.com/codemodify/systemkit-logging v1.7.6 golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd diff --git a/go.sum b/go.sum index 74b5b83..8b9349d 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,6 @@ +github.com/codemodify/SystemKit v1.7.4 h1:glqH7m+qxEQoUXWuLXhzHHLgV9sYYUPM1rRWVz66tRg= +github.com/codemodify/SystemKit v1.7.4/go.mod h1:KKn3HcCBZURVS8AbQanXxsyUbHsGhnIinVpAkSPVzXk= +github.com/codemodify/systemkit-cryptography v1.0.0/go.mod h1:xpC1R/KccPhPrmY9Vs5lcOrESMlAZfJ/xrbqrfuFve0= github.com/codemodify/systemkit-helpers v1.7.7 h1:ITFCHhS6hSxqNhqcqwVfpzKG9JOEcX3E+4AO7uo1yXI= github.com/codemodify/systemkit-helpers v1.7.7/go.mod h1:5jkrQySFtJYZnUnudYeuAYzbunPsAcDlQmW/kMa6rT0= github.com/codemodify/systemkit-logging v1.7.6 h1:B43qtBemRL85bwQPsdwtspOENYB1OgHPEnZIfhB/88I= @@ -5,14 +8,19 @@ github.com/codemodify/systemkit-logging v1.7.6/go.mod h1:CgHyiLfps+2ALdwXfTKTShM github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davidmz/go-pageant v1.0.1 h1:kzCt64aTc557QYvy5VBSN1pVWO/tNAcqzwlpUsZ8IEE= github.com/davidmz/go-pageant v1.0.1/go.mod h1:WWOKE/93DhgsPq15jaipH4fVY+MLKKWH4Yku5Ei92rE= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= @@ -20,19 +28,23 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/sftp v1.11.0 h1:4Zv0OGbpkg4yNuUtH0s8rvoYxRCNyT29NVUo6pgPmxI= github.com/pkg/sftp v1.11.0/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/sfreiberg/simplessh v0.0.0-20180301191542-495cbb862a9c h1:7Q+2oF0uBoLEV+j13E3/xUkPkI7f+sFNPZOPo2jmrWk= github.com/sfreiberg/simplessh v0.0.0-20180301191542-495cbb862a9c/go.mod h1:sB7d6wQapoRM+qx5MgQYB6JVHtel4YHRr0NXXCkXiwQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200208060501-ecb85df21340/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 h1:3zb4D3T4G8jdExgVU/95+vQXfpEPiMdCaZgmGVxjNHM= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/readme.md b/readme.md index 521bf68..0d7a4d9 100644 --- a/readme.md +++ b/readme.md @@ -1,21 +1,33 @@ # ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Service -[![GoDoc](https://godoc.org/github.com/codemodify/SystemKit?status.svg)](https://godoc.org/github.com/codemodify/SystemKit) +[![GoDoc](https://godoc.org/github.com/codemodify/systemkit-logging?status.svg)](https://godoc.org/github.com/codemodify/systemkit-events) [![0-License](https://img.shields.io/badge/license-0--license-brightgreen)](https://github.com/codemodify/TheFreeLicense) -[![Go Report Card](https://goreportcard.com/badge/github.com/codemodify/SystemKit)](https://goreportcard.com/report/github.com/codemodify/SystemKit) +[![Go Report Card](https://goreportcard.com/badge/github.com/codemodify/systemkit-logging)](https://goreportcard.com/report/github.com/codemodify/systemkit-logging) [![Test Status](https://github.com/danawoodman/systemservice/workflows/Test/badge.svg)](https://github.com/danawoodman/systemservice/actions) ![code size](https://img.shields.io/github/languages/code-size/codemodify/SystemKit?style=flat-square) -Cross platform Create/Start/Stop/Delete system or user service - - How to use? +#### Robust Cross platform Create/Start/Stop/Delete system or user service. +#### Supported: Linux, Raspberry Pi, FreeBSD, Mac OS, Windows, Solaris -# Cross platform

`CREATE/START/STOP/UNINSTALL` SYSTEM / USER SERVICE -## How to use? +# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Install +```go +go get github.com/codemodify/systemkit-service +``` -# ![](https://fonts.gstatic.com/s/i/materialicons/label_important/v4/24px.svg) MacOS ![](https://img.icons8.com/ios-filled/30/000000/mac-os.png) - - Download a sample service definiton from here and save/extract to your `~/Downloads` folder: +# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) API -> `ghttps://github.com/codemodify/systemkit-service/samples/service.sh` +  |   +--- | --- +service := Service.New() | Create a new system service +service.Install(false) | Install a new system service +service.Install(true) | Install a new system service and start +service.Start() | Start system service +service.Restart() | Restart system service +service.Status() | System service status +service.Stop() | Stop system service +service.Uninstall() | Uninstall system service + +# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Usage ```go package main @@ -52,26 +64,5 @@ func main() { ``` --- -#### `INSTALL WITHOUT START ` -```go - err := service.Install(false) - if err != nil { - fmt.Println(err.Error()) - -``` ---- -#### `STOP SERVICE ` -```go - err := service.Stop - if err != nil { - fmt.Println(err.Error()) -``` -#### `UNINSTALL SERVICE ` -```go - err := service.Uninstall - if err != nil { - fmt.Println(err.Error()) -``` ---- -#### `IMPORTANT NOTE` -### If this is executed as `SUDO` then a system service will be created instead of user service + +> `IMPORTANT NOTE:`
If this is executed as `SUDO` then a system service will be created instead of user service From e5cad076b606d0ee448d1f3c7a7961f709af7049 Mon Sep 17 00:00:00 2001 From: Vitalie Date: Sat, 4 Apr 2020 17:45:45 +0300 Subject: [PATCH 7/7] Update readme.md --- readme.md | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 0d7a4d9..863b1c2 100644 --- a/readme.md +++ b/readme.md @@ -1,11 +1,25 @@ # ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Service -[![GoDoc](https://godoc.org/github.com/codemodify/systemkit-logging?status.svg)](https://godoc.org/github.com/codemodify/systemkit-events) -[![0-License](https://img.shields.io/badge/license-0--license-brightgreen)](https://github.com/codemodify/TheFreeLicense) -[![Go Report Card](https://goreportcard.com/badge/github.com/codemodify/systemkit-logging)](https://goreportcard.com/report/github.com/codemodify/systemkit-logging) -[![Test Status](https://github.com/danawoodman/systemservice/workflows/Test/badge.svg)](https://github.com/danawoodman/systemservice/actions) -![code size](https://img.shields.io/github/languages/code-size/codemodify/SystemKit?style=flat-square) +[![](https://img.shields.io/github/v/release/codemodify/systemkit-service?style=flat-square)](https://github.com/codemodify/systemkit-service/releases/latest) +![](https://img.shields.io/github/languages/code-size/codemodify/systemkit-service?style=flat-square) +![](https://img.shields.io/github/last-commit/codemodify/systemkit-service?style=flat-square) +[![](https://img.shields.io/badge/license-0--license-brightgreen?style=flat-square)](https://github.com/codemodify/TheFreeLicense) + +![](https://img.shields.io/github/workflow/status/codemodify/systemkit-service/qa?style=flat-square) +![](https://img.shields.io/github/issues/codemodify/systemkit-service?style=flat-square) +[![](https://goreportcard.com/badge/github.com/codemodify/systemkit-service?style=flat-square)](https://goreportcard.com/report/github.com/codemodify/systemkit-service) + +[![](https://img.shields.io/badge/godoc-reference-brightgreen?style=flat-square)](https://godoc.org/github.com/codemodify/systemkit-service) +![](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square) +![](https://img.shields.io/gitter/room/codemodify/systemkit-service?style=flat-square) + +![](https://img.shields.io/github/contributors/codemodify/systemkit-service?style=flat-square) +![](https://img.shields.io/github/stars/codemodify/systemkit-service?style=flat-square) +![](https://img.shields.io/github/watchers/codemodify/systemkit-service?style=flat-square) +![](https://img.shields.io/github/forks/codemodify/systemkit-service?style=flat-square) + + +#### Robust Cross platform Create/Start/Stop/Delete system or user service -#### Robust Cross platform Create/Start/Stop/Delete system or user service. #### Supported: Linux, Raspberry Pi, FreeBSD, Mac OS, Windows, Solaris # ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Install