Posts Tagged ‘init’
The following is a simple (and very row) init script for Symantec Backup Exec Agent for Linux.
I wrote it because I really hate to execute script not registered with chkconfig on a production systems.
I’ve added the “status” function by checking if an executable called “beremote” is listening on 10000/tcp on IPv4 on the localhost.
If you are planning to run ralus on a different TCP port, please fix the script.
The following is the script :
#!/bin/sh
#
# RALUS Control Script
# chkconfig: 2345 99 01
# Description: Here is a little startup/shutdown script for RedHat/CentOS systems
#
# Author : Riccardo Riva
#
# description: Symantec Backup Exec Linux Agent Init Script
#
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
# See how we were called.
if [ ! -d /opt/VRTSralus ]
then
echo "Symantec Backup Exec Remote Agent missing /opt/VRTSralus [FAILED]"
exit 1
fi
if [ ! -d /etc/VRTSralus ]
then
echo "Symantec Backup Exec Remote Agent missing /etc/VRTSralus [FAILED]"
exit 1
fi
if [ ! -d /var/VRTSralus ]
then
echo "Symantec Backup Exec Remote Agent missing /var/VRTSralus [FAILED]"
exit 1
fi
CMD="$1"
case "$CMD" in
'start')
if [ -x /opt/VRTSralus/bin/beremote ]
then
echo -n "Starting Symantec Backup Exec Remote Agent "
rm -f /var/VRTSralus/ralus.pid
rm -f /var/VRTSralus/ralus.errpid
/opt/VRTSralus/bin/beremote >/var/VRTSralus/beremote.service.log 2>/var/VRTSralus/beremote.service.log &
PIDWAIT=30
while [ "$PIDWAIT" != "0" ]
do
if [ -f /var/VRTSralus/ralus.pid ]
then
PIDWAIT=0
else
PIDWAIT=$(($PIDWAIT-1))
echo -n "."
sleep 1;
fi
if [ -f /var/VRTSralus/ralus.errpid ]
then
PIDWAIT=0
fi
done
if [ -f /var/VRTSralus/ralus.pid ]
then
RETVAL=0
else
RETVAL=1
fi
echo
else
RETVAL=1
fi
if [ "$RETVAL" = "0" ]
then
echo "Starting Symantec Backup Exec Remote Agent: [ OK ]"
else
echo "Starting Symantec Backup Exec Remote Agent: [FAILED]"
fi
;;
'stop')
if [ -f /bin/grep ]
then
PID=`/bin/ps -e | /bin/grep beremote | /bin/sed -e 's/^ *//' -e 's/ .*//'`
else
PID=`/usr/bin/ps -e | /usr/bin/grep beremote | /usr/bin/sed -e 's/^ *//' -e 's/ .*//'`
fi
if [ "${PID}" != "" ]
then
echo -n "Stopping Symantec Backup Exec Remote Agent "
if [ -f /bin/pkill ]
then
/bin/pkill -15 beremote
else
/usr/bin/pkill -15 beremote
fi
RETVAL=$?
PIDWAIT=15
while [ "$PIDWAIT" != "0" ]
do
if [ -f /var/VRTSralus/ralus.pid ]
then
PIDWAIT=0
RETVAL=0
else
PIDWAIT=$(($PIDWAIT-1))
echo -n "."
sleep 1;
fi
done
echo
rm -f /var/VRTSralus/ralus.pid
rm -f /var/VRTSralus/ralus.errpid
else
RETVAL=1
fi
if [ "$RETVAL" = "0" ]
then
echo "Stopping Symantec Backup Exec Remote Agent: [ OK ]"
else
echo "Stopping Symantec Backup Exec Remote Agent: [FAILED]"
fi
;;
'restart')
$0 stop
$0 start
RETVAL=1
;;
'status')
if [ $(netstat -tulpan | grep beremote |grep 0.0.0.0:10000 | wc -l) -eq 1 ];
then
echo "Symantec Backup Exec Remote Agent running and listening on tcp port 10000"
else
echo "Symantec Backup Exec Remote Agent not running"
fi
;;
*)
echo "Symantec Backup Exec Remote Agent for Linux/Unix Servers"
echo "Usage: VRTSralus.init { start | stop | restart | status}"
RETVAL=1
;;
esac
exit $RETVAL
#
# -- End of file
You should download the file here : http://www.riccardoriva.com/shared-files/ralus_init_script.sh
Hope this help
Bye
Riccardo
Print This Post
This simple How-To will explain a raw and dirt method to daemonize to http manager for ARECA Raid Controller.
If you have this controller on your system you should find in the bundled CD-ROM the following folder :
root PACKAGES -> Linux -> CLI -> version -> i386 -> cli32 PACKAGES -> Linux -> CLI -> version -> x86-64 -> cli32 PACKAGES -> Linux -> HTTP -> version.x.y.x -> i386 -> archttp32 PACKAGES -> Linux -> HTTP -> version.x.y.x -> x86-64 -> archttp32
Create a folder in your /usr/local folder called “areca” e and create into it two folders called “http” and “cli”
Copy the “cli32″ and “archttp32″ executable file that match your architecture (i386 or x86-64) in the specified folder, so you should have something similar :
[root@relay ~]# ls -lahR /usr/local/areca/ /usr/local/areca/: total 20K drwxr-xr-x 4 root root 4.0K Feb 12 10:28 . drwxr-xr-x 13 root root 4.0K Feb 12 10:26 .. dr-xr-xr-x 2 root root 4.0K Feb 12 10:27 cli dr-xr-xr-x 2 root root 4.0K Feb 12 10:42 http /usr/local/areca/cli: total 1.6M dr-xr-xr-x 2 root root 4.0K Feb 12 10:27 . drwxr-xr-x 4 root root 4.0K Feb 12 10:28 .. -r-xr-xr-x 1 root root 1.6M Dec 26 2008 cli32 /usr/local/areca/http: total 1.6M dr-xr-xr-x 2 root root 4.0K Feb 12 10:42 . drwxr-xr-x 4 root root 4.0K Feb 12 10:28 .. -r-xr-xr-x 1 root root 1.6M Dec 26 2008 archttp32 -rw-r--r-- 1 root root 91 Feb 12 10:42 archttpsrv.conf
Create a new file called “areca” in your /etc/init.d folder with the following content :
#!/bin/sh
#
# Startup script for the ARECA RAID CONTROLLER HTTP Monitor
#
# chkconfig: 2345 62 38
# description: HTTP Tools to monitor and manage ARECA RAID Controller
#
# processname: archttp32
# config: none
# lockfile: /var/lock/subsys/archttp32
#
# Author: Riccardo Riva
# WebSite: http://www.riccardoriva.com
#
# This script is realeased under the terms of the GPL.
#====================================================================
# Source function library
. /etc/init.d/functions
RETVAL=0
start() {
echo -n $"Starting ARECA HTTP Manager: "
daemon /usr/local/areca/http/archttp32 2>&1>/dev/null &
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/archttp32
return $RETVAL
}
stop() {
echo -n $"Stopping ARECA HTTP Manager: "
killproc archttp32
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/archttp32
return $RETVAL
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading ARECA HTTP Manager: "
killproc archttp32 -ALRM
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status archttp32
;;
restart)
restart
;;
condrestart)
[ -f /var/lock/subsys/archttp32 ] && restart || :
;;
reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
esac
exit $?
#---End of file---
Assing to it the right permission and ownership
chmod 755 /etc/init.d/areca chown root:root /etc/init.d/areca
You should also place in the executable file folder the configuration file, called “archttp32srv.conf” with the following content :
[GENERAL] BindingIp=0.0.0.0 HTTPPort=81 SMTPPort=25 ScanPci=YES ScanRs232=NO ScanInband=NO ConnInfo=NO [MAIL] Server=MAIL.SERVER.IP.ADDRESS # Please Change ME Sender=SENDERNAME # Please Change ME SenderMail=SENDERMAIL # Please Change ME Account= Password= MailToName1=RECEIVERNAME # Please Change ME MailToName2= MailToName3= MailToName4= MailAddr1=RECEIVERMAIL # Please Change ME MailAddr2= MailAddr3= MailAddr4= EvtLevel=3 NotifyForNoEvent=NO [SNMP] TrapIp1=SNMP.SERVER.IP.ADDRESS # Please Change ME TrapIp2=0.0.0.0 TrapIp3=0.0.0.0 TrapPort1=162 TrapPort2=162 TrapPort3=162 Community=public EvtLevel=3
And configure it for startup at boot time.
chkconfig areca on
I know it very dirt, but I had no time left to search a better way, maybe in the future.
Hope this help
Bye
Riccardo
Print This Post
The following is a simple (and very row) init script for Bacula 5.0.
I wrote it because I really hate to execute script not registered with chkconfig on a production systems.
The following is the script :
#!/bin/sh
#
# BACULA Control Script
# chkconfig: 2345 99 01
# Description: Here is a little startup/shutdown script for RedHat/CentOS systems
#
# processname: bacula
# bacula-dir pidfile: /var/run/bacula-dir.9101.pid
# bacula-fd pidfile: /var/run/bacula-fd.9102.pid
# bacula-sd pidfile: /var/run/bacula-sd.9103.pid
#
# bacula-dir config: /etc/bacula/bacula-dir.conf
# bacula-fd config: /etc/bacula/bacula-fd.conf
# bacula-sd config: /etc/bacula/bacula-sd.conf
#
# Author : Riccardo Riva
#
# description: It comes by night and sucks the vital essence from your computers.
#
SCRIPTDIR=/etc/bacula
#
# Disable Glibc malloc checks, it doesn't help and it keeps from getting
# good dumps
MALLOC_CHECK_=0
export MALLOC_CHECK_
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
# See how we were called.
case "$1" in
start)
[ -x ${SCRIPTDIR}/bacula-ctl-sd ] && ${SCRIPTDIR}/bacula-ctl-sd $1 $2
[ -x ${SCRIPTDIR}/bacula-ctl-fd ] && ${SCRIPTDIR}/bacula-ctl-fd $1 $2
[ -x ${SCRIPTDIR}/bacula-ctl-dir ] && ${SCRIPTDIR}/bacula-ctl-dir $1 $2
;;
stop)
# Stop the FD first so that SD will fail jobs and update catalog
[ -x ${SCRIPTDIR}/bacula-ctl-fd ] && ${SCRIPTDIR}/bacula-ctl-fd $1 $2
[ -x ${SCRIPTDIR}/bacula-ctl-sd ] && ${SCRIPTDIR}/bacula-ctl-sd $1 $2
[ -x ${SCRIPTDIR}/bacula-ctl-dir ] && ${SCRIPTDIR}/bacula-ctl-dir $1 $2
;;
restart)
$0 stop
sleep 2
$0 start
;;
status)
[ -x ${SCRIPTDIR}/bacula-ctl-sd ] && ${SCRIPTDIR}/bacula-ctl-sd status
[ -x ${SCRIPTDIR}/bacula-ctl-fd ] && ${SCRIPTDIR}/bacula-ctl-fd status
[ -x ${SCRIPTDIR}/bacula-ctl-dir ] && ${SCRIPTDIR}/bacula-ctl-dir status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit $RETVAL
#--- End of file ---
You should download the script from here :
http://www.riccardoriva.com/shared-files/bacula_init_script.sh
Hope this help
Bye
Riccardo
Print This Post
This simple init script is for daemonize freshclam (Clamd Antivirus Updater) on RHEL or CentOS.
Create a brand new file called freshclam in /etc/init.d/ with the following content :
#!/bin/sh
#
# Startup script for the Clam AntiVirus Update Tool
#
# chkconfig: 2345 62 38
# description: freshclam is an update daemon for Clam AV database.
#
# processname: freshclam
# config: /etc/freshclam.conf
# pidfile: /var/run/clamav/freshclam.pid
#
# Author: Riccardo Riva
# WebSite: http://www.riccardoriva.com
#
# This script is realeased under the terms of the GPL.
#====================================================================
# Source function library
. /etc/init.d/functions
# Get network config
. /etc/sysconfig/network
test -f /etc/freshclam.conf || exit 0
RETVAL=0
start() {
echo -n $"Starting freshclam: "
daemon /usr/bin/freshclam -d -p /var/run/clamav/freshclam.pid
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/freshclam
return $RETVAL
}
stop() {
echo -n $"Stopping freshclam: "
killproc freshclam
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/run/clamav/freshclam.pid /var/lock/subsys/freshclam
return $RETVAL
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading DB: "
killproc freshclam -ALRM
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status freshclam
;;
restart)
restart
;;
condrestart)
[ -f /var/lock/subsys/freshclam ] && restart || :
;;
reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
esac
exit $?
Assign to it corect ownership and permission :
chown root:root /etc/init.d/freshclam chmod 755 /etc/init.d/freshclam
Test if the scripts works correctly on your system with the following commands :
service freshclam start service freshclam stop service freshclam restart service freshclam reload service freshclam condstart
If all works fine you should add freshclam to the automatic startup services with the following command :
chkconfig freshclam on
Hope this help
Bye
Riccardo
Print This Post
This post will assume you just have a fully functional working mail server and you want do download all emails from some mailboxes located on another mail server, tipically located on your service provider’s one.
This post guide will guide you to install and configure fetchmail and use it with your RHEL 5 or newer, you should use all the following information also with CentOS without change any line, but you shoud adapt it to every Linux distribution.
Most likely you want to setup fetchmail to download your domain mailbox over pop3 and inject into Postfix (or whatever you use as MTA).
To install fetchmail use the following :
yum install fetchmail -y
You should decide how to use fetchmail :
* as a daemon
* as a cron scheduled task
The following is a very simple init script for Oracle on Red Hat Enterprise Linux.
I’m using it successfully in RHEL 5.2 but you can use it on other systems, only double check the various path.
#!/bin/sh
#
# ORACLE Control Script
# chkconfig: 3 80 20
#
# Description: Here is a little startup/shutdown script for Oracle 10g on RedHat systems
#
# Author : Riccardo Riva
#
# Source LSB function library.
[ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions
#Assuming have Oracle installed on :
# /oracle/product/10.2.0/db1
ORACLE_HOME=/oracle/product/10.2.0/db_1
#Assuming have “oracle” user
ORACLE_OWNER=oracle
# Edit this with your DB instance name
ORACLE_DB=DB_INSTANCE_NAME
if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
echo “Oracle startup: cannot start”
exit
fi
case “$1″ in
’start’)
# Start the Oracle databases:
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/lsnrctl start”
su – $ORACLE_OWNER -c $ORACLE_HOME/bin/dbstart
;;
’stop’)
# Stop the Oracle databases:
su – $ORACLE_OWNER -c $ORACLE_HOME/bin/dbshut
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/lsnrctl stop”
;;
’status’)
if su -l $ORACLE_OWNER -c “${ORACLE_HOME}/bin/tnsping ${ORACLE_DB} >/dev/null 2>&1″
then
exit 0
else
exit 1
fi
;;
esac
Create this script and put it in your /etc/init.d/ directory
Make this script excutable
Use “chkconfig” to set the startup or the shutdown for this script in the desired runlevels.
Hope this help avoid wasting time
Bye
Riccardo
Here is the code for an advanced startup/shutdown script for JBoss.
I’m using it with JBoss 3.2.6 on a RHEL 5.2 Advanced Platform, and all works well.
I’ve added the “status” function for use it in a cluster suite and a new function to check if Oracle DB Server is up and running, otherwise JBoss doesn’t deploy well all developers files.
When you use “start” function, the script use a simple “tnsping” based function that loop into themselves until Oracle is not fully working and then sleep other 10 seconds to start JBoss.
JBoss startup/shutdown script with Oracle Support
Hope this help
Bye
Riccardo
Print This Post
Here is the code for a startup/shutdown script for JBoss.
I’m using it on a RHEL 5.2 Advanced Platform, and all works well.
I’ve added the “status” function for use it in a cluster suite.
Hope this help
Bye
Riccardo
Print This Post
Today I had to install an ArcServer Unix agent on a brand new Linux system, and as any times i can’t find an init script that allow to start/stop/restart or see the agent status.
Google wasn’t my friend because I was without internet access so I’ve decided to write it by myself.
follow the Linux Init Script for ArcServe Unix Agent :
#! /bin/sh
#
# Author: Riccardo Riva
#
# System startup script for the inet daemon
#
### BEGIN INIT INFO
# Provides: uagent
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Description: Start UAgent daemon.
### END INIT INFO
if [ -e /etc/rc.config ]; then
. /etc/rc.config
fi
if [ -e /etc/rc.status ]; then
. /etc/rc.status
fi
# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}
uagent_bin=/opt/uagent/uagent
return=$rc_done
# Reset status of this service.
rc_reset
# See how we were called.
case “$1″ in
start)
echo -n “Starting Uagent daemon: ”
$uagent_bin start || return=$rc_failed
echo -e “$return”
;;
stop)
echo -n “Stopping UAgent daemon: ”
$uagent_bin stop
sleep 2
$uagent_bin stop || return=$rc_failed
echo -e “$return”
sleep 2
;;
restart)
echo -n “Stopping UAgent daemon: ”
$uagent_bin stop
sleep 2
$uagent_bin stop || return=$rc_failed
echo -e “$return”
sleep 2
echo -n “Starting Uagent daemon: ”
$uagent_bin start || return=$rc_failed
echo -e “$return”
;;
status)
echo -n “Checking for UAgent daemon: ”
$uagent_bin status && echo OK || echo No process
;;
*)
echo “Usage: $0 {start|stop|status}”
exit 1
esac
test “$return” = “$rc_done” || exit 1
exit 0























