Skip to content

Commit

Permalink
remove py extension from REST API CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
drakkan committed Oct 8, 2020
1 parent 8034f28 commit f22fe6a
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ..
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions docker/rest-api-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
2 changes: 1 addition & 1 deletion docs/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions docs/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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
Expand Down
56 changes: 28 additions & 28 deletions examples/rest-api-cli/README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -326,7 +326,7 @@ Output:
Command:

```console
python sftpgo_api_cli.py get-connections
python sftpgo_api_cli get-connections
```

Output:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -401,7 +401,7 @@ Output:
Command:

```console
python sftpgo_api_cli.py close-connection f82cfec6a391ad673edd4ae9a144f32ccb59456139f8e1185b070134fffbab7c
python sftpgo_api_cli close-connection f82cfec6a391ad673edd4ae9a144f32ccb59456139f8e1185b070134fffbab7c
```

Output:
Expand All @@ -419,15 +419,15 @@ Output:
Command:

```console
python sftpgo_api_cli.py get-quota-scans
python sftpgo_api_cli get-quota-scans
```

## Start quota scan

Command:

```console
python sftpgo_api_cli.py start-quota-scan test_username
python sftpgo_api_cli start-quota-scan test_username
```

Output:
Expand All @@ -445,15 +445,15 @@ Output:
Command:

```console
python sftpgo_api_cli.py get-folders-quota-scans
python sftpgo_api_cli get-folders-quota-scans
```

## Start folder quota scan

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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -507,7 +507,7 @@ Output:
Command:

```console
python sftpgo_api_cli.py delete-user 9576
python sftpgo_api_cli delete-user 9576
```

Output:
Expand All @@ -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:
Expand All @@ -541,7 +541,7 @@ Output:
Command:

```console
python sftpgo_api_cli.py get-version
python sftpgo_api_cli get-version
```

Output:
Expand All @@ -559,7 +559,7 @@ Output:
Command:

```console
python sftpgo_api_cli.py get-provider-status
python sftpgo_api_cli get-provider-status
```

Output:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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.
Expand Down
File renamed without changes.
13 changes: 7 additions & 6 deletions pkgs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ maintainer: "Nicola Murino <nicola.murino@gmail.com>"
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/"
Expand All @@ -67,6 +67,7 @@ overrides:
recommends:
- bash-completion
- python3-requests
- python3-pygments
scripts:
postinstall: ../scripts/deb/postinstall.sh
preremove: ../scripts/deb/preremove.sh
Expand Down
4 changes: 2 additions & 2 deletions pkgs/scripts/deb/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f22fe6a

Please sign in to comment.