Skip to content

Commit fed0c11

Browse files
committed
[fix] : Fixed unit check
1 parent 9ae3e71 commit fed0c11

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

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

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,11 @@ _safe_systemctl(){
9292
local _service _command="${1}"
9393
shift 1
9494
for _service in "${@}"; do
95-
# https://unix.stackexchange.com/questions/539147/systemctl-check-if-a-unit-service-or-target-exists
96-
if (( "$(systemctl list-unit-files "${_service}" | wc -l)" > 3 )); then
97-
if [[ "${_command}" = "enable" ]]; then
98-
if [[ "$(systemctl is-enabled "${_service}")" = "enabled" ]]; then
99-
echo "${_service} has been enabled" >&2
100-
else
101-
systemctl enable "${_service}" || true
102-
fi
103-
else
104-
systemctl "${_command}" "${_service}"
105-
fi
106-
elif echo "${_service}" | grep -q "@"; then
107-
_safe_systemctl "${_command}" "$(echo "${_service}" | cut -d "@" -f 1)"
108-
else
109-
echo "${_service} was not found" >&2
95+
if [[ "${_command}" = "enable" ]] && [[ "$(systemctl is-enabled "${_service}")" = "enabled" ]]; then
96+
echo "${_service} has been enabled" >&2
97+
continue
11098
fi
99+
systemctl "${_command}" "${_service}" || true
111100
done
101+
return 0
112102
}

0 commit comments

Comments
 (0)