From 7dfa257695d1da2a3db3551d6d47e950002d6964 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sun, 15 Nov 2020 22:20:18 +0100 Subject: [PATCH] - hd6x: fix shutdown --- make/target-scripts.mk | 21 +++++++---- skel-root/general/scripts/halt.init | 3 -- skel-root/general/scripts/sendsigs.init | 21 +++++++++++ skel-root/general/scripts/umountfs.init | 47 +++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 10 deletions(-) delete mode 100644 skel-root/general/scripts/halt.init create mode 100644 skel-root/general/scripts/sendsigs.init create mode 100644 skel-root/general/scripts/umountfs.init diff --git a/make/target-scripts.mk b/make/target-scripts.mk index 3ed75d38..4a783aad 100644 --- a/make/target-scripts.mk +++ b/make/target-scripts.mk @@ -15,7 +15,6 @@ init-scripts: \ $(TARGET_DIR)/etc/init.d/crond \ $(TARGET_DIR)/etc/init.d/custom-poweroff \ $(TARGET_DIR)/etc/init.d/fstab \ - $(TARGET_DIR)/etc/init.d/halt \ $(TARGET_DIR)/etc/init.d/hostname \ $(TARGET_DIR)/etc/init.d/inetd \ $(TARGET_DIR)/etc/init.d/mdev \ @@ -26,6 +25,8 @@ init-scripts: \ $(TARGET_DIR)/etc/init.d/swap \ $(TARGET_DIR)/etc/init.d/sys_update.sh \ $(TARGET_DIR)/etc/init.d/syslogd \ + $(TARGET_DIR)/etc/init.d/sendsigs \ + $(TARGET_DIR)/etc/init.d/umountfs \ $(TARGET_DIR)/etc/init.d/suspend \ $(TARGET_DIR)/etc/init.d/user-initscripts @@ -66,12 +67,6 @@ $(TARGET_DIR)/etc/init.d/fstab: $(INSTALL_EXEC) -D $(TARGET_FILES)/scripts/fstab.init $(@) $(UPDATE-RC.D) $(@F) defaults 01 98 -$(TARGET_DIR)/etc/init.d/halt: -ifeq ($(BOXMODEL), $(filter $(BOXMODEL), hd60 hd61)) - $(INSTALL_EXEC) -D $(TARGET_FILES)/scripts/halt.init $(@) - $(UPDATE-RC.D) $(@F) start 90 0 . -endif - $(TARGET_DIR)/etc/init.d/hostname: $(INSTALL_EXEC) -D $(TARGET_FILES)/scripts/hostname.init $(@) @@ -115,6 +110,18 @@ $(TARGET_DIR)/etc/init.d/syslogd: $(INSTALL_EXEC) -D $(TARGET_FILES)/scripts/syslogd.init $(@) $(UPDATE-RC.D) $(@F) stop 98 0 6 . +$(TARGET_DIR)/etc/init.d/sendsigs: +ifeq ($(BOXMODEL), $(filter $(BOXMODEL), hd60 hd61)) + $(INSTALL_EXEC) -D $(TARGET_FILES)/scripts/sendsigs.init $(@) + $(UPDATE-RC.D) $(@F) start 85 0 . +endif + +$(TARGET_DIR)/etc/init.d/umountfs: +ifeq ($(BOXMODEL), $(filter $(BOXMODEL), hd60 hd61)) + $(INSTALL_EXEC) -D $(TARGET_FILES)/scripts/umountfs.init $(@) + $(UPDATE-RC.D) $(@F) start 86 0 . +endif + $(TARGET_DIR)/etc/init.d/suspend: ifeq ($(BOXMODEL), $(filter $(BOXMODEL), hd60 hd61)) $(INSTALL_EXEC) -D $(TARGET_FILES)/scripts/suspend.init $(@) diff --git a/skel-root/general/scripts/halt.init b/skel-root/general/scripts/halt.init deleted file mode 100644 index 68d690c5..00000000 --- a/skel-root/general/scripts/halt.init +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -halt -d -f -p diff --git a/skel-root/general/scripts/sendsigs.init b/skel-root/general/scripts/sendsigs.init new file mode 100644 index 00000000..34e1b771 --- /dev/null +++ b/skel-root/general/scripts/sendsigs.init @@ -0,0 +1,21 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: sendsigs +# Required-Start: +# Required-Stop: umountnfs +# Default-Start: +# Default-Stop: 0 6 +# Short-Description: Kill all remaining processes. +# Description: +### END INIT INFO + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +# Kill all processes. +echo "Sending all processes the TERM signal..." +killall5 -15 +sleep 5 +echo "Sending all processes the KILL signal..." +killall5 -9 + +: exit 0 diff --git a/skel-root/general/scripts/umountfs.init b/skel-root/general/scripts/umountfs.init new file mode 100644 index 00000000..30e441bb --- /dev/null +++ b/skel-root/general/scripts/umountfs.init @@ -0,0 +1,47 @@ +#!/bin/sh +# +# umountfs Turn off swap and unmount all local filesystems. +# + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +# Ensure /proc is mounted +test -r /proc/mounts || mount -t proc proc /proc + +echo "Deactivating swap..." +swapoff -a + +# Sleep give epg time to save +sleep 5 + +# We leave /proc mounted, the umount of /dev/devpts seems to fail +# quite frequently, the busybox umount apparently gives up at the +# first failure, so it is necessary to go file system by file +# system. It is necessary to go backward in the /proc list, because +# later things may have been mounted on earlier mounts. +unmount() { + local dev mp type opts + if read dev mp type opts + then + # recurse - unmount later items + unmount + # skip / and needed virtual filesystems + case "$mp" in + /|/dev|/proc|/sys) return 0;; + esac + # then unmount this, if possible, otherwise make + # it read-only + umount -f -r "$mp" + fi +} + +echo "Unmounting local filesystems..." +unmount