diff options
author | Devaev Maxim <[email protected]> | 2019-07-19 04:10:30 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-07-19 04:10:30 +0300 |
commit | efbedb222df3b213d8e3106ee211830602ce5720 (patch) | |
tree | b1e67cef60ac7b46e8c6507671dff31bb2045357 | |
parent | ad83678eb3f735806f87ad9a43c32bdd6ffb92aa (diff) |
using sysusers.d
-rw-r--r-- | PKGBUILD | 9 | ||||
-rw-r--r-- | configs/os/sysusers.conf | 15 | ||||
-rw-r--r-- | kvmd.install | 32 |
3 files changed, 23 insertions, 33 deletions
@@ -65,6 +65,9 @@ package_kvmd() { mkdir -p "$pkgdir/usr/lib/systemd/system" cp configs/os/systemd/*.service "$pkgdir/usr/lib/systemd/system" + mkdir -p "$pkgdir/usr/lib/sysusers.d" + cp configs/os/sysusers.conf "$pkgdir/usr/lib/sysusers.d/kvmd.conf" + mkdir -p "$pkgdir/usr/lib/tmpfiles.d" cp configs/os/tmpfiles.conf "$pkgdir/usr/lib/tmpfiles.d/kvmd.conf" @@ -106,9 +109,9 @@ for _platform in $PIKVM_PLATFORM; do local _cfg_default=\"/usr/share/kvmd/configs.default\" - ln -sf \"\$_cfg_default/os/sysctl.conf\" \"\$pkgdir/etc/sysctl.d/99-pikvm.conf\" - ln -sf \"\$_cfg_default/os/udev/$_platform-$_board.rules\" \"\$pkgdir/etc/udev/rules.d/99-pikvm.rules\" - ln -sf \"\$_cfg_default/os/modules-load/$_platform.conf\" \"\$pkgdir/etc/modules-load.d/pikvm.conf\" + ln -sf \"\$_cfg_default/os/sysctl.conf\" \"\$pkgdir/etc/sysctl.d/99-kvmd.conf\" + ln -sf \"\$_cfg_default/os/udev/$_platform-$_board.rules\" \"\$pkgdir/etc/udev/rules.d/99-kvmd.rules\" + ln -sf \"\$_cfg_default/os/modules-load/$_platform.conf\" \"\$pkgdir/etc/modules-load.d/kvmd.conf\" ln -sf \"\$_cfg_default/kvmd/main/$_platform.yaml\" \"\$pkgdir/etc/kvmd/main.yaml\" if [ $_platform == v1-hdmi ]; then diff --git a/configs/os/sysusers.conf b/configs/os/sysusers.conf new file mode 100644 index 00000000..2714ae70 --- /dev/null +++ b/configs/os/sysusers.conf @@ -0,0 +1,15 @@ +g kvmd - - +g kvmd-ipmi - - +g kvmd-nginx - - + +u kvmd - "Pi-KVM - The main daemon" - +u kvmd-ipmi - "Pi-KVM - IPMI to KVMD proxy" - +u kvmd-nginx - "Pi-KVM - HTTP entrypoint" - + +m kvmd gpio +m kvmd uucp +m kvmd systemd-journal + +m kvmd-ipmi kvmd + +m kvmd-nginx kvmd diff --git a/kvmd.install b/kvmd.install index 42e9645d..2c4bc7e8 100644 --- a/kvmd.install +++ b/kvmd.install @@ -6,38 +6,10 @@ post_install() { } post_upgrade() { - echo "==> Configuring KVMD users and groups ..." - - _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 - - _create_user kvmd-ipmi "Pi-KVM - IPMI to KVMD proxy" - _add_user_to_group kvmd-ipmi kvmd - - _create_user kvmd-nginx "Pi-KVM - HTTP entrypoint" - _add_user_to_group kvmd-nginx kvmd + echo "==> Ensuring KVMD users and groups ..." + systemd-sysusers /usr/lib/sysusers.d/kvmd.conf chown kvmd:kvmd /etc/kvmd/htpasswd chown kvmd-ipmi:kvmd-ipmi /etc/kvmd/ipmipasswd chmod 600 /etc/kvmd/*passwd } - -post_remove() { - _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" -} |