mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03:00
automatically build deb and rpm Linux packages
The packages are built after each tag/commit Fixes #176
This commit is contained in:
53
pkgs/scripts/deb/postinstall.sh
Normal file
53
pkgs/scripts/deb/postinstall.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/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
|
||||
# initialize data provider
|
||||
/usr/bin/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 /etc/sftpgo/sftpgo.env
|
||||
echo "Please be sure to have the python3-requests package installed if you want to use the REST API CLI"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
|
||||
# This will only remove masks created by d-s-h on package removal.
|
||||
deb-systemd-helper unmask sftpgo.service >/dev/null || true
|
||||
|
||||
# was-enabled defaults to true, so new installations run enable.
|
||||
if deb-systemd-helper --quiet was-enabled sftpgo.service; then
|
||||
# Enables the unit on first installation, creates new
|
||||
# symlinks on upgrades if the unit file has changed.
|
||||
deb-systemd-helper enable sftpgo.service >/dev/null || true
|
||||
deb-systemd-invoke start sftpgo.service >/dev/null || true
|
||||
else
|
||||
# Update the statefile to add new symlinks (if any), which need to be
|
||||
# cleaned up on purge. Also remove old symlinks.
|
||||
deb-systemd-helper update-state sftpgo.service >/dev/null || true
|
||||
fi
|
||||
|
||||
# Restart only if it was already started
|
||||
if [ -d /run/systemd/system ]; then
|
||||
systemctl --system daemon-reload >/dev/null || true
|
||||
if [ -n "$2" ]; then
|
||||
deb-systemd-invoke try-restart sftpgo.service >/dev/null || true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
19
pkgs/scripts/deb/postremove.sh
Normal file
19
pkgs/scripts/deb/postremove.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ -d /run/systemd/system ]; then
|
||||
systemctl --system daemon-reload >/dev/null || true
|
||||
fi
|
||||
|
||||
if [ "$1" = "remove" ]; then
|
||||
if [ -x "/usr/bin/deb-systemd-helper" ]; then
|
||||
deb-systemd-helper mask sftpgo.service >/dev/null || true
|
||||
fi
|
||||
fi
|
||||
|
||||
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
|
||||
6
pkgs/scripts/deb/preremove.sh
Normal file
6
pkgs/scripts/deb/preremove.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
|
||||
deb-systemd-invoke stop sftpgo.service >/dev/null || true
|
||||
fi
|
||||
25
pkgs/scripts/rpm/postinstall
Normal file
25
pkgs/scripts/rpm/postinstall
Normal file
@@ -0,0 +1,25 @@
|
||||
if [ $1 -eq 1 ]; then
|
||||
# Initial installation
|
||||
# Add user and group
|
||||
if ! getent group sftpgo >/dev/null; then
|
||||
/usr/sbin/groupadd --system sftpgo
|
||||
fi
|
||||
if ! getent passwd sftpgo >/dev/null; then
|
||||
/usr/sbin/useradd --system \
|
||||
--gid sftpgo \
|
||||
--no-create-home \
|
||||
--home-dir /var/lib/sftpgo \
|
||||
--shell /sbin/nologin \
|
||||
--comment "SFTPGo user" \
|
||||
sftpgo
|
||||
fi
|
||||
# initialize data provider
|
||||
/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
|
||||
/usr/bin/chmod 750 /etc/sftpgo /var/lib/sftpgo
|
||||
/usr/bin/chmod 640 /etc/sftpgo/sftpgo.json /etc/sftpgo/sftpgo.env
|
||||
echo "Please be sure to have the python requests library installed if you want to use the REST API CLI"
|
||||
fi
|
||||
# reload to pick up any changes to systemd files
|
||||
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
||||
5
pkgs/scripts/rpm/postremove
Normal file
5
pkgs/scripts/rpm/postremove
Normal file
@@ -0,0 +1,5 @@
|
||||
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
||||
if [ $1 -ge 1 ]; then
|
||||
# Package upgrade, not uninstall
|
||||
/bin/systemctl try-restart sftpgo.service >/dev/null 2>&1 || :
|
||||
fi
|
||||
5
pkgs/scripts/rpm/preremove
Normal file
5
pkgs/scripts/rpm/preremove
Normal file
@@ -0,0 +1,5 @@
|
||||
if [ $1 -eq 0 ]; then
|
||||
# Package removal, not upgrade
|
||||
/bin/systemctl --no-reload disable sftpgo.service >/dev/null 2>&1 || :
|
||||
/bin/systemctl stop sftpgo.service >/dev/null 2>&1 || :
|
||||
fi
|
||||
Reference in New Issue
Block a user