diff options
author | Roy Marples <uberlord@gentoo.org> | 2006-08-13 11:22:06 +0000 |
---|---|---|
committer | Roy Marples <uberlord@gentoo.org> | 2006-08-13 11:22:06 +0000 |
commit | a47c947ff8e2137ee3898f9f615c7645716deb34 (patch) | |
tree | 307f792c59b8a481b484de10b20ca1a7666597fb /sys-apps/kexec-tools/files | |
parent | Recomment out openct stuff (diff) | |
download | gentoo-2-a47c947ff8e2137ee3898f9f615c7645716deb34.tar.gz gentoo-2-a47c947ff8e2137ee3898f9f615c7645716deb34.tar.bz2 gentoo-2-a47c947ff8e2137ee3898f9f615c7645716deb34.zip |
Update the init script so that it's more intelligent working things out
so it should just work for most peoples installs.
We now confiure kexec on shutdown by default instead of startup.
(Portage version: 2.1.1_pre4-r4)
Diffstat (limited to 'sys-apps/kexec-tools/files')
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.conf | 6 | ||||
-rwxr-xr-x | sys-apps/kexec-tools/files/kexec.init | 120 |
2 files changed, 69 insertions, 57 deletions
diff --git a/sys-apps/kexec-tools/files/kexec.conf b/sys-apps/kexec-tools/files/kexec.conf index b496dc866841..74f8b891ce54 100644 --- a/sys-apps/kexec-tools/files/kexec.conf +++ b/sys-apps/kexec-tools/files/kexec.conf @@ -1,6 +1,5 @@ # Boot partition #BOOTPART="/boot" -#BOOTMOUNT=1 # Kernel name #KNAME="vmlinuz-2.6.10" @@ -15,6 +14,5 @@ #INITRD="/boot/fbsplash-emergence-1024x768" # Load kexec kernel image into memory during shutdown instead of bootup -# (default: no) -#LOAD_DURING_SHUTDOWN="no" - +# (default: yes) +#LOAD_DURING_SHUTDOWN="yes" diff --git a/sys-apps/kexec-tools/files/kexec.init b/sys-apps/kexec-tools/files/kexec.init index fa0d86197250..3ddacd1d1546 100755 --- a/sys-apps/kexec-tools/files/kexec.init +++ b/sys-apps/kexec-tools/files/kexec.init @@ -1,75 +1,89 @@ #!/sbin/runscript # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init,v 1.7 2006/06/13 20:48:55 dsd Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init,v 1.8 2006/08/13 11:22:06 uberlord Exp $ depend() { - need checkfs + need localmount } -load_image() { - [ -z "$KNAME" ] && KNAME="bzImage" - [ -z "$BOOTPART" ] && BOOTPART="/boot" - [ -z "$BOOTMOUNT" ] && BOOTMOUNT=1 - [ -z "$ROOTPART" ] && ROOTPART="`cut -f 1 -d' ' /etc/mtab | grep / | tr '\n' '\t' | cut -f 1`" - [ -z "$KPARAM" ] && KPARAM="`sed -r 's:root=[a-zA-Z0-9/]+\s*::g' /proc/cmdline`" - [ -n "$INITRD" ] && INITRDOPT="--initrd=$INITRD" +image_path() { + local x= kver=$(uname -r) + for x in "${KNAME:-bzImage}" vmlinuz \ + bzImage-"${kver}" vmlinuz-"${kver}" ; do + if [[ -e ${BOOTPART}/${x} ]] ; then + echo "${BOOTPART}/${x}" + return 0 + fi + done - if [ "$KNAME" != "-" ] - then - ebegin "Loading kernel $KNAME for Kexec" - MNT=1 - LOCS="`cut -f 2 -d' ' /etc/mtab | tr '\n' ' '`" - for x in $LOCS - do - if [ "$x" == "$BOOTPART" ] - then - MNT=0 - fi - done + return 1 +} - if [ $MNT -eq 1 -a $BOOTMOUNT -eq 1 ] - then - /bin/mount $BOOTPART - if [ $? -ne 0 ] - then - eerror "Couldn't mount $BOOTPART" - MNT="0" - fi - fi - kexec -l $BOOTPART/$KNAME --append="root=$ROOTPART $KPARAM" $INITRDOPT - RES=$? - if [ $MNT -eq 1 -a $BOOTMOUNT -eq 1 ] - then - /bin/umount $BOOTPART - if [ $? -ne 0 ]; then - eerror "Couldn't umount $BOOTPART" - fi - fi - else +load_image() { + if [[ ${KNAME} == "-" ]] ; then ebegin "Disabling kexec" kexec -u - RES=$? + eend $? + return $? + fi + + BOOTPART="${BOOTPART:-/boot}" + local img=$(image_path) mounted=false initrdopt= + + if [[ -z ${img} ]] ; then + # If we cannot find our image, try mounting ${BOOTPART} + if [[ ! $'\n'$(</proc/mounts) =~ $'\n'"[^ ]* ${BOOTPART} " ]] ; then + ebegin "Mounting ${BOOTPART}" + mount "${BOOTPART}" && mounted=true + eend $? || return $? + img=$(image_path) + fi + fi + + if [[ -z ${img} ]] ; then + eerror "No kernel image found in ${BOOTPART}!" + ${mounted} && umount "${BOOTPART}" + return 1 fi - eend $RES + ebegin "Loading kernel image ${img} for kexec" + [[ -z ${ROOTPART} ]] \ + && ROOTPART=$(sed -n '/^[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /etc/mtab) + [[ -z ${KPARAM} ]] \ + && KPARAM=$(sed -r 's:root=[a-zA-Z0-9/]+\s*::g' /proc/cmdline) + + # Use the default initrd if it exists and none other given + [[ -z ${INITRD} && -e ${BOOTPART}/initrd ]] \ + && INITRD="${BOOTPART}/initrd" + [[ -e ${INITRD} ]] && initrdopt="--initrd=${INITRD}" + + kexec -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt} + local res=$? + + ${mounted} && umount "${BOOTPART}" + eend ${res} + return ${res} } start() { - if [ "$LOAD_DURING_SHUTDOWN" == 'no' -o "$LOAD_DURING_SHUTDOWN" == '' ]; - then - load_image - else - return 0 - fi + [[ ${LOAD_DURING_SHUTDOWN:-yes} == "yes" ]] && return 0 + + ebegin "Configuring kexec" + load_image + eend 0 } stop() { - if ! [ "$LOAD_DURING_SHUTDOWN" == 'no' -o "$LOAD_DURING_SHUTDOWN" == '' ]; - then - load_image - else + [[ ${LOAD_DURING_SHUTDOWN:-yes} != "yes" ]] && return 0 + + ebegin "Configuring kexec" + if [[ ${SOFTLEVEL} != "reboot" ]] || ! is_runlevel_stop ; then + einfo "Not rebooting, so disabling" + kexec -u return 0 fi -} + load_image + eend $? +} |