Skip to content

Commit 7d7cfe9

Browse files
committed
[update] : Enable service if it is disabled
1 parent df21128 commit 7d7cfe9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules/share/airootfs.any/root/functions.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ _safe_systemctl(){
9494
for _service in "${@}"; do
9595
# https://unix.stackexchange.com/questions/539147/systemctl-check-if-a-unit-service-or-target-exists
9696
if (( "$(systemctl list-unit-files "${_service}" | wc -l)" > 3 )); then
97-
systemctl "${_command}" "${_service}"
97+
if [[ "${_command}" = "enable" ]]; then
98+
if [[ "$(systemctl is-enabled "${_service}")" = "enabled" ]]; then
99+
systemctl enable "${_service}"
100+
fi
101+
else
102+
systemctl "${_command}" "${_service}"
103+
fi
98104
else
99105
echo "${_service} was not found" >&2
100106
fi

0 commit comments

Comments
 (0)