#! /bin/sh 
#
# Copyright (c) 2007 SUSE Linux GmbH, Nuernberg, Germany, EU.
# Copyright (c) 2004-2006 SUSE Linux GmbH, Nuernberg, Germany.
# Copyright (c) 2002 SuSE Linux AG, Nuernberg, Germany.
# Copyright (c) 1995-2001 SuSE GmbH, Nuernberg, Germany.
#
# Authors:
#	Dennis Olsson, 2007, SUSE Linux GmbH, Nuernberg, Germany, EU.
#	Dirk Hessing, 2007, SUSE Linux GmbH, Nuernberg, Germany, EU.
#	Wolfgang Rosenauer, 2004-2006, SuSE Linux AG, Nuernberg, Germany.
#	Holger Achtziger, 1995-2001, 2002 SuSE GmbH, Nuernberg, Germany.
#
# /etc/init.d/sapinit
#
#   and symbolic its link
#
# /usr/sbin/rcsapinit
#
### BEGIN INIT INFO
# Provides:       SAPINIT
# Required-Start: $remote_fs $syslog
# Should-Start:   sysstat
# Required-Stop:  $remote_fs $syslog
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Short-Description:    Initializing kernel environment for SAP system 
# Description:    Initializes the kernel environment for a SAP system 
### END INIT INFO

# Fetch the boot script functions, if available
test -f /etc/rc.status && . /etc/rc.status

# Special settings for this script
#sh_opt -s xpg_echo		# Enable escape characters to be interpreted.

# Commands required to be present by this script
readonly SYSCTL="/sbin/sysctl"
readonly SAPinit="/usr/sbin/SAPinit"

# Reset status of this service
rc_reset

# Figure out what to do, and do it;-)
case "${1}" in
    start)
	# System parameters
	echo "Setting kernel specific parameters for a SAP system\c"
	if [[ -x "${SYSCTL}" ]]
	then
	    ${SAPinit}
	else
	    echo "- ERROR: The '${SYSCTL}' command is not available!\c"
	    echo "\n\r\t${warn}\c"
	    echo "WARNING: SAP specific kernel parameters are neither verified nor set!\c"
	    echo "${norm}\c"
	    rc_failed 5
	fi
	rc_status -v -r
    ;;

    stop)
	echo "${0}: Action '${1}' is currently not implemented.\c"
	# echo -n "Removing kernel parameters for SAP system"
	# sed -i '/^# Added by sapinit on .*$/,/N/d' /etc/sysctl.conf
	# sed -i '/^# Changed by sapinit on .*$/,/N/d' /etc/sysctl.conf
	rc_status -v
    ;;

    status)
	echo "${0}: Action '${1}' is currently not implemented.\c"
	rc_status -v
    ;;

    try-restart)
	# As long as "stop" has not been implemented, there is no need to use it!!
	# ${0} stop
	${0} start
    ;;

    *)
	echo "Usage: ${0} {start|status|stop|try-restart}"
	exit 1
    ;;
esac
rc_exit
