#!/bin/sh
#
# Copyright (c) 2002 SuSE Linux AG, Nuernberg, Germany.
#
# Author: Joachim Gleissner <jg@suse.de>
#
# /etc/init.d/boot.scpm
#
# $Id: boot.scpm,v 1.6 2004/03/19 10:35:31 jg Exp $
#
### BEGIN INIT INFO
# Provides:          boot.scpm
# Required-Start:    boot.localfs
# X-UnitedLinux-ShouldStart: boot.md boot.lvm
# Required-Stop:
# Default-Start:     B
# Default-Stop:
# Description:       Set up on-boot profile
### END INIT INFO

. /etc/rc.status

test -x /sbin/scpm || exit 0
test -f /etc/scpm.conf || exit 0

. /etc/scpm.conf

rc_reset

case "$1" in
    start|b)
	test -z "$PROFILE" && exit 0
	test $(/sbin/scpm status | awk '{ if ($1 == "enabled") print $3 }') = no \
	    && { echo "Can not restore profile $PROFILE, SCPM is disabled" ;
	         exit 0; }
	test "$PROFILE" = "`/sbin/scpm active`" && exit 0
	test -z "$BOOT_MODE" && BOOT_MODE=force
	echo -n "Restoring profile $PROFILE"
	if [ "$BOOT_MODE" = "force" ]; then
	    /sbin/scpm -b -q -f switch $PROFILE || rc_failed
	elif [ "$BOOT_MODE" = "skip" ]; then
	    /sbin/scpm -b -q -s switch $PROFILE || rc_failed
	elif [ "$BOOT_MODE" = "backup" ]; then
	    /sbin/scpm -q delete _boot 2>/dev/null
	    /sbin/scpm -q add _boot
	    /sbin/scpm -b -q -s switch $PROFILE || rc_failed
	else
	    echo -n "  unkown boot mode $BOOT_MODE"
	    rc_failed
	fi
	rc_status -v 
	;;
    stop)
	;;
    status)
	rc_failed 4
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status}"
	exit 1
	;;
esac
rc_exit
