From 7aaa211601597aee58e56d99cf8530a7ba52d80c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 26 Jan 2022 13:53:47 +0100 Subject: updater-ng: test update to 70.0.0 --- updater-ng/files/cleanup_rc_d.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 updater-ng/files/cleanup_rc_d.sh (limited to 'updater-ng/files/cleanup_rc_d.sh') diff --git a/updater-ng/files/cleanup_rc_d.sh b/updater-ng/files/cleanup_rc_d.sh new file mode 100755 index 0000000..9df8015 --- /dev/null +++ b/updater-ng/files/cleanup_rc_d.sh @@ -0,0 +1,27 @@ +#!/bin/sh +set -eu + +cd "$ROOT_DIR/etc/rc.d" + +# Remove any dangling links +for rc in *; do + [ -L "$rc" ] || continue + [ -f "$rc" ] || { + echo "Removing enable for non-existent service: $rc" >&2 + rm -f "$rc" + } +done + +# Fix multiple links for same service +# We list here all links and do two passes. First we just remove number and filter +# out only duplicates. This way we have problematic services but to get name only +# once we have to remove leading 'S' or 'K' and do second pass. This way we have +# just list of all problematic services. +find -maxdepth 1 -type l \ + | sed 's|\./\([SK]\)..|\1|' | sort | uniq -d \ + | sed 's|[SK]||' | sort | uniq \ + | while read -r service; do + echo "Fixing multiple startup/shutdown links for service: $service" >&2 + rm -f [SK]??"$service" + /bin/sh "$ROOT_DIR/etc/rc.common" "$ROOT_DIR/etc/init.d/$service" enable +done -- cgit v1.2.3