2024-02-24 07:52:22 +01:00
|
|
|
function systemctl --description 'Wraps privileged and user systemctl commands to use doas when necessary' -w systemctl
|
2022-09-30 16:46:31 +02:00
|
|
|
set -l user_commands \
|
|
|
|
list-units list-unit-files list-jobs list-timers \
|
|
|
|
list-sockets list-dependencies list-machines \
|
|
|
|
is-active is-enabled is-failed \
|
|
|
|
status show help get-default show-environment cat
|
|
|
|
|
|
|
|
set -l root_commands start stop reload restart try-restart \
|
|
|
|
reload-or-restart try-reload-or-restart isolate kill clean \
|
|
|
|
set-property reset-failed enable disable reenable preset \
|
|
|
|
preset-all mask unmask link revert add-wants add-requires \
|
|
|
|
edit set-default cancel set-environment unset-environment import-environment \
|
|
|
|
daemon-reload daemon-reexec default rescue emergency halt poweroff reboot \
|
|
|
|
kexec exit switch-root suspend hibernate hybrid-sleep suspend-then-hibernate
|
|
|
|
|
|
|
|
if contains -- --user $argv; or not contains -- $argv[1] $root_commands
|
|
|
|
command systemctl $argv
|
|
|
|
else
|
2024-02-24 07:52:22 +01:00
|
|
|
command doas systemctl $argv
|
2022-09-30 16:46:31 +02:00
|
|
|
end
|
|
|
|
end
|