debian/postinst: add checks, be verbose

Do not attempt to change permissions/ownership if the package gets
upgraded from a version higher than the next release.

Do not fail if the user deleted the config file.

Be verbose when changing permissions.

Related: OS#4107
Change-Id: I853097a13e27b2ebd0b940117c8f5f4b3ea49b9a
This commit is contained in:
Oliver Smith 2024-05-14 15:20:34 +02:00
parent abfe4e1643
commit 705a48e8f7
1 changed files with 14 additions and 6 deletions

View File

@ -16,12 +16,20 @@ case "$1" in
fi
# Fix permissions of previous (root-owned) install (OS#4107)
chown osmocom:osmocom /etc/osmocom/osmo-stp.cfg
chmod 0660 /etc/osmocom/osmo-stp.cfg
chown root:osmocom /etc/osmocom
chmod 2775 /etc/osmocom
mkdir -p /var/lib/osmocom
chown -R osmocom:osmocom /var/lib/osmocom
if dpkg --compare-versions "$2" le "1.9.0"; then
if [ -e /etc/osmocom/osmo-stp.cfg ]; then
chown -v osmocom:osmocom /etc/osmocom/osmo-stp.cfg
chmod -v 0660 /etc/osmocom/osmo-stp.cfg
fi
if [ -d /etc/osmocom ]; then
chown -v root:osmocom /etc/osmocom
chmod -v 2775 /etc/osmocom
fi
mkdir -p /var/lib/osmocom
chown -R -v osmocom:osmocom /var/lib/osmocom
fi
;;
esac