Swatch 起動スクリプト(SuSE用:複数ファイル)

#! /bin/sh
# Copyright (c) 2002-2005 Aconus.com, Tokyo.
# All rights reserved.
#
# Author: Oyaji <oyaji@mail.aconus.com>
#
# /etc/init.d/swatch
#
### BEGIN INIT INFO
# Provides: swatch
# Required-Start: $syslog
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Description: Start Simple WATCHer is an automated monitoring tool (Swatch).
### END INIT INFO

# First reset status of this service
. /etc/rc.status
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running

CHECK_LOG="/var/log/messages"
SWATCH_CONF="/etc/swatch/swatchrc"

CHECK_LOG_FTP="/var/log/proftpd/all.log"
SWATCH_CONF_FTP="/etc/swatch/swatchrc_ftp"

SWATCH_BIN="/usr/bin/swatch"
SWATCH_LOG="/var/log/swatch"
SWATCH_SCRIPT="/var/run/swatch"

# Check that swatch exists.
if [ ! -x $SWATCH_BIN ]; then
echo -n "Swatch, $SWATCH_BIN not installed!"
rc_status -s
exit 5
fi

# Check that swatch configuration file exists.
if [ ! -f $SWATCH_CONF ]; then
echo -n "Swatch configuration file, $SWATCH_CONF does not exist."
# Tell the user this has skipped
rc_status -s
exit 6
elif [ ! -f $SWATCH_CONF_FTP ]; then
echo -n "Swatch configuration file, $SWATCH_CONF_FTP does not exist."
# Tell the user this has skipped
rc_status -s
exit 6
fi

pid_check() {
SWATCH_PID=`pidofproc swatch`
}

case "1ドル" in
start)
pid_check
if [ "$SWATCH_PID" != "" ]; then
echo -n "Warning: Swatch System already running!"
rc_status -s
exit 7
else
echo -n "Swatch System startup: "
$SWATCH_BIN -c $SWATCH_CONF -t $CHECK_LOG --script-dir=$SWATCH_SCRIPT >> $SWATCH_LOG &
rc_status -v
echo -n "Swatch System for FTP startup: "
$SWATCH_BIN -c $SWATCH_CONF_FTP -t $CHECK_LOG_FTP --script-dir=$SWATCH_SCRIPT >> $SWATCH_LOG &
rc_status -v
fi
;;
stop)
pid_check
if [ "$SWATCH_PID" = "" ]; then
echo -n "Warning: Swatch System not running! "
rc_status -s
exit 7
else
echo -n "Swatch System shutdown: "
killproc tail
rc_status -v
fi
;;
restart)
0ドル stop
0ドル start
rc_status
;;
*)
echo "Usage: 0ドル {start|stop|restart}"
exit 1
;;
esac
rc_exit

AltStyle によって変換されたページ (->オリジナル) /