diff options
author | Devaev Maxim <[email protected]> | 2019-05-10 14:36:28 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-05-10 14:36:28 +0300 |
commit | 18fa69b77973b5db970797edc1f627e67904606e (patch) | |
tree | a117ca5329ec841e47dab0771a818b49c3ff8f06 /kvmd.install | |
parent | 03c3caa35eeef059c950874fb291d6ee78d55568 (diff) |
improved users/groups
Diffstat (limited to 'kvmd.install')
-rw-r--r-- | kvmd.install | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/kvmd.install b/kvmd.install index 3e504d48..42e9645d 100644 --- a/kvmd.install +++ b/kvmd.install @@ -8,19 +8,36 @@ post_install() { post_upgrade() { echo "==> Configuring KVMD users and groups ..." - id kvmd &>/dev/null || useradd -r -c "The main Pi-KVM daemon" -s /sbin/nologin kvmd - for group in gpio uucp systemd-journal; do - (groupmems -l -g "$group" | grep kvmd >/dev/null) || groupmems -g "$group" -a kvmd - done + _create_user kvmd "Pi-KVM - The main daemon" + _add_user_to_group kvmd gpio + _add_user_to_group kvmd uucp + _add_user_to_group kvmd systemd-journal - id kvmd-nginx &>/dev/null || useradd -r -c "Pi-KVM Nginx Server" -s /sbin/nologin kvmd-nginx - (groupmems -l -g kvmd | grep kvmd-nginx >/dev/null) || groupmems -g kvmd -a kvmd-nginx + _create_user kvmd-ipmi "Pi-KVM - IPMI to KVMD proxy" + _add_user_to_group kvmd-ipmi kvmd - chown root:kvmd \ - /usr/share/kvmd/configs.default/kvmd/*passwd \ - /etc/kvmd/*passwd + _create_user kvmd-nginx "Pi-KVM - HTTP entrypoint" + _add_user_to_group kvmd-nginx kvmd + + chown kvmd:kvmd /etc/kvmd/htpasswd + chown kvmd-ipmi:kvmd-ipmi /etc/kvmd/ipmipasswd + chmod 600 /etc/kvmd/*passwd } post_remove() { - userdel kvmd &>/dev/null + _delete_user kvmd-nginx + _delete_user kvmd-ipmi + _delete_user kvmd +} + +_create_user() { + id "$1" &>/dev/null || useradd -r -c "$2" -s /sbin/nologin "$1" +} + +_delete_user() { + userdel "$1" &>/dev/null +} + +_add_user_to_group() { + (groupmems -l -g "$2" | grep "$1" >/dev/null) || groupmems -g "$2" -a "$1" } |