File boot.cycle.IA64 of Package bootcycle

#! /bin/bash
#
# Copyright (c) 2003 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# File: /etc/init.d/boot.loadmodules
# Author: Werner Fink <feedback@suse.de>
#
### BEGIN INIT INFO
# Provides:          boot.cycle
# Required-Start:    boot.localfs
# Should-Start:      boot.loadmodules
# Required-Stop:     boot.localfs
# Should-Stop:       boot.loadmodules
# Default-Start:     B
# Default-Stop:
# Description:       Set default boot entry if called
### END INIT INFO

#
# Sanity check
#
skip=""
if test -e /etc/sysconfig/bootloader ; then
    . /etc/sysconfig/bootloader
else
    skip=5
fi

#
# Configure check
#
efi=/usr/sbin/efibootmgr
test "$LOADER_TYPE" = "elilo" -a -x "$efi"	|| skip=6
test "$CYCLE_DETECTION" = "yes" -a \
			 -n "$CYCLE_NEXT_ENTRY"	|| skip=6

. /etc/rc.status
rc_reset

#
# Not configured: go out here
#
if test -n "$skip" ; then
    rc_failed $skip
    rc_exit
fi

#
# This one checks if EFI Shell entry is declared _and_ active by default
#
check_for_efi ()
{
    local line
    local default=""
    local found=no

    while read line ; do
	case "$line" in
	BootOrder:*)	default="${line#*: }" ;;
	Boot*EFI*Shell*)
	    line=${line#Boot}
	    if test "${default%%,*}" = "${line%\**}" ; then
		found=yes
	    fi
	esac
    done < <($efi)

    test "$found" = "yes" && return 0    
    return 1
}

case "$1" in
    start)
	echo "Set up $LOADER_TYPE entry for next boot cycle"
	if check_for_efi ; then
	    $efi --active   "$CYCLE_NEXT_ENTRY"
	    $efi --bootnext "$CYCLE_NEXT_ENTRY"
	else
	    rc_failed 1
	fi
	rc_status -v1
	;;
    stop)	
	# skip / do nothing
	;;
    status)
	rc_failed 4
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status}"
	exit 1
	;;
esac

rc_exit