diff options
author | Hetsh | 2020-05-05 11:48:17 +0200 |
---|---|---|
committer | Hetsh | 2020-05-05 11:48:17 +0200 |
commit | a31368fff6c5c65554e48c5a9da904649b2bf82b (patch) | |
tree | 34a918fb004481d04bbb101eb6435251f29fd841 | |
parent | 2e1f916f16a7ade9509a545e1e2f857859fc9c6a (diff) | |
download | aur-a31368fff6c5c65554e48c5a9da904649b2bf82b.tar.gz |
My God, do not wipe home dir of mcs user during package removal
-rw-r--r-- | .SRCINFO | 2 | ||||
-rw-r--r-- | PKGBUILD | 2 | ||||
-rw-r--r-- | mcsctl-git.install | 29 |
3 files changed, 18 insertions, 15 deletions
@@ -1,7 +1,7 @@ pkgbase = mcsctl-git pkgdesc = Manage multiple minecraft servers with a simple bash script and systemd unit template. pkgver = master - pkgrel = 9 + pkgrel = 10 url = https://github.com/Hetsh/mcsctl install = mcsctl-git.install arch = any @@ -3,7 +3,7 @@ pkgname=mcsctl-git pkgver=master commit=('3877e5cef1a50e6b450b09acc6cc2563bb1d6cc1') -pkgrel=9 +pkgrel=10 pkgdesc='Manage multiple minecraft servers with a simple bash script and systemd unit template.' arch=('any') url='https://github.com/Hetsh/mcsctl' diff --git a/mcsctl-git.install b/mcsctl-git.install index 65ea2f9eaad4..16fd88158bca 100644 --- a/mcsctl-git.install +++ b/mcsctl-git.install @@ -1,23 +1,26 @@ MCS_USER='mcs' -MCS_GROUP='mcs' -post_install() { - if ! getent group "$MCS_GROUP" > /dev/null; then - groupadd "$MCS_GROUP" +user_exists() { + if getent passwd "$MCS_USER" > /dev/null; then + return $(true) + else + return $(false) fi +} - if ! getent passwd "$MCS_USER" > /dev/null; then - useradd -c 'Minecraft user' -g "$MCS_GROUP" -s /usr/bin/nologin -m "$MCS_USER" - passwd -l "$MCS_USER" > /dev/null +post_install() { + if ! user_exists; then + echo "Adding user \"$MCS_USER\"..." + useradd --user-group --comment 'Minecraft user' --shell /usr/bin/nologin --create-home "$MCS_USER" &> /dev/null + passwd --lock "$MCS_USER" > /dev/null fi } post_remove() { - killall -w -u "$MCS_USER" -s KILL - userdel -r -f "$MCS_GROUP" &> /dev/null - - CONF_FILE="/etc/mcsctl.conf" - if [ -e "$CONF_FILE" ]; then - echo "==> Your configuration in \"$CONF_FILE\" was preserved." + if user_exists; then + echo "Stopping processes controlled by \"$MCS_USER\"..." + killall --wait --user "$MCS_USER" + echo "Removing user \"$MCS_USER\"..." + userdel --force "$MCS_USER" &> /dev/null fi } |