diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 34c6dc21..8f20978a 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -32,14 +32,14 @@ jobs: - name: Build for Linux/macOS if: startsWith(matrix.os, 'windows-') != true - run: go build -i -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo + run: go build -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo - name: Build for Windows if: startsWith(matrix.os, 'windows-') run: | $GIT_COMMIT = (git describe --always --dirty) | Out-String $DATE_TIME = ([datetime]::Now.ToUniversalTime().toString("yyyy-MM-ddTHH:mm:ssZ")) | Out-String - go build -i -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/version.date=$DATE_TIME" -o sftpgo.exe + go build -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/version.date=$DATE_TIME" -o sftpgo.exe - name: Initialize data provider run: ./sftpgo initprovider @@ -142,7 +142,7 @@ jobs: go-version: 1.14 - name: Build - run: go build -i -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo + run: go build -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo - name: Run tests using PostgreSQL provider run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9798e18..9d476c01 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -102,14 +102,14 @@ jobs: - name: Build for Linux/macOS if: startsWith(matrix.os, 'windows-') != true - run: go build -i -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo + run: go build -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo - name: Build for Windows if: startsWith(matrix.os, 'windows-') run: | $GIT_COMMIT = (git describe --always --dirty) | Out-String $DATE_TIME = ([datetime]::Now.ToUniversalTime().toString("yyyy-MM-ddTHH:mm:ssZ")) | Out-String - go build -i -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/version.date=$DATE_TIME" -o sftpgo.exe + go build -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/version.date=$DATE_TIME" -o sftpgo.exe - name: Initialize data provider run: ./sftpgo initprovider @@ -160,9 +160,9 @@ jobs: cp -r templates output/ if [ $OS == 'linux' ] then - cp -r init/sftpgo.service output/init/ + cp init/sftpgo.service output/init/ else - cp -r init/com.github.drakkan.sftpgo.plist output/init/ + cp init/com.github.drakkan.sftpgo.plist output/init/ fi ./sftpgo gen completion bash > output/bash_completion/sftpgo-completion.bash ./sftpgo gen completion zsh > output/zsh_completion/_sftpgo diff --git a/cmd/gencompletion.go b/cmd/gencompletion.go index cb403767..0d7c1dbc 100644 --- a/cmd/gencompletion.go +++ b/cmd/gencompletion.go @@ -16,24 +16,24 @@ var genCompletionCmd = &cobra.Command{ Bash: -$ source <(sftpgo completion bash) +$ source <(sftpgo gen completion bash) # To load completions for each session, execute once: Linux: - $ sftpgo completion bash > /etc/bash_completion.d/sftpgo-completion.bash + $ sftpgo gen completion bash > /etc/bash_completion.d/sftpgo-completion.bash MacOS: - $ sftpgo completion bash > /usr/local/etc/bash_completion.d/sftpgo-completion.bash + $ sftpgo gen completion bash > /usr/local/etc/bash_completion.d/sftpgo-completion.bash Zsh: -$ source <(sftpgo completion zsh) +$ source <(sftpgo gen completion zsh) # To load completions for each session, execute once: $ sftpgo completion zsh > "${fpath[1]}/_sftpgo" Fish: -$ sftpgo completion fish | source +$ sftpgo gen completion fish | source # To load completions for each session, execute once: $ sftpgo completion fish > ~/.config/fish/completions/sftpgo.fish diff --git a/docker/sftpgo/alpine/Dockerfile b/docker/sftpgo/alpine/Dockerfile index 5236f022..4f0a8420 100644 --- a/docker/sftpgo/alpine/Dockerfile +++ b/docker/sftpgo/alpine/Dockerfile @@ -7,7 +7,7 @@ ARG TAG ARG FEATURES # Use --build-arg TAG=LATEST for latest tag. Use e.g. --build-arg TAG=0.9.6 for a specific tag/commit. Otherwise HEAD (master) is built. RUN git checkout $(if [ "${TAG}" = LATEST ]; then echo `git rev-list --tags --max-count=1`; elif [ -n "${TAG}" ]; then echo "${TAG}"; else echo HEAD; fi) -RUN go build -i $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o /go/bin/sftpgo +RUN go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o /go/bin/sftpgo FROM alpine:latest diff --git a/docker/sftpgo/debian/Dockerfile b/docker/sftpgo/debian/Dockerfile index 1f3718c5..370ac50a 100644 --- a/docker/sftpgo/debian/Dockerfile +++ b/docker/sftpgo/debian/Dockerfile @@ -7,7 +7,7 @@ ARG TAG ARG FEATURES # Use --build-arg TAG=LATEST for latest tag. Use e.g. --build-arg TAG=0.9.6 for a specific tag/commit. Otherwise HEAD (master) is built. RUN git checkout $(if [ "${TAG}" = LATEST ]; then echo `git rev-list --tags --max-count=1`; elif [ -n "${TAG}" ]; then echo "${TAG}"; else echo HEAD; fi) -RUN go build -i $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo +RUN go build $(if [ -n "${FEATURES}" ]; then echo "-tags ${FEATURES}"; fi) -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo # now define the run environment FROM debian:latest diff --git a/docs/build-from-source.md b/docs/build-from-source.md index 292a9748..de8ebb83 100644 --- a/docs/build-from-source.md +++ b/docs/build-from-source.md @@ -36,7 +36,7 @@ Version info, such as git commit and build date, can be embedded setting the fol For example, you can build using the following command: ```bash -go build -i -tags nogcs,nos3,nosqlite -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo +go build -tags nogcs,nos3,nosqlite -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo ``` You should get a version that includes git commit, build date and available features like this one: diff --git a/docs/service.md b/docs/service.md index a27972e9..70abecd9 100644 --- a/docs/service.md +++ b/docs/service.md @@ -9,19 +9,22 @@ Here are some basic instructions to run SFTPGo as service, please run the follow ```bash # create the required directories sudo mkdir -p /etc/sftpgo \ - /var/lib/sftpgo + /var/lib/sftpgo \ + /usr/share/sftpgo # install sftpgo executable sudo install -Dm755 sftpgo /usr/bin/sftpgo # install the default configuration file, edit it if required sudo install -Dm644 sftpgo.json /etc/sftpgo/ # override some configuration keys using environment variables -sudo sh -c 'echo "SFTPGO_HTTPD__TEMPLATES_PATH=/var/lib/sftpgo/templates" > /etc/sftpgo/sftpgo.env' -sudo sh -c 'echo "SFTPGO_HTTPD__STATIC_FILES_PATH=/var/lib/sftpgo/static" >> /etc/sftpgo/sftpgo.env' +sudo sh -c 'echo "SFTPGO_HTTPD__TEMPLATES_PATH=/usr/share/sftpgo/templates" > /etc/sftpgo/sftpgo.env' +sudo sh -c 'echo "SFTPGO_HTTPD__STATIC_FILES_PATH=/usr/share/sftpgo/static" >> /etc/sftpgo/sftpgo.env' sudo sh -c 'echo "SFTPGO_HTTPD__BACKUPS_PATH=/var/lib/sftpgo/backups" >> /etc/sftpgo/sftpgo.env' sudo sh -c 'echo "SFTPGO_DATA_PROVIDER__CREDENTIALS_PATH=/var/lib/sftpgo/credentials" >> /etc/sftpgo/sftpgo.env' +# if you use a file based data provider such as sqlite or bolt consider to set the database path too, for example: +#sudo sh -c 'echo "SFTPGO_DATA_PROVIDER__NAME=/var/lib/sftpgo/sftpgo.db" >> /etc/sftpgo/sftpgo.env' # install static files and templates for the web UI -sudo cp -r static templates /var/lib/sftpgo/ +sudo cp -r static templates /usr/share/sftpgo/ # initialize the configured data provider # if you want to use MySQL or PostgreSQL you need to create the configured database before running the initprovider command sudo /usr/bin/sftpgo initprovider -c /etc/sftpgo/ @@ -35,6 +38,10 @@ sudo systemctl status sftpgo sudo systemctl enable sftpgo # optional, install the REST API CLI. It requires python-requests to run sudo install -Dm755 examples/rest-api-cli/sftpgo_api_cli.py /usr/bin/sftpgo_api_cli +# optional, create shell completion script, for example for bash +sudo /usr/bin/sftpgo gen completion bash > /etc/bash_completion.d/sftpgo-completion.bash +# optional, create man pages +sudo /usr/bin/sftpgo gen man -d /usr/share/man/man1 ``` ## macOS @@ -47,6 +54,7 @@ Here are some basic instructions to run SFTPGo as service, please run the follow # create the required directories sudo mkdir -p /usr/local/opt/sftpgo/init \ /usr/local/opt/sftpgo/var/lib \ + /usr/local/opt/sftpgo/usr/share \ /usr/local/opt/sftpgo/var/log \ /usr/local/opt/sftpgo/etc \ /usr/local/opt/sftpgo/bin @@ -59,7 +67,7 @@ sudo chown root:wheel /usr/local/opt/sftpgo/init/com.github.drakkan.sftpgo.plist # install the default configuration file, edit it if required sudo cp sftpgo.json /usr/local/opt/sftpgo/etc/ # install static files and templates for the web UI -sudo cp -r static templates /usr/local/opt/sftpgo/var/lib/ +sudo cp -r static templates /usr/local/opt/sftpgo/usr/share/ # initialize the configured data provider # if you want to use MySQL or PostgreSQL you need to create the configured database before running the initprovider command sudo /usr/local/opt/sftpgo/bin/sftpgo initprovider -c /usr/local/opt/sftpgo/etc/ diff --git a/examples/ldapauth/README.md b/examples/ldapauth/README.md index 7b29a573..eeacf2bc 100644 --- a/examples/ldapauth/README.md +++ b/examples/ldapauth/README.md @@ -7,7 +7,7 @@ You need to change the LDAP connection parameters and the user search query to m You can build this example using the following command: ```console -go build -i -ldflags "-s -w" -o ldapauth +go build -ldflags "-s -w" -o ldapauth ``` This program assumes that the 389ds schema was extended to add support for public keys using the following ldif file placed in `/etc/dirsrv/schema/98openssh-ldap.ldif`: diff --git a/examples/ldapauthserver/README.md b/examples/ldapauthserver/README.md index 61f3dad2..803e8acd 100644 --- a/examples/ldapauthserver/README.md +++ b/examples/ldapauthserver/README.md @@ -7,5 +7,5 @@ You can configure the server using the [ldapauth.toml](./ldapauth.toml) configur You can build this example using the following command: ```console -go build -i -ldflags "-s -w" -o ldapauthserver +go build -ldflags "-s -w" -o ldapauthserver ``` diff --git a/init/com.github.drakkan.sftpgo.plist b/init/com.github.drakkan.sftpgo.plist index 7f0801c3..062606ee 100644 --- a/init/com.github.drakkan.sftpgo.plist +++ b/init/com.github.drakkan.sftpgo.plist @@ -11,9 +11,9 @@ SFTPGO_LOG_FILE_PATH /usr/local/opt/sftpgo/var/log/sftpgo.log SFTPGO_HTTPD__TEMPLATES_PATH - /usr/local/opt/sftpgo/var/lib/templates + /usr/local/opt/sftpgo/usr/share/templates SFTPGO_HTTPD__STATIC_FILES_PATH - /usr/local/opt/sftpgo/var/lib/static + /usr/local/opt/sftpgo/usr/share/static SFTPGO_HTTPD__BACKUPS_PATH /usr/local/opt/sftpgo/var/lib/backups SFTPGO_DATA_PROVIDER__CREDENTIALS_PATH