From: Matthias Kruk Date: Fri, 21 Jan 2022 09:55:39 +0000 (+0900) Subject: debian: Add/remove groups during installation/removal X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=4dfaf1a1dab4ca6aee6bf6eae0d8882ef1f0fe9e;p=toolbox debian: Add/remove groups during installation/removal When installing toolbox from debian packages, the toolbox and toolbox_ipc groups are not created, and the permissions and ownership of /var/lib/toolbox are incorrect. This commit adds postinst and postrm scripts that create and remove the toolbox and toolbox_ipc groups during installation/removal, and set the permissions on /var/lib/toolbox appropriately. --- diff --git a/Makefile b/Makefile index 13da461..1f060d5 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ clean: install: mkdir -p $(DESTDIR)/$(PREFIX)/share/toolbox mkdir -p $(DESTDIR)/$(PREFIX)/bin + mkdir -p $(DESTDIR)/var/lib/toolbox/ipc cp toolbox.sh $(DESTDIR)/$(PREFIX)/share/toolbox/. cp -r include $(DESTDIR)/$(PREFIX)/share/toolbox/. chown -R root.root $(DESTDIR)/$(PREFIX)/share/toolbox diff --git a/debian/control b/debian/control index a2e02f9..bba710e 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: toolbox Priority: optional Maintainer: Matthias Kruk -Build-Depends: debhelper (>= 9), make, coreutils, findutils, grep, sed +Build-Depends: debhelper (>= 9), adduser (>= 3.11), make, coreutils, findutils, grep, sed Standards-Version: 3.9.8 Section: shells Homepage: https://m10k.eu/toolbox.html diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..ddc2e23 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,24 @@ +#!/bin/sh + +main() { + # If a group exists, there is a chance that the user + # has customized directory ownership and permissions, + # so we don't change it. + + if addgroup toolbox; then + chown root.toolbox /var/lib/toolbox + chmod 770 /var/lib/toolbox + fi + + if addgroup toolbox_ipc; then + chown root.toolbox_ipc /var/lib/toolbox/ipc + chmod 770 /var/lib/toolbox/ipc + fi + + return 0 +} + +{ + main "$@" + exit "$?" +} diff --git a/debian/postrm b/debian/postrm new file mode 100755 index 0000000..5c58e05 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,13 @@ +#!/bin/sh + +main() { + delgroup toolbox + delgroup toolbox_ipc + + return 0 +} + +{ + main "$@" + exit "$?" +}