minor improvements

This commit is contained in:
Nicola Murino
2019-09-16 18:11:35 +02:00
parent 4a1baaee69
commit 580fae7a8f
2 changed files with 20 additions and 12 deletions

View File

@@ -37,7 +37,7 @@ Regularly the test cases are manually executed and pass on Windows. Other UNIX v
Simple install the package to your [$GOPATH](https://github.com/golang/go/wiki/GOPATH "GOPATH") with the [go tool](https://golang.org/cmd/go/ "go command") from shell: Simple install the package to your [$GOPATH](https://github.com/golang/go/wiki/GOPATH "GOPATH") with the [go tool](https://golang.org/cmd/go/ "go command") from shell:
```bash ```
$ go get -u github.com/drakkan/sftpgo $ go get -u github.com/drakkan/sftpgo
``` ```
@@ -57,13 +57,13 @@ Version info, such as git commit and build date, can be embedded setting the fol
For example you can build using the following command: For example you can build using the following command:
```bash ```
go build -i -ldflags "-s -w -X github.com/drakkan/sftpgo/utils.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/utils.date=`date -u +%FT%TZ`" -o sftpgo go build -i -ldflags "-s -w -X github.com/drakkan/sftpgo/utils.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/utils.date=`date -u +%FT%TZ`" -o sftpgo
``` ```
and you will get a version that includes git commit and build date like this one: and you will get a version that includes git commit and build date like this one:
```bash ```
sftpgo -v sftpgo -v
SFTPGo version: 0.9.0-dev-90607d4-dirty-2019-08-08T19:28:36Z SFTPGo version: 0.9.0-dev-90607d4-dirty-2019-08-08T19:28:36Z
``` ```
@@ -76,13 +76,13 @@ Alternately you can use distro packages:
For macOS a `launchd` sample [service](https://github.com/drakkan/sftpgo/tree/master/init/com.github.drakkan.sftpgo.plist "launchd plist") can be found inside the source tree. The `launchd` plist assumes that `sftpgo` has `/usr/local/opt/sftpgo` as base directory. For macOS a `launchd` sample [service](https://github.com/drakkan/sftpgo/tree/master/init/com.github.drakkan.sftpgo.plist "launchd plist") can be found inside the source tree. The `launchd` plist assumes that `sftpgo` has `/usr/local/opt/sftpgo` as base directory.
On Windows you can run `SFTPGo` as Windows Service read the "Configuration" section below for details. On Windows you can run `SFTPGo` as Windows Service, please read the "Configuration" section below for more details.
## Configuration ## Configuration
The `sftpgo` executable can be used this way: The `sftpgo` executable can be used this way:
```bash ```
Usage: Usage:
sftpgo [command] sftpgo [command]
@@ -229,13 +229,13 @@ Please note that to override configuration options with environment variables a
To start the SFTP Server with the default values for the command line flags simply use: To start the SFTP Server with the default values for the command line flags simply use:
```bash ```
sftpgo serve sftpgo serve
``` ```
On Windows you can register `SFTPGo` as Windows Service, take a look at the CLI usage to learn how: On Windows you can register `SFTPGo` as Windows Service, take a look at the CLI usage to learn how:
```bash ```
sftpgo.exe service --help sftpgo.exe service --help
Install, Uninstall, Start, Stop and retrieve status for SFTPGo Windows Service Install, Uninstall, Start, Stop and retrieve status for SFTPGo Windows Service
@@ -257,6 +257,14 @@ Use "sftpgo service [command] --help" for more information about a command.
`install` subcommand accepts the same flags valid for `serve`. `install` subcommand accepts the same flags valid for `serve`.
After installing as Windows Service please remember to allow network access to the SFTPGo executable using something like this:
```
netsh advfirewall firewall add rule name="SFTPGo Service" dir=in action=allow program="C:\Program Files\SFTPGo\sftpgo.exe"
```
or through the Windows Firewall GUI.
## Account's configuration properties ## Account's configuration properties
For each account the following properties can be configured: For each account the following properties can be configured:

View File

@@ -88,7 +88,7 @@ loop:
} }
func (s *WindowsService) RunService() error { func (s *WindowsService) RunService() error {
exepath, err := s.getExecPath() exePath, err := s.getExePath()
if err != nil { if err != nil {
return err return err
} }
@@ -99,7 +99,7 @@ func (s *WindowsService) RunService() error {
} }
s.isInteractive = isIntSess s.isInteractive = isIntSess
dir := filepath.Dir(exepath) dir := filepath.Dir(exePath)
if err = os.Chdir(dir); err != nil { if err = os.Chdir(dir); err != nil {
return err return err
} }
@@ -128,7 +128,7 @@ func (s *WindowsService) Start() error {
} }
func (s *WindowsService) Install(args ...string) error { func (s *WindowsService) Install(args ...string) error {
exepath, err := s.getExecPath() exePath, err := s.getExePath()
if err != nil { if err != nil {
return err return err
} }
@@ -146,7 +146,7 @@ func (s *WindowsService) Install(args ...string) error {
DisplayName: serviceName, DisplayName: serviceName,
Description: serviceDesc, Description: serviceDesc,
StartType: mgr.StartAutomatic} StartType: mgr.StartAutomatic}
service, err = m.CreateService(serviceName, exepath, config, args...) service, err = m.CreateService(serviceName, exePath, config, args...)
if err != nil { if err != nil {
return err return err
} }
@@ -266,6 +266,6 @@ func (s *WindowsService) Status() (Status, error) {
} }
} }
func (s *WindowsService) getExecPath() (string, error) { func (s *WindowsService) getExePath() (string, error) {
return os.Executable() return os.Executable()
} }