S60testbed 1.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
#!/bin/sh
#
# Do Emulab stuff
#

if [ -f /etc/emulab/paths.sh ]; then
	. /etc/emulab/paths.sh
else
	BINDIR=/etc/testbed
fi

mode=admin

start() {
	for token in `cat /proc/cmdline`; do
		case $token in
			elab_mode=*) mode=${token##*=} ;;
		esac
	done

	# if newnode, there is no DB state for quotes
	if [ "$mode" = "newnode" ]; then
	    echo "FATAL: secure MFS does not support 'newnode'"
	    sleep 5
	    /sbin/reboot
	fi

	echo "Starting secure MFS in \"$mode\" mode"
	script=""
	scriptarg=""
	if [ -x $BINDIR/script1.sh ]; then
	    if $BINDIR/script1.sh; then
		scriptarg="-secure"
	    else
		echo "WARNING: secure setup failed, dropping to MFS"
		mode="admin"
	    fi
	fi

	case $mode in
		admin)
			script=$BINDIR/rc/rc.mfs
			scriptarg="boot"
			;;
		frisbee)
			if $BINDIR/rc/rc.frisbee $scriptarg; then
			    echo "Disk load done";
			else
			    echo "WARNING: disk load failed, continuing anyway"
			fi
			script=""
			scriptarg=""
			;;
		*)
			echo "Invalid mode, dropping to MFS" 1>&2
			script=$BINDIR/rc/rc.mfs
			scriptarg="boot"
			;;
	esac

	# must sign-off before executing any further scripts
	if [ -x $BINDIR/script2.sh ]; then
	    if $BINDIR/script2.sh; then
		echo "Signed off from secure MFS"
	    else
		echo "WARNING: TPM sign-off failed"
		script=""
	    fi
	fi
	if [ -z "$script" ]; then
	    echo "Rebooting ..."
	    sleep 2
	    /sbin/reboot
	fi

 	echo "Starting ${script##*/} ..."
	$script $scriptarg
	exit $?
}

stop() {
	:
}
restart() {
	:
}

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart|reload)
  	restart
	;;
  *)
	echo $"Usage: $0 {start|stop|restart}"
	exit 1
esac

exit $?