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 /mcsctl-git.install | |
parent | 2e1f916f16a7ade9509a545e1e2f857859fc9c6a (diff) | |
download | aur-a31368fff6c5c65554e48c5a9da904649b2bf82b.tar.gz |
My God, do not wipe home dir of mcs user during package removal
Diffstat (limited to 'mcsctl-git.install')
-rw-r--r-- | mcsctl-git.install | 29 |
1 files changed, 16 insertions, 13 deletions
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 } |