#!/bin/sh
# vim:set sw=4 ts=4:
#
# $Id: make_cadsm,v 1.5 2005/04/11 14:14:39 fabian Exp $
#
#############################################################################
#
# ALICE
# Automatic Linux Installation and Configuration Environment
#
# Copyright (c) 2000 SuSE Linux Solutions AG, Eschborn, 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: Fabian Herschel
# 
#############################################################################
#
# make_cadsm
# TODO: NOT ready yet
#
# Sections: --
# Tags:     --
#
usage()
{
   echo "$_self -h | --help | -?"
   echo "$_self -fqhn"
}

test -n "$alice_dir" || alice_dir="/usr/lib/alice2/"
export alice_dir


while [ $# -gt 0 ]
do
   case $1 in
       -h | --help | -? ) usage
                          exit 1
                          ;;
       -fqhn ) export fqhn=$2; shift
            ;;

   esac
   shift
done

. $alice_dir/lib/alicerc
WELCOME

############################################################################
# And now we begin
#
# Create a startup file for the adsm sheduler
cat <<EOF >/etc/rc.d/cadsm
#!/bin/sh
if [ $1 = "start" ]; then
        /bin/nohup /usr/adsm/dsmc schedule >>/var/log/adsm/dsmsched.log 2>>/var/log/adsm/dsmsched.err &
        echo "Starting ADSM scheduler"
else
        if [ $1 = "stop" ]; then
                pid=`/usr/bin/ps -e | /usr/bin/grep dsmc |\
                         /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`  
                if [ "${pid}" != "" ]; then
                        echo "Stopping ADSM scheduler"
                        kill ${pid}
                fi     
        fi
fi
EOF
ln -s ../cadsm /etc/rc.d/rc2.d/S40cadsm
ln -s ../cadsm /etc/rc.d/rc3.d/K40cadsm
mkdir -d /var/log/adsm
#
# 
############################################################################
# Thats all
GOOD_BYE
