* [PATCH] introduce optional job control
@ 2011-10-17 21:01 Michal Soltys
[not found] ` <1318885310-12535-2-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
2011-10-18 9:52 ` [PATCH] introduce optional job control WANG Cong
0 siblings, 2 replies; 4+ messages in thread
From: Michal Soltys @ 2011-10-17 21:01 UTC (permalink / raw
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Option --ctty will optionally add setsid binary to dracut's image.
During runtime, if rd.ctty is set and is a character device,
emergency shells will be spawned with job control.
Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
dracut | 3 ++-
modules.d/99base/init | 10 ++++++++--
modules.d/99base/module-setup.sh | 1 +
modules.d/99shutdown/shutdown | 11 +++++++++--
4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/dracut b/dracut
index 4bc0db3..d32b357 100755
--- a/dracut
+++ b/dracut
@@ -226,6 +226,7 @@ while (($# > 0)); do
--nolvmconf) lvmconf_l="no";;
--debug) debug="yes";;
--profile) profile="yes";;
+ --ctty) cttyhack="yes";;
-v|--verbose) ((verbosity_mod_l++));;
-q|--quiet) ((verbosity_mod_l--));;
-l|--local) allowlocal="yes" ;;
@@ -504,7 +505,7 @@ chmod 755 "$initdir"
export initdir dracutbasedir dracutmodules drivers \
fw_dir drivers_dir debug no_kernel kernel_only \
add_drivers mdadmconf lvmconf filesystems \
- use_fstab libdir usrlibdir fscks nofscks \
+ use_fstab libdir usrlibdir fscks nofscks cttyhack \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug
diff --git a/modules.d/99base/init b/modules.d/99base/init
index 06d61a8..1b62582 100755
--- a/modules.d/99base/init
+++ b/modules.d/99base/init
@@ -40,6 +40,7 @@ wait_for_loginit()
emergency_shell()
{
+ local _ctty
set +e
if [ "$1" = "-n" ]; then
_rdshell_name=$2
@@ -57,8 +58,13 @@ emergency_shell()
echo "Dropping to debug shell."
echo
export PS1="$_rdshell_name:\${PWD}# "
- [ -e /.profile ] || echo "exec 0<>/dev/console 1<>/dev/console 2<>/dev/console" > /.profile
- sh -i -l
+ [ -e /.profile ] || >/.profile
+ _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
+ if type setsid >/dev/null 2>&1 && [ -c "$_ctty" ] ; then
+ setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
+ else
+ sh -i -l
+ fi
else
warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
# cause a kernel panic
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
index f6dc920..6d2fa07 100755
--- a/modules.d/99base/module-setup.sh
+++ b/modules.d/99base/module-setup.sh
@@ -16,6 +16,7 @@ install() {
dracut_install mount mknod mkdir modprobe pidof sleep chroot \
sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink
dracut_install -o less
+ [[ $cttyhack = yes ]] && dracut_install -o setsid
if [ ! -e "${initdir}/bin/sh" ]; then
dracut_install bash
(ln -s bash "${initdir}/bin/sh" || :)
diff --git a/modules.d/99shutdown/shutdown b/modules.d/99shutdown/shutdown
index a31a95d..9473b5b 100755
--- a/modules.d/99shutdown/shutdown
+++ b/modules.d/99shutdown/shutdown
@@ -13,6 +13,7 @@ export TERM=linux
emergency_shell()
{
+ local _ctty
set +e
if [ "$1" = "-n" ]; then
_rdshell_name=$2
@@ -29,8 +30,14 @@ emergency_shell()
echo "Dropping to debug shell."
echo
export PS1="$_rdshell_name:\${PWD}# "
- [ -e /.profile ] || echo "exec 0<>/dev/console 1<>/dev/console 2<>/dev/console" > /.profile
- sh -i -l
+ [ -e /.profile ] || >/.profile
+ _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
+ if type setsid >/dev/null 2>&1 && [ -c "$_ctty" ] ; then
+ _ctty=/dev/${_ctty##*/}
+ setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
+ else
+ sh -i -l
+ fi
else
exec /lib/systemd/systemd-shutdown "$@"
warn "Shutdown has failed. To debug this issue add \"rdshell\" to the kernel command line."
--
1.7.5.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] job control fixup
[not found] ` <1318885310-12535-2-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
@ 2011-10-17 22:02 ` Michal Soltys
0 siblings, 0 replies; 4+ messages in thread
From: Michal Soltys @ 2011-10-17 22:02 UTC (permalink / raw
To: initramfs-u79uwXL29TY76Z2rM5mHXA
- in case no ctty was provided, shell was spawned without caring about
/dev/console
Also, the ctty is more opportunistic. If the image was generated with
--ctty, we will fallback to /dev/tty1 if rc.ctty is invalid or missing.
Otherwise we spawn standard shell on /dev/console
Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
modules.d/99base/init | 8 +++++---
modules.d/99shutdown/shutdown | 9 +++++----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/modules.d/99base/init b/modules.d/99base/init
index 54d5281..76c6957 100755
--- a/modules.d/99base/init
+++ b/modules.d/99base/init
@@ -59,11 +59,13 @@ emergency_shell()
echo
export PS1="$_rdshell_name:\${PWD}# "
[ -e /.profile ] || >/.profile
- _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
- if type setsid >/dev/null 2>&1 && [ -c "$_ctty" ] ; then
+ _ctty=/dev/console
+ if type setsid >/dev/null 2>&1; then
+ _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
+ [ -c "$_ctty" ] || _ctty=/dev/tty1
setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
else
- sh -i -l
+ sh -i -l 0<$_ctty 1>$_ctty 2>&1
fi
else
warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
diff --git a/modules.d/99shutdown/shutdown b/modules.d/99shutdown/shutdown
index 9473b5b..21bb37f 100755
--- a/modules.d/99shutdown/shutdown
+++ b/modules.d/99shutdown/shutdown
@@ -31,12 +31,13 @@ emergency_shell()
echo
export PS1="$_rdshell_name:\${PWD}# "
[ -e /.profile ] || >/.profile
- _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
- if type setsid >/dev/null 2>&1 && [ -c "$_ctty" ] ; then
- _ctty=/dev/${_ctty##*/}
+ _ctty=/dev/console
+ if type setsid >/dev/null 2>&1; then
+ _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
+ [ -c "$_ctty" ] || _ctty=/dev/tty1
setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
else
- sh -i -l
+ sh -i -l 0<$_ctty 1>$_ctty 2>&1
fi
else
exec /lib/systemd/systemd-shutdown "$@"
--
1.7.5.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] introduce optional job control
2011-10-17 21:01 [PATCH] introduce optional job control Michal Soltys
[not found] ` <1318885310-12535-2-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
@ 2011-10-18 9:52 ` WANG Cong
2011-10-18 10:23 ` Michal Soltys
1 sibling, 1 reply; 4+ messages in thread
From: WANG Cong @ 2011-10-18 9:52 UTC (permalink / raw
To: initramfs-u79uwXL29TY76Z2rM5mHXA
On Mon, 17 Oct 2011 23:01:50 +0200, Michal Soltys wrote:
> Option --ctty will optionally add setsid binary to dracut's image.
>
> During runtime, if rd.ctty is set and is a character device, emergency
> shells will be spawned with job control.
>
Hi,
Please also update dracut.8.xml.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] introduce optional job control
2011-10-18 9:52 ` [PATCH] introduce optional job control WANG Cong
@ 2011-10-18 10:23 ` Michal Soltys
0 siblings, 0 replies; 4+ messages in thread
From: Michal Soltys @ 2011-10-18 10:23 UTC (permalink / raw
To: initramfs-u79uwXL29TY76Z2rM5mHXA
On 18.10.2011 11:52, WANG Cong wrote:
> On Mon, 17 Oct 2011 23:01:50 +0200, Michal Soltys wrote:
>
>> Option --ctty will optionally add setsid binary to dracut's image.
>>
>> During runtime, if rd.ctty is set and is a character device, emergency
>> shells will be spawned with job control.
>>
>
> Hi,
>
> Please also update dracut.8.xml.
>
Ah, right.
Actually, there's another fix to do, so I'll just prepare v2 with all
the stuff.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-10-18 10:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-17 21:01 [PATCH] introduce optional job control Michal Soltys
[not found] ` <1318885310-12535-2-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
2011-10-17 22:02 ` [PATCH] job control fixup Michal Soltys
2011-10-18 9:52 ` [PATCH] introduce optional job control WANG Cong
2011-10-18 10:23 ` Michal Soltys
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.