Kingsto88
10th November 2004, 09:40
Dear all,
I would like to know how to write a script or what I should do if I want my Sun unix server to auto rc.stop and rc.start whenever I shutdown and bootup my server.
Can any one help me please.
Thanks and regards,
bdittmar
12th November 2004, 13:16
Dear all,
I would like to know how to write a script or what I should do if I want my Sun unix server to auto rc.stop and rc.start whenever I shutdown and bootup my server.
Can any one help me please.
Hello, don't know on SUN,
HP-UX in /etc/rc.config.d/baan
#!/sbin/sh
# baan configuration
#
# BAAN: to 1 to start BAAN
#
#BAAN=1
#BAAN=0
and entries in /sbin/init.d
All Victor says is o.k.
The above script enables BaaN to strt automaticly.
The script "/sbin/init.d/baan" starts BaaN depending on the above shown value:
#! /sbin/sh
#
# File: /sbin/init.d/baan
# AUTOR: Bernd Dittmar
# DATE : 09.12.2004
#
#
# Modification for LUST B. Dittmar (2004-12-09)
#
# By this script Baan starts by HP-UX 11i booting
#
# Activate the start by Variable in /etc/rc.config.d BAAN
# (file /etc/rc.config.d/baan)
# Is the variable = 0 then Baan will be ignored by boot and shutdown
#
# @(#) $Revision: 72.11 $
#
# NOTE: This script is not configurable! Any changes made to this
# script will be overwritten when you upgrade to the next
# release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
# is unbootable. Do not modify this script.
#
# <Insert comment about your script here>
#
# Allowed exit values:
# 0 = success; causes "OK" to show up in checklist.
# 1 = failure; causes "FAIL" to show up in checklist.
# 2 = skip; causes "N/A" to show up in the checklist.
# Use this value if execution of this script is overridden
# by the use of a control variable, or if this script is not
# appropriate to execute for some other reason.
# 3 = reboot; causes the system to be rebooted after execution.
# Input and output:
# stdin is redirected from /dev/null
#
# stdout and stderr are redirected to the /etc/rc.log file
# during checklist mode, or to the console in raw mode.
PATH=/usr/sbin:/usr/bin:/sbin
export PATH
#B. Dittmar (2004-12-09) Path and BaaN Environment for LUST
#Std. disconnected
#BSE=/baan/bse
#BSE_TMP=$BSE/tmp
BSE=/daten/bse
BSE_TMP=/daten/tmp
BSE_SORT=/daten/tmp
PATH=$BSE/bin:$PATH
export BSE BSE_TMP BSE_SORT PATH
rval=0
# Check the exit value of a command run by this script. If non-zero, the
# exit code is echoed to the log file and the return value of this script
# is set to indicate failure.
# Kill the named process(es).
# $1=<search pattern for your process>
killproc() {
pid=`ps -e | awk '$NF~/'"$1"'/ {print $1}'`
if [ "X$pid" != "X" ]; then
if kill "$pid"; then
echo "$1 stopped"
else
rval=1
echo "Unable to stop $1"
fi
fi
}
case $1 in
'start_msg')
# Emit a _short_ message relating to running this script with
# the "start" argument; this message appears as part of the checklist.
echo "Startup BAAN"
;;
'stop_msg')
# Emit a _short_ message relating to running this script with
# the "stop" argument; this message appears as part of the checklist.
echo "Shutdown BAAN"
;;
'start')
# source the system configuration variables
if [ -f /etc/rc.config ] ; then
. /etc/rc.config
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi
# Check to see if this script is allowed to run...
if [ "$BAAN" != 1 ]; then
rval=2
else
if [ -f ${BSE_TMP}/rc.start_done ]
then
rm -f ${BSE_TMP}/rc.start_done
fi
if [ -f ${BSE}/tmp/pd_lock ]
then
rm -f ${BSE}/tmp/pd_lock
fi
sh ${BSE}/etc/rc.start
rval=0
fi
;;
'stop')
# source the system configuration variables
if [ -f /etc/rc.config ] ; then
. /etc/rc.config
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi
# Check to see if this script is allowed to run...
if [ "$BAAN" != 1 ]; then
rval=2
else
if [ -f ${BSE_TMP}/rc.stop_done ]
then
rm -f ${BSE_TMP}/rc.stop_done
fi
sh ${BSE}/etc/rc.stop
rval=0
fi
;;
*)
echo "usage: $0 {start|stop|start_msg|stop_msg}"
rval=1
;;
esac
exit $rval
--------------------------------------------------
It starts $BSE/etc/rc.start and rc.stop if you set the symb. links correct in the runlevel with:
ln -s /sbin/init.d/baan Sxxxbaan and
ln -s /sbin/init.d/baan Kxxxbaan
The Value Sxxx + Kxxx has to be 1000.
Regards Bernd
victor_cleto
15th November 2004, 13:04
I assume the script will be called baan next.
O SUN a stop|start script should be build as /etc/init.d/baan and the needed stop and start links created from the /etc/rcX.d/... ->/etc/init.d/baan - look for the DB script to give you an idea of the sequence for the stop|start of Baan.
On HP-UX the script should be build as /sbin/init.d/baan and the links from /sbin/rcX.d/... ->/sbin/init.d/baan - it is also usual to build a script to run a config file script as /etc/rc.config.d/baan that is run by the former and that if BAAN=1, then continue, if =0 then exit without any actions - this is used so that you can disable|enable the autostart|stop of Baan.
So maybe it's also good to use this config script on SUN (and this script is what was mentioned in the previous reply, not the /sbin/init.d/baan one!).
Check the init.d man page to understand the start/stop OS script sequences and run levels.
bdittmar
10th December 2004, 11:01
Have a look at the enhancements in my last posting.