From 555394b95eedf98658d73f113697454489f60e6f Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Wed, 14 Oct 2020 22:25:58 +0200 Subject: [PATCH] Linux pkgs: move data directory to /srv/sftpgo --- docker/sftpgo/alpine/README.md | 2 +- docker/sftpgo/debian/README.md | 2 +- pkgs/build.sh | 2 +- pkgs/debian/postinst | 11 ++++++++++- pkgs/scripts/deb/postinstall.sh | 9 +++++++++ pkgs/scripts/deb/postremove.sh | 1 + pkgs/scripts/rpm/postinstall | 12 +++++++++++- 7 files changed, 34 insertions(+), 5 deletions(-) diff --git a/docker/sftpgo/alpine/README.md b/docker/sftpgo/alpine/README.md index 076b7f2b..d9ba2090 100644 --- a/docker/sftpgo/alpine/README.md +++ b/docker/sftpgo/alpine/README.md @@ -1,6 +1,6 @@ # SFTPGo with Docker and Alpine -:warning: The recommended way to run SFTPGo on Docker is to use the official [images](https://github.com/users/drakkan/packages/container/package/sftpgo). The documentation here is now obsolete. +:warning: The recommended way to run SFTPGo on Docker is to use the official [images](https://hub.docker.com/r/drakkan/sftpgo). The documentation here is now obsolete. This DockerFile is made to build image to host multiple instances of SFTPGo started with different users. diff --git a/docker/sftpgo/debian/README.md b/docker/sftpgo/debian/README.md index 39551249..4bb5fe48 100644 --- a/docker/sftpgo/debian/README.md +++ b/docker/sftpgo/debian/README.md @@ -1,6 +1,6 @@ # Dockerfile based on Debian stable -:warning: The recommended way to run SFTPGo on Docker is to use the official [images](https://github.com/users/drakkan/packages/container/package/sftpgo). The documentation here is now obsolete. +:warning: The recommended way to run SFTPGo on Docker is to use the official [images](https://hub.docker.com/r/drakkan/sftpgo). The documentation here is now obsolete. Please read the comments inside the `Dockerfile` to learn how to customize things for your setup. diff --git a/pkgs/build.sh b/pkgs/build.sh index 93cd6681..6717f015 100755 --- a/pkgs/build.sh +++ b/pkgs/build.sh @@ -61,7 +61,7 @@ config_files: empty_folders: - /var/lib/sftpgo - - /srv/sftpgo/data + - /srv/sftpgo overrides: deb: diff --git a/pkgs/debian/postinst b/pkgs/debian/postinst index 95b7e587..c7034105 100644 --- a/pkgs/debian/postinst +++ b/pkgs/debian/postinst @@ -28,6 +28,15 @@ if [ "$1" = "configure" ]; then 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" fi + + # check permissions for /srv/sftpgo and adjust them if needed + if [ -d /srv/sftpgo ]; then + if [ $(stat -c '%U' /srv/sftpgo) != sftpgo ]; then + echo "Set permissions for /srv/sftpgo" + chown -R sftpgo:sftpgo /srv/sftpgo + chmod 750 /srv/sftpgo + fi + fi fi -#DEBHELPER# \ No newline at end of file +#DEBHELPER# diff --git a/pkgs/scripts/deb/postinstall.sh b/pkgs/scripts/deb/postinstall.sh index 5478c362..fe80bfa4 100644 --- a/pkgs/scripts/deb/postinstall.sh +++ b/pkgs/scripts/deb/postinstall.sh @@ -28,6 +28,15 @@ if [ "$1" = "configure" ]; then 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" fi + + # check permissions for /srv/sftpgo and adjust them if needed + if [ -d /srv/sftpgo ]; then + if [ $(stat -c '%U' /srv/sftpgo) != sftpgo ]; then + echo "Set permissions for /srv/sftpgo" + chown -R sftpgo:sftpgo /srv/sftpgo + chmod 750 /srv/sftpgo + fi + fi fi if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then diff --git a/pkgs/scripts/deb/postremove.sh b/pkgs/scripts/deb/postremove.sh index 3a4021b1..ad7a5946 100644 --- a/pkgs/scripts/deb/postremove.sh +++ b/pkgs/scripts/deb/postremove.sh @@ -15,4 +15,5 @@ if [ "$1" = "purge" ]; then if [ -x "/usr/bin/deb-systemd-helper" ]; then deb-systemd-helper purge 'sftpgo.service' >/dev/null || true deb-systemd-helper unmask 'sftpgo.service' >/dev/null || true + fi fi diff --git a/pkgs/scripts/rpm/postinstall b/pkgs/scripts/rpm/postinstall index 0ca4550b..993c1a55 100644 --- a/pkgs/scripts/rpm/postinstall +++ b/pkgs/scripts/rpm/postinstall @@ -19,7 +19,17 @@ if [ $1 -eq 1 ]; then /usr/bin/chown -R sftpgo:sftpgo /etc/sftpgo /var/lib/sftpgo /srv/sftpgo /usr/bin/chmod 750 /etc/sftpgo /var/lib/sftpgo /srv/sftpgo /usr/bin/chmod 640 /etc/sftpgo/sftpgo.json - echo "Please be sure to have the python requests library installed if you want to use the REST API CLI" + /bin/echo "Please be sure to have the python requests library installed if you want to use the REST API CLI" fi + +# check permissions for /srv/sftpgo and adjust them if needed +if [ -d /srv/sftpgo ]; then + if [ $(/usr/bin/stat -c '%U' /srv/sftpgo) != sftpgo ]; then + /bin/echo "Set permissions for /srv/sftpgo" + /usr/bin/chown -R sftpgo:sftpgo /srv/sftpgo + /usr/bin/chmod 750 /srv/sftpgo + fi +fi + # reload to pick up any changes to systemd files /bin/systemctl daemon-reload >/dev/null 2>&1 || :