#!/bin/bash
# vim:set sw=4 ts=4:
#
# $Id: prepare_alice_SLES8,v 1.10 2005/04/11 14:14:39 fabian Exp $
#
#############################################################################
#
# ALICE
# Automatic Linux Installation and Configuration Environment
#
# Copyright (c) 2000-2002 SuSE Linux Solutions AG, Eschborn, Germany
#               2002-2004 SuSE Linux AG, Eschborn, Germany
#               2005           SUSE GmbH, Nuernberg, Germany
#
# 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
#
#############################################################################
#
# Author: Pieter Hollants, Fabian Herschel
#
##############################################################################
#
# prepare_alice_SLES8
# Implants ALICEs installation path into the systems first bootup 
# (so make_all can be called then)
#
# Sections: --
# Tags:     --
#
# Where does YaST the installation media resp. the ALICE scripts?
# Where does YaST mount the installation target?
target_mount="./mnt"
if [ "$1" = "--auto" ]
then
   target_mount="."
else
   target_mount="/"
fi

export target_mount
if [ -e $target_mount/alrc.cfg ]
then
   . $target_mount/alrc.cfg
else
	echo "$target_mount/alrc.cfg not found (skipp)"
fi
#
# Now let us set the alice logger for syslog
#
cp $target_mount/etc/syslog.conf $target_mount/etc/syslog.conf.orig.$$
(
if [ -n "$ALICE_LOGGER_FACILITY" ]  # i.e. local0
then
   if [ -n "$ALICE_LOGGER_ACTION_ALL" ]
   then
      for action in $ALICE_LOGGER_ACTION_ALL
      do
         echo "$ALICE_LOGGER_FACILITY.* $action"
      done
   fi
   if [ -n "$ALICE_LOGGER_ACTION_ERR" ]
   then
      for action in $ALICE_LOGGER_ACTION_ALL
      do
         echo "$ALICE_LOGGER_FACILITY.err $action"
      done    
   fi
   if [ -n "$ALICE_LOGGER_ACTION_WARN" ]
   then
      for action in $ALICE_LOGGER_ACTION_ALL
      do
         echo "$ALICE_LOGGER_FACILITY.warn $action"
      done    
   fi
fi
) >> $target_mount/etc/syslog.conf 
#
init_dir=/etc/init.d
#
# Link alice into target systems bootup sequence
#
# first insserv network in the case this isn't already done
${target_mount}/sbin/insserv ${target_mount}/${init_dir}/network
${target_mount}/sbin/insserv ${target_mount}/${init_dir}/portmap
${target_mount}/sbin/insserv ${target_mount}/${init_dir}/alice
#
# create the alice "semaphore" file
#
mkdir -p ${target_mount}/var/state
touch ${target_mount}/var/state/alice_run
touch ${target_mount}/etc/sysconfig/alice
#
# thats it
