2020-10-08 16:20:15 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ "$1" = "configure" ]; then
|
|
|
|
# Add user and group
|
|
|
|
if ! getent group sftpgo >/dev/null; then
|
|
|
|
groupadd --system sftpgo
|
|
|
|
fi
|
|
|
|
if ! getent passwd sftpgo >/dev/null; then
|
|
|
|
useradd --system \
|
|
|
|
--gid sftpgo \
|
|
|
|
--no-create-home \
|
|
|
|
--home-dir /var/lib/sftpgo \
|
|
|
|
--shell /usr/sbin/nologin \
|
|
|
|
--comment "SFTPGo user" \
|
|
|
|
sftpgo
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$2" ]; then
|
2020-10-14 05:46:36 +00:00
|
|
|
# if configure has no args this is the first installation
|
|
|
|
# for upgrades the second arg is the previously installed version
|
|
|
|
#
|
2020-10-08 16:20:15 +00:00
|
|
|
# initialize data provider
|
|
|
|
sftpgo initprovider -c /etc/sftpgo
|
|
|
|
# ensure files and folders have the appropriate permissions
|
2020-10-14 05:46:36 +00:00
|
|
|
chown -R sftpgo:sftpgo /etc/sftpgo /var/lib/sftpgo /srv/sftpgo
|
|
|
|
chmod 750 /etc/sftpgo /var/lib/sftpgo /srv/sftpgo
|
2020-10-08 16:20:15 +00:00
|
|
|
chmod 640 /etc/sftpgo/sftpgo.json
|
|
|
|
fi
|
2020-10-14 20:25:58 +00:00
|
|
|
|
2020-10-15 08:01:31 +00:00
|
|
|
# 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
|
2020-10-14 20:25:58 +00:00
|
|
|
if [ -d /srv/sftpgo ]; then
|
2020-10-15 08:01:31 +00:00
|
|
|
chown sftpgo:sftpgo /srv/sftpgo
|
|
|
|
chmod 750 /srv/sftpgo
|
2020-10-14 20:25:58 +00:00
|
|
|
fi
|
2020-10-15 08:01:31 +00:00
|
|
|
|
2020-10-08 16:20:15 +00:00
|
|
|
fi
|
|
|
|
|
2020-10-14 20:25:58 +00:00
|
|
|
#DEBHELPER#
|