Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sysvinit): support older versions of sysvinit which don't have enable|disable commands #10

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions services/tedgectl
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,29 @@ manage_sysvinit() {
command="$1"
name="$2"
case "$command" in
is_available) service --status-all ;;
is_available)
# service --status-all does not run on some systems (e.g. older yocto versions)
if command -V pidof >/dev/null 2>&1; then
[ "$(pidof /sbin/init)" = "1" ]
elif command -V grep >/dev/null 2>&1; then
/sbin/init --version | grep -qi sysv
else
/sbin/init --version >/dev/null
fi
;;
start) service "$name" start ;;
stop) service "$name" stop ;;
restart) service "$name" restart ;;
enable)
update-rc.d "$name" defaults # TODO check if it is required: install service before enabling
update-rc.d "$name" enable
update-rc.d "$name" defaults

# Not all sysvinit systems support the enable/disable command
update-rc.d "$name" enable 2>/dev/null ||:
;;
disable)
update-rc.d "$name" disable
# Not all sysvinit systems support the enable/disable command
update-rc.d "$name" disable 2>/dev/null ||:

update-rc.d "$name" remove
;;
is_active|status) service "$name" status ;;
Expand Down