Verified Commit c42f26c9 authored by Karel Koci's avatar Karel Koci 🤘
Browse files

updater-ng: add postupdate script that cleans up /etc/rc.d

During update there can be dangling links to services that are no longer
installed as well as old links if service changed START/STOP number.
This script removes them.
parent 48244977
......@@ -9,7 +9,7 @@ include $(TOPDIR)/
......@@ -71,7 +71,7 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/updater/hook_preupdate
touch $(1)/etc/updater/hook_preupdate/.keep
$(INSTALL_DIR) $(1)/etc/updater/hook_postupdate
touch $(1)/etc/updater/hook_postupdate/.keep
$(INSTALL_BIN) ./files/ $(1)/etc/updater/hook_postupdate/
$(INSTALL_DIR) $(1)/etc/updater/hook_reboot_required
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/pkgupdate/hook_reboot_required/ $(1)/etc/updater/hook_reboot_required/
set -eu
cd "/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"
# 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"
"/etc/init.d/$service" enable
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment