#!/bin/sh
# vim:set sw=4 ts=4:
#
# $Id: alice,v 1.3 2005/04/11 14:14:39 fabian Exp $
#
#############################################################################
#
# ALICE
# Automatic Linux Installation and Configuration Environment
#
# Copyright (c) 1999 SuSE Rhein-Main AG, Eschborn, Germany.  All rights reserved.
#               2000-2001 SuSE Linux Solutions AG, Eschborn, Germany.  All rights reserved.
#		2002,2003 SuSE Linux AG, Eschborn, Germany.  All rights reserved.
#               2003-2011 SUSE Linux Products GmbH
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#############################################################################
#
# Authors: Pieter Hollants
#          Fabian Herschel
#          Juergen Henge-Ernst
#
# TODO: Maybe the portmap should only be a optional requirement!
#
### BEGIN INIT INFO
# Provides:          alice
# Required-Start:    $network 
# Required-Stop:     $network
# Default-Start:     3 5
# Default-Stop:
# Description:       Runs the alice system config scripts
### END INIT INFO
#
# Sections: --
# Tags:     --
#
. /etc/rc.status
rc_reset
case $1 in
	start )
		# only continue, if the "semaphore" has not been removed so far
		echo "Starting ALICE configuration scripts"
		if [ ! -e /var/state/alice_run ]; then
			echo -e " - skipping $rc_done" 
			exit
		fi
		#
		# get some ALICE environment
		#
		. /etc/sysconfig/alice
		if [ ! "$ALICE_CONFIG" = "yes" ]; then
			echo -e " - skipping (ALICE_CONFIG!=yes) $rc_done" 
			exit
		fi
		#
		# remove semaphore, if needed and start the master script
		#
		if [ "$ALICE_START_EVERY_BOOT" = "yes" ]
		then
			printf "Skipp removing the alice semaphore (alice will start on next reboot)\n"	
		else
			rm /var/state/alice_run
        fi
		/usr/lib/alice2/bin/make_all 
		alice_rc=$?
		printf "ALICE configuration scripts have finished." 
		case $alice_rc in
			0 ) rc_str="$rc_done"
				;;
			1 | 2 ) rc_str="$rc_failed"
				;;
		esac
		echo -e "$rc_str"
		;;
	stop  )
		;;
esac
