new flags and lvm

isirc:
	lvm instead symlinks (vgscan, ...) will be called with --sysinit.

flags:
	NOSEC: default, on failure, isirc crashes and no shell will start.
		but NOSEC will allow isirc to start a shell for debugging.
		if you have a secure grub-config and nobody should be able to start
		a root-shell, this will be default. else NOSEC is interesting for
		debugging.
	init: yes, init=/bin/sh will be possible. NOSEC is not needed.
	isirdsh: start a shell before mounting. needs NOSEC.
	ISIRDSH: start a shell after mounting and before switch root. needs NOSEC.
This commit is contained in:
Denis Knauf 2012-08-18 00:20:03 +02:00
parent d81863c487
commit a09b427d1c

28
isirc
View file

@ -3,6 +3,7 @@
PATH=/bin
export PATH
QUITE=${QUITE:-false}
NOSEC=false
log() {
[ "X$QUITE" != "Xtrue" ] && echo "$*"
@ -26,10 +27,15 @@ then
log " mdev"
mdev -s
log " activate volume groups"
vgscan --mknodes --ignorelockingfailure
vgchange --ignorelockingfailure -P -a y
lvm vgscan --mknodes --sysinit
lvm vgchange --sysinit -P -a y
if cmdline -c isirdsh
if cmdline -c NOSEC
then
NOSEC=true
fi
if [ Xtrue = "X$NOSEC" ] && cmdline -c isirdsh
then
log " start shell"
exec sh
@ -42,11 +48,9 @@ fi
ROOT="$(cmdline -c root)"
FLAGS="$(cmdline -c rootflags)"
if cmdline -c ro
then
FLAGS="${FLAGS},ro"
then FLAGS="${FLAGS},ro"
elif cmdline -c rw
then
FLAGS="${FLAGS},rw"
then FLAGS="${FLAGS},rw"
fi
FSTYPE="$(cmdline -c rootfstype)"
FSTYPE="${FSTYPE:-auto}"
@ -57,9 +61,17 @@ log " mount ${ROOT} as ${FSTYPE} with ${FLAGS}"
if ! mount -o "${FLAGS}" -t "${FSTYPE}" "${ROOT}" /mnt
then
err "Can't mount root!"
[ Xtrue = "X$NOSEC" ] && exec sh
fi
# ISIRDSH -> shell for debugging, testing, what ever...
if [ Xtrue = "X$NOSEC" ] && cmdline -c ISIRDSH
then
exec sh
fi
INIT="$(cmdline -c init)"
INIT="${INIT:-/sbin/init}"
cd /mnt
log " Change to new root"
exec switch_root /mnt /bin/sh
exec switch_root /mnt "$INIT"