diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index ac888bdd..bfbed3e5 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -81,8 +81,8 @@ jobs: cp -r templates output/ cp -r static output/ cp -r init output/ - cp examples/rest-api-cli/sftpgo_api_cli.py output/examples/rest-api-cli/ - ./sftpgo gen completion bash > output/bash_completion/sftpgo-completion.bash + cp examples/rest-api-cli/sftpgo_api_cli output/examples/rest-api-cli/ + ./sftpgo gen completion bash > output/bash_completion/sftpgo ./sftpgo gen completion zsh > output/zsh_completion/_sftpgo ./sftpgo gen man -d output/man/man1 gzip output/man/man1/* diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4381c937..9d1cf6a0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -75,7 +75,7 @@ jobs: COMMIT_SHA=${{ steps.info.outputs.sha }} platforms: linux/amd64,linux/arm64 labels: | - org.opencontainers.image.title=SFTPGo + org.opencontainers.image.title=${{ fromJson(steps.repo.outputs.result).name }} org.opencontainers.image.description=Fully featured and highly configurable SFTP server with optional FTP/S and WebDAV support org.opencontainers.image.url=${{ fromJson(steps.repo.outputs.result).html_url }} org.opencontainers.image.documentation=${{ fromJson(steps.repo.outputs.result).html_url }}/blob/${{ github.sha }}/docker/README.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e73cff4..3b7770e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -139,7 +139,7 @@ jobs: pip install requests pip install pygments pip install pyinstaller - pyinstaller --hidden-import="pkg_resources.py2_warn" --noupx --onefile examples\rest-api-cli\sftpgo_api_cli.py + pyinstaller --hidden-import="pkg_resources.py2_warn" --noupx --onefile examples\rest-api-cli\sftpgo_api_cli - name: Prepare Release for Linux/macOS if: startsWith(matrix.os, 'windows-') != true @@ -160,11 +160,11 @@ jobs: else cp init/com.github.drakkan.sftpgo.plist output/init/ fi - ./sftpgo gen completion bash > output/bash_completion/sftpgo-completion.bash + ./sftpgo gen completion bash > output/bash_completion/sftpgo ./sftpgo gen completion zsh > output/zsh_completion/_sftpgo ./sftpgo gen man -d output/man/man1 gzip output/man/man1/* - cp examples/rest-api-cli/sftpgo_api_cli.py output/examples/rest-api-cli/ + cp examples/rest-api-cli/sftpgo_api_cli output/examples/rest-api-cli/ cd output tar cJvf sftpgo_${SFTPGO_VERSION}_${OS}_x86_64.tar.xz * cd .. diff --git a/README.md b/README.md index 9768fa0e..d7d5390d 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ Some Linux distro packages are available: - [sftpgo-bin](https://aur.archlinux.org/packages/sftpgo-bin/). This package follows stable releases downloading the prebuilt linux binary from GitHub. It does not require `git`, `gcc` and `go` to build. - [sftpgo-git](https://aur.archlinux.org/packages/sftpgo-git/). This package builds and installs the latest git master. It requires `git`, `gcc` and `go` to build. - Deb and RPM packages are built after each commit and for each release. +- An Ubuntu PPA is available [here](https://launchpad.net/~sftpgo/+archive/ubuntu/sftpgo). You can easily test new features selecting a commit from the [Actions](https://github.com/drakkan/sftpgo/actions) page and downloading the matching build artifacts for Linux, macOS or Windows. GitHub stores artifacts for 90 days. diff --git a/docker/rest-api-cli/Dockerfile b/docker/rest-api-cli/Dockerfile index f1b21ddd..e93a9259 100644 --- a/docker/rest-api-cli/Dockerfile +++ b/docker/rest-api-cli/Dockerfile @@ -2,7 +2,7 @@ FROM debian:latest LABEL maintainer="nicola.murino@gmail.com" RUN apt-get update && apt-get install -y curl python3-requests python3-pygments -RUN curl https://raw.githubusercontent.com/drakkan/sftpgo/master/examples/rest-api-cli/sftpgo_api_cli.py --output /usr/bin/sftpgo_api_cli.py +RUN curl https://raw.githubusercontent.com/drakkan/sftpgo/master/examples/rest-api-cli/sftpgo_api_cli --output /usr/bin/sftpgo_api_cli -ENTRYPOINT ["python3", "/usr/bin/sftpgo_api_cli.py" ] +ENTRYPOINT ["python3", "/usr/bin/sftpgo_api_cli" ] CMD [] \ No newline at end of file diff --git a/docs/account.md b/docs/account.md index 8305f879..5ffc6a77 100644 --- a/docs/account.md +++ b/docs/account.md @@ -66,5 +66,5 @@ These properties are stored inside the data provider. If you want to use your existing accounts, you have these options: - If your accounts are already stored inside a supported database, you can create a database view. Since a view is read only, you have to disable user management and quota tracking so SFTPGo will never try to write to the view -- you can import your users inside SFTPGo. Take a look at [sftpgo_api_cli.py](../examples/rest-api-cli#convert-users-from-other-stores "SFTPGo API CLI example"), it can convert and import users from Linux system users and Pure-FTPd/ProFTPD virtual users +- you can import your users inside SFTPGo. Take a look at [sftpgo_api_cli](../examples/rest-api-cli#convert-users-from-other-stores "SFTPGo API CLI example"), it can convert and import users from Linux system users and Pure-FTPd/ProFTPD virtual users - you can use an external authentication program diff --git a/docs/service.md b/docs/service.md index 8bd82bdf..123fa8df 100644 --- a/docs/service.md +++ b/docs/service.md @@ -62,9 +62,9 @@ sudo systemctl status sftpgo # automatically start sftpgo on boot 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 +sudo install -Dm755 examples/rest-api-cli/sftpgo_api_cli /usr/bin/sftpgo_api_cli # optional, create shell completion script, for example for bash -sudo sh -c '/usr/bin/sftpgo gen completion bash > /etc/bash_completion.d/sftpgo-completion.bash' +sudo sh -c '/usr/bin/sftpgo gen completion bash > /usr/share/bash-completion/completions/sftpgo' # optional, create man pages sudo /usr/bin/sftpgo gen man -d /usr/share/man/man1 ``` @@ -103,7 +103,7 @@ sudo launchctl load -w /Library/LaunchDaemons/com.github.drakkan.sftpgo.plist # verify that the service is started sudo launchctl list com.github.drakkan.sftpgo # optional, install the REST API CLI. It requires python-requests to run, this python module is not installed by default -sudo cp examples/rest-api-cli/sftpgo_api_cli.py /usr/local/opt/sftpgo/bin/ +sudo cp examples/rest-api-cli/sftpgo_api_cli /usr/local/opt/sftpgo/bin/ ``` ## Windows diff --git a/examples/rest-api-cli/README.md b/examples/rest-api-cli/README.md index 29757641..6ebd7f48 100644 --- a/examples/rest-api-cli/README.md +++ b/examples/rest-api-cli/README.md @@ -1,6 +1,6 @@ # REST API CLI client -`sftpgo_api_cli.py` is a very simple command line client for `SFTPGo` REST API written in python. +`sftpgo_api_cli` is a very simple command line client for `SFTPGo` REST API written in python. It has the following requirements: @@ -11,13 +11,13 @@ It has the following requirements: You can see the usage with the following command: ```console -python sftpgo_api_cli.py --help +python sftpgo_api_cli --help ``` and ```console -python sftpgo_api_cli.py [sub-command] --help +python sftpgo_api_cli [sub-command] --help ``` Basically there is a sub command for each REST API and the following global arguments: @@ -33,7 +33,7 @@ Basically there is a sub command for each REST API and the following global argu For each subcommand `--help` shows the available arguments, try for example: -```python sftpgo_api_cli.py add_user --help``` +```python sftpgo_api_cli add_user --help``` Additionally it can convert users to the SFTPGo format from some supported users stores @@ -44,7 +44,7 @@ Let's see a sample usage for each REST API. Command: ```console -python sftpgo_api_cli.py add-user test_username --password "test_pwd" --home-dir="/tmp/test_home_dir" --uid 33 --gid 1000 --max-sessions 2 --quota-size 0 --quota-files 3 --permissions "list" "download" "upload" "delete" "rename" "create_dirs" "overwrite" --subdirs-permissions "/dir1::list,download" "/dir2::*" --upload-bandwidth 100 --download-bandwidth 60 --status 0 --expiration-date 2019-01-01 --allowed-ip "192.168.1.1/32" --fs S3 --s3-bucket test --s3-region eu-west-1 --s3-access-key accesskey --s3-access-secret secret --s3-endpoint "http://127.0.0.1:9000" --s3-storage-class Standard --s3-key-prefix "vfolder/" --s3-upload-part-size 10 --s3-upload-concurrency 4 --denied-login-methods "password" "keyboard-interactive" --allowed-extensions "/dir1::.jpg,.png" "/dir2::.rar,.png" --denied-extensions "/dir3::.zip,.rar" --denied-protocols DAV FTP +python sftpgo_api_cli add-user test_username --password "test_pwd" --home-dir="/tmp/test_home_dir" --uid 33 --gid 1000 --max-sessions 2 --quota-size 0 --quota-files 3 --permissions "list" "download" "upload" "delete" "rename" "create_dirs" "overwrite" --subdirs-permissions "/dir1::list,download" "/dir2::*" --upload-bandwidth 100 --download-bandwidth 60 --status 0 --expiration-date 2019-01-01 --allowed-ip "192.168.1.1/32" --fs S3 --s3-bucket test --s3-region eu-west-1 --s3-access-key accesskey --s3-access-secret secret --s3-endpoint "http://127.0.0.1:9000" --s3-storage-class Standard --s3-key-prefix "vfolder/" --s3-upload-part-size 10 --s3-upload-concurrency 4 --denied-login-methods "password" "keyboard-interactive" --allowed-extensions "/dir1::.jpg,.png" "/dir2::.rar,.png" --denied-extensions "/dir3::.zip,.rar" --denied-protocols DAV FTP ``` Output: @@ -144,7 +144,7 @@ Output: Command: ```console -python sftpgo_api_cli.py update-user 9576 test_username --password "test_pwd" --home-dir="/tmp/test_home_dir" --uid 0 --gid 33 --max-sessions 3 --quota-size 0 --quota-files 4 --permissions "*" --subdirs-permissions "/dir1::list,download,create_symlinks" --upload-bandwidth 90 --download-bandwidth 80 --status 1 --expiration-date "" --allowed-ip "" --denied-ip "192.168.1.0/24" --denied-login-methods "" --fs local --virtual-folders "/vdir1::/tmp/mapped1::-1::-1" "/vdir2::/tmp/mapped2::100::104857600" --allowed-extensions "" --denied-extensions "" --max-upload-file-size 104857600 --denied-protocols "" +python sftpgo_api_cli update-user 9576 test_username --password "test_pwd" --home-dir="/tmp/test_home_dir" --uid 0 --gid 33 --max-sessions 3 --quota-size 0 --quota-files 4 --permissions "*" --subdirs-permissions "/dir1::list,download,create_symlinks" --upload-bandwidth 90 --download-bandwidth 80 --status 1 --expiration-date "" --allowed-ip "" --denied-ip "192.168.1.0/24" --denied-login-methods "" --fs local --virtual-folders "/vdir1::/tmp/mapped1::-1::-1" "/vdir2::/tmp/mapped2::100::104857600" --allowed-extensions "" --denied-extensions "" --max-upload-file-size 104857600 --denied-protocols "" ``` Output: @@ -164,7 +164,7 @@ You can set the argument `--disconnect` to `1` to disconnect the user, if connec Command: ```console -python sftpgo_api_cli.py get-user-by-id 9576 +python sftpgo_api_cli get-user-by-id 9576 ``` Output: @@ -261,7 +261,7 @@ Output: Command: ```console -python sftpgo_api_cli.py get-users --limit 1 --offset 0 --username test_username --order DESC +python sftpgo_api_cli get-users --limit 1 --offset 0 --username test_username --order DESC ``` Output: @@ -326,7 +326,7 @@ Output: Command: ```console -python sftpgo_api_cli.py get-connections +python sftpgo_api_cli get-connections ``` Output: @@ -358,7 +358,7 @@ Output: Command: ```console -python sftpgo_api_cli.py get-folders --limit 1 --offset 0 --folder-path /tmp/mapped1 --order DESC +python sftpgo_api_cli get-folders --limit 1 --offset 0 --folder-path /tmp/mapped1 --order DESC ``` Output: @@ -381,7 +381,7 @@ Output: ## Add folder ```console -python sftpgo_api_cli.py add-folder /tmp/mapped_folder +python sftpgo_api_cli add-folder /tmp/mapped_folder ``` Output: @@ -401,7 +401,7 @@ Output: Command: ```console -python sftpgo_api_cli.py close-connection f82cfec6a391ad673edd4ae9a144f32ccb59456139f8e1185b070134fffbab7c +python sftpgo_api_cli close-connection f82cfec6a391ad673edd4ae9a144f32ccb59456139f8e1185b070134fffbab7c ``` Output: @@ -419,7 +419,7 @@ Output: Command: ```console -python sftpgo_api_cli.py get-quota-scans +python sftpgo_api_cli get-quota-scans ``` ## Start quota scan @@ -427,7 +427,7 @@ python sftpgo_api_cli.py get-quota-scans Command: ```console -python sftpgo_api_cli.py start-quota-scan test_username +python sftpgo_api_cli start-quota-scan test_username ``` Output: @@ -445,7 +445,7 @@ Output: Command: ```console -python sftpgo_api_cli.py get-folders-quota-scans +python sftpgo_api_cli get-folders-quota-scans ``` ## Start folder quota scan @@ -453,7 +453,7 @@ python sftpgo_api_cli.py get-folders-quota-scans Command: ```console -python sftpgo_api_cli.py start-folder-quota-scan /tmp/mapped_folder +python sftpgo_api_cli start-folder-quota-scan /tmp/mapped_folder ``` Output: @@ -471,7 +471,7 @@ Output: Command: ```console -python sftpgo_api_cli.py -d update-quota-usage a -S 123 -F 1 -M reset +python sftpgo_api_cli -d update-quota-usage a -S 123 -F 1 -M reset ``` Output: @@ -489,7 +489,7 @@ Output: Command: ```console -python sftpgo_api_cli.py -d update-quota-usage /tmp/mapped_folder -S 123 -F 1 -M add +python sftpgo_api_cli -d update-quota-usage /tmp/mapped_folder -S 123 -F 1 -M add ``` Output: @@ -507,7 +507,7 @@ Output: Command: ```console -python sftpgo_api_cli.py delete-user 9576 +python sftpgo_api_cli delete-user 9576 ``` Output: @@ -523,7 +523,7 @@ Output: ## Delete folder ```console -python sftpgo_api_cli.py delete-folder /tmp/mapped_folder +python sftpgo_api_cli delete-folder /tmp/mapped_folder ``` Output: @@ -541,7 +541,7 @@ Output: Command: ```console -python sftpgo_api_cli.py get-version +python sftpgo_api_cli get-version ``` Output: @@ -559,7 +559,7 @@ Output: Command: ```console -python sftpgo_api_cli.py get-provider-status +python sftpgo_api_cli get-provider-status ``` Output: @@ -577,7 +577,7 @@ Output: Command: ```console -python sftpgo_api_cli.py dumpdata backup.json --indent 1 +python sftpgo_api_cli dumpdata backup.json --indent 1 ``` Output: @@ -595,7 +595,7 @@ Output: Command: ```console -python sftpgo_api_cli.py loaddata /app/data/backups/backup.json --scan-quota 2 --mode 0 +python sftpgo_api_cli loaddata /app/data/backups/backup.json --scan-quota 2 --mode 0 ``` Output: @@ -619,21 +619,21 @@ You can convert users to the SFTPGo format from the following users stores: For details give a look at the `convert-users` subcommand usage: ```console -python sftpgo_api_cli.py convert-users --help +python sftpgo_api_cli convert-users --help ``` Let's see some examples: ```console -python sftpgo_api_cli.py convert-users "" unix-passwd unix_users.json --min-uid 500 --force-uid 1000 --force-gid 1000 +python sftpgo_api_cli convert-users "" unix-passwd unix_users.json --min-uid 500 --force-uid 1000 --force-gid 1000 ``` ```console -python sftpgo_api_cli.py convert-users pureftpd.passwd pure-ftpd pure_users.json --usernames "user1" "user2" +python sftpgo_api_cli convert-users pureftpd.passwd pure-ftpd pure_users.json --usernames "user1" "user2" ``` ```console -python sftpgo_api_cli.py convert-users proftpd.passwd proftpd pro_users.json +python sftpgo_api_cli convert-users proftpd.passwd proftpd pro_users.json ``` The json file generated using the `convert-users` subcommand can be used as input for the `loaddata` subcommand. diff --git a/examples/rest-api-cli/sftpgo_api_cli.py b/examples/rest-api-cli/sftpgo_api_cli similarity index 100% rename from examples/rest-api-cli/sftpgo_api_cli.py rename to examples/rest-api-cli/sftpgo_api_cli diff --git a/pkgs/build.sh b/pkgs/build.sh index 8f729a79..06146d47 100755 --- a/pkgs/build.sh +++ b/pkgs/build.sh @@ -40,19 +40,19 @@ maintainer: "Nicola Murino " provides: - sftpgo description: | - Fully featured and highly configurable SFTP server. - SFTPGo has optional FTP/S and WebDAV support. - It can serve local filesystem, S3 (Compatible) Object Storages - and Google Cloud Storage + Fully featured and highly configurable SFTP server + SFTPGo has optional FTP/S and WebDAV support. + It can serve local filesystem, S3 (Compatible) Object Storages + and Google Cloud Storage vendor: "SFTPGo" homepage: "https://github.com/drakkan/sftpgo" license: "GPL-3.0" files: ${BASE_DIR}/sftpgo: "/usr/bin/sftpgo" - ./sftpgo-completion.bash: "/etc/bash_completion.d/sftpgo-completion.bash" + ./sftpgo-completion.bash: "/usr/share/bash-completion/completions/sftpgo" ./man1/*: "/usr/share/man/man1/" ${BASE_DIR}/init/sftpgo.service: "/lib/systemd/system/sftpgo.service" - ${BASE_DIR}/examples/rest-api-cli/sftpgo_api_cli.py: "/usr/bin/sftpgo_api_cli" + ${BASE_DIR}/examples/rest-api-cli/sftpgo_api_cli: "/usr/bin/sftpgo_api_cli" ${BASE_DIR}/templates/*: "/usr/share/sftpgo/templates/" ${BASE_DIR}/static/**/*: "/usr/share/sftpgo/static/" @@ -67,6 +67,7 @@ overrides: recommends: - bash-completion - python3-requests + - python3-pygments scripts: postinstall: ../scripts/deb/postinstall.sh preremove: ../scripts/deb/preremove.sh diff --git a/pkgs/scripts/deb/postinstall.sh b/pkgs/scripts/deb/postinstall.sh index b658acac..16c84599 100644 --- a/pkgs/scripts/deb/postinstall.sh +++ b/pkgs/scripts/deb/postinstall.sh @@ -18,12 +18,12 @@ if [ "$1" = "configure" ]; then if [ -z "$2" ]; then # initialize data provider - /usr/bin/sftpgo initprovider -c /etc/sftpgo + sftpgo initprovider -c /etc/sftpgo # ensure files and folders have the appropriate permissions chown -R sftpgo:sftpgo /etc/sftpgo /var/lib/sftpgo chmod 750 /etc/sftpgo /var/lib/sftpgo chmod 640 /etc/sftpgo/sftpgo.json - echo "Please be sure to have the python3-requests package installed if you want to use the REST API CLI" + echo "Please be sure to have the python3-requests package installed if you want to use the REST API CLI" fi fi