mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03:00
Allow to read env vars from files inside the "env.d" directory
This makes it easier to set environment variables on some operating systems. Setting configuration options from environment variables is recommended if you want to avoid the time-consuming task of merging your changes with the default configuration file after upgrading SFTPGo Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -93,6 +93,9 @@ contents:
|
||||
- dst: "/var/lib/sftpgo"
|
||||
type: dir
|
||||
|
||||
- dst: "/etc/sftpgo/env.d"
|
||||
type: dir
|
||||
|
||||
overrides:
|
||||
deb:
|
||||
recommends:
|
||||
|
||||
@@ -22,6 +22,7 @@ Install-ChocolateyPackage @packageArgs
|
||||
|
||||
$DefaultDataPath = Join-Path -Path $ENV:ProgramData -ChildPath "SFTPGo"
|
||||
$DefaultConfigurationFilePath = Join-Path -Path $DefaultDataPath -ChildPath "sftpgo.json"
|
||||
$EnvDirPath = Join-Path -Path $DefaultDataPath -ChildPath "env.d"
|
||||
|
||||
# `t = tab
|
||||
Write-Output "---------------------------"
|
||||
@@ -38,7 +39,8 @@ Write-Output "Default data location:"
|
||||
Write-Output "`t$DefaultDataPath"
|
||||
Write-Output "Default configuration file location:"
|
||||
Write-Output "`t$DefaultConfigurationFilePath"
|
||||
Write-Output ""
|
||||
Write-Output "Directory to create environment variable files to set configuration options:"
|
||||
Write-Output "`t$EnvDirPath"
|
||||
Write-Output "If the SFTPGo service does not start, make sure that TCP ports 2022 and 8080 are"
|
||||
Write-Output "not used by other services or change the SFTPGo configuration to suit your needs."
|
||||
Write-Output ""
|
||||
|
||||
@@ -24,15 +24,15 @@ if [ "$1" = "configure" ]; then
|
||||
sftpgo initprovider -c /etc/sftpgo
|
||||
# ensure files and folders have the appropriate permissions
|
||||
chown -R sftpgo:sftpgo /etc/sftpgo /var/lib/sftpgo /srv/sftpgo
|
||||
chmod 750 /etc/sftpgo /var/lib/sftpgo /srv/sftpgo
|
||||
chmod 750 /etc/sftpgo /etc/sftpgo/env.d /var/lib/sftpgo /srv/sftpgo
|
||||
chmod 640 /etc/sftpgo/sftpgo.json
|
||||
fi
|
||||
|
||||
# we added /srv/sftpgo after 1.1.0, we should check if we are upgrading
|
||||
# from this version but a non-recursive chmod/chown shouldn't hurt
|
||||
if [ -d /srv/sftpgo ]; then
|
||||
chown sftpgo:sftpgo /srv/sftpgo
|
||||
chmod 750 /srv/sftpgo
|
||||
# we added /etc/sftpgo/env.d in v2.4.0, we should check if we are upgrading
|
||||
# from a previous version but a non-recursive chmod/chown shouldn't hurt
|
||||
if [ -d /etc/sftpgo/env.d ]; then
|
||||
chown sftpgo:sftpgo /etc/sftpgo/env.d
|
||||
chmod 750 /etc/sftpgo/env.d
|
||||
fi
|
||||
|
||||
# set the cap_net_bind_service capability so the service can bind to privileged ports
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
/var/lib/sftpgo
|
||||
/srv/sftpgo
|
||||
/etc/sftpgo/env.d
|
||||
|
||||
@@ -24,15 +24,15 @@ if [ "$1" = "configure" ]; then
|
||||
sftpgo initprovider -c /etc/sftpgo
|
||||
# ensure files and folders have the appropriate permissions
|
||||
chown -R sftpgo:sftpgo /etc/sftpgo /var/lib/sftpgo /srv/sftpgo
|
||||
chmod 750 /etc/sftpgo /var/lib/sftpgo /srv/sftpgo
|
||||
chmod 750 /etc/sftpgo /etc/sftpgo/env.d /var/lib/sftpgo /srv/sftpgo
|
||||
chmod 640 /etc/sftpgo/sftpgo.json
|
||||
fi
|
||||
|
||||
# we added /srv/sftpgo after 1.1.0, we should check if we are upgrading
|
||||
# from this version but a non-recursive chmod/chown shouldn't hurt
|
||||
if [ -d /srv/sftpgo ]; then
|
||||
chown sftpgo:sftpgo /srv/sftpgo
|
||||
chmod 750 /srv/sftpgo
|
||||
# we added /etc/sftpgo/env.d in v2.4.0, we should check if we are upgrading
|
||||
# from a previous version but a non-recursive chmod/chown shouldn't hurt
|
||||
if [ -d /etc/sftpgo/env.d ]; then
|
||||
chown sftpgo:sftpgo /etc/sftpgo/env.d
|
||||
chmod 750 /etc/sftpgo/env.d
|
||||
fi
|
||||
|
||||
# set the cap_net_bind_service capability so the service can bind to privileged ports
|
||||
|
||||
@@ -17,16 +17,21 @@ if [ $1 -eq 1 ]; then
|
||||
/usr/bin/sftpgo initprovider -c /etc/sftpgo
|
||||
# ensure files and folders have the appropriate permissions
|
||||
/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 750 /etc/sftpgo /etc/sftpgo/env.d /var/lib/sftpgo /srv/sftpgo
|
||||
/usr/bin/chmod 640 /etc/sftpgo/sftpgo.json
|
||||
fi
|
||||
|
||||
# adjust permissions for /srv/sftpgo and /var/lib/sftpgo
|
||||
# adjust permissions for /srv/sftpgo, /etc/sftpgo/env.d and /var/lib/sftpgo
|
||||
if [ -d /srv/sftpgo ]; then
|
||||
/usr/bin/chown sftpgo:sftpgo /srv/sftpgo
|
||||
/usr/bin/chmod 750 /srv/sftpgo
|
||||
fi
|
||||
|
||||
if [ -d /etc/sftpgo/env.d ]; then
|
||||
/usr/bin/chown sftpgo:sftpgo /etc/sftpgo/env.d
|
||||
/usr/bin/chmod 750 /etc/sftpgo/env.d
|
||||
fi
|
||||
|
||||
if [ -d /var/lib/sftpgo ]; then
|
||||
/usr/bin/chown sftpgo:sftpgo /var/lib/sftpgo
|
||||
/usr/bin/chmod 750 /var/lib/sftpgo
|
||||
|
||||
Reference in New Issue
Block a user