commit: bc7df5ee2b27d04889cacba49bb3339a58ce9de3
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 6 18:21:45 2019 +0000
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Wed Aug 7 15:03:44 2019 +0000
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=bc7df5ee
Rework resume-boot.sh
- We no longer use $GK_SHELL_LOCKFILE which was removed in
in previous commit ("initrd.scripts: run_shell(): Use LOCK file").
- We now try to kill all $SH processes allowing to use resume-boot
in remote and local rescue shell.
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
defaults/resume-boot.sh | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/defaults/resume-boot.sh b/defaults/resume-boot.sh
index cb29831..f4dd4b2 100644
--- a/defaults/resume-boot.sh
+++ b/defaults/resume-boot.sh
@@ -1,15 +1,28 @@
#!/bin/sh
. /etc/initrd.defaults
+. /etc/initrd.scripts
-if [ -s "${GK_SHELL_LOCKFILE}" ]
+GK_INIT_LOG_PREFIX=${0}
+if [ -n "${SSH_CLIENT_IP}" ] && [ -n "${SSH_CLIENT_PORT}" ]
then
- kill -9 "$(cat "${GK_SHELL_LOCKFILE}")"
+ GK_INIT_LOG_PREFIX="${0}[${SSH_CLIENT_IP}:${SSH_CLIENT_PORT}]"
fi
-if [ -f "${GK_SSHD_LOCKFILE}" ]
-then
- rm "${GK_SSHD_LOCKFILE}"
-fi
+# We don't want to kill init script (PID 1),
+# ourselves and parent process yet...
+pids_to_keep="1 ${$} ${PPID}"
+
+for pid in $(pgrep sh)
+do
+ if ! echo " ${pids_to_keep} " | grep -q " ${pid} "
+ then
+ kill -9 ${pid}
+ fi
+done
+
+good_msg "Resuming boot process ..."
+[ -f "${GK_SSHD_LOCKFILE}" ] && run rm "${GK_SSHD_LOCKFILE}"
+[ "${PPID}" != '1' ] && kill -9 ${PPID}
exit 0