Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/
Date: Wed, 07 Aug 2019 15:46:21
Message-Id: 1565190224.bc7df5ee2b27d04889cacba49bb3339a58ce9de3.whissi@gentoo
1 commit: bc7df5ee2b27d04889cacba49bb3339a58ce9de3
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Tue Aug 6 18:21:45 2019 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Wed Aug 7 15:03:44 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=bc7df5ee
7
8 Rework resume-boot.sh
9
10 - We no longer use $GK_SHELL_LOCKFILE which was removed in
11 in previous commit ("initrd.scripts: run_shell(): Use LOCK file").
12
13 - We now try to kill all $SH processes allowing to use resume-boot
14 in remote and local rescue shell.
15
16 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
17
18 defaults/resume-boot.sh | 25 +++++++++++++++++++------
19 1 file changed, 19 insertions(+), 6 deletions(-)
20
21 diff --git a/defaults/resume-boot.sh b/defaults/resume-boot.sh
22 index cb29831..f4dd4b2 100644
23 --- a/defaults/resume-boot.sh
24 +++ b/defaults/resume-boot.sh
25 @@ -1,15 +1,28 @@
26 #!/bin/sh
27
28 . /etc/initrd.defaults
29 +. /etc/initrd.scripts
30
31 -if [ -s "${GK_SHELL_LOCKFILE}" ]
32 +GK_INIT_LOG_PREFIX=${0}
33 +if [ -n "${SSH_CLIENT_IP}" ] && [ -n "${SSH_CLIENT_PORT}" ]
34 then
35 - kill -9 "$(cat "${GK_SHELL_LOCKFILE}")"
36 + GK_INIT_LOG_PREFIX="${0}[${SSH_CLIENT_IP}:${SSH_CLIENT_PORT}]"
37 fi
38
39 -if [ -f "${GK_SSHD_LOCKFILE}" ]
40 -then
41 - rm "${GK_SSHD_LOCKFILE}"
42 -fi
43 +# We don't want to kill init script (PID 1),
44 +# ourselves and parent process yet...
45 +pids_to_keep="1 ${$} ${PPID}"
46 +
47 +for pid in $(pgrep sh)
48 +do
49 + if ! echo " ${pids_to_keep} " | grep -q " ${pid} "
50 + then
51 + kill -9 ${pid}
52 + fi
53 +done
54 +
55 +good_msg "Resuming boot process ..."
56 +[ -f "${GK_SSHD_LOCKFILE}" ] && run rm "${GK_SSHD_LOCKFILE}"
57 +[ "${PPID}" != '1' ] && kill -9 ${PPID}
58
59 exit 0