]> git.corax.cc Git - toolbox/commitdiff
debian: Add/remove groups during installation/removal
authorMatthias Kruk <m@m10k.eu>
Fri, 21 Jan 2022 09:55:39 +0000 (18:55 +0900)
committerMatthias Kruk <m@m10k.eu>
Fri, 21 Jan 2022 09:55:39 +0000 (18:55 +0900)
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.

Makefile
debian/control
debian/postinst [new file with mode: 0755]
debian/postrm [new file with mode: 0755]

index 13da46152087559b852d728c1b3e553db1a76712..1f060d56b80748a94269c5aa5b50aac339524fa4 100644 (file)
--- 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
index a2e02f97158b284773a77edd5345000030d1f595..bba710ee9fa3caf88cee1750fb881bb05a64da91 100644 (file)
@@ -1,7 +1,7 @@
 Source: toolbox
 Priority: optional
 Maintainer: Matthias Kruk <m@m10k.eu>
-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 (executable)
index 0000000..ddc2e23
--- /dev/null
@@ -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 (executable)
index 0000000..5c58e05
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+main() {
+       delgroup toolbox
+       delgroup toolbox_ipc
+
+       return 0
+}
+
+{
+       main "$@"
+       exit "$?"
+}