File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / smartmontools / smartd.initd.in
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 01:17:36 2013 UTC (10 years, 10 months ago) by misho
Branches: smartmontools, elwix, MAIN
CVS tags: v6_2, v6_1p0, v6_1, HEAD
6.1

    1: #! /bin/sh
    2: 
    3: # smartmontools init file for smartd
    4: # Copyright (C) 2002-8 Bruce Allen <smartmontools-support@lists.sourceforge.net>
    5: # $Id: smartd.initd.in,v 1.1.1.2 2013/07/22 01:17:36 misho Exp $
    6: 
    7: # For RedHat and cousins:
    8: # chkconfig: 2345 40 40
    9: # description: Self Monitoring and Reporting Technology (SMART) Daemon
   10: # processname: smartd 
   11: 
   12: # For SuSE and cousins
   13: ### BEGIN INIT INFO
   14: # Provides:                   smartd
   15: # Required-Start:             $syslog $remote_fs
   16: # Should-Start:               sendmail
   17: # Required-Stop:              $syslog $remote_fs
   18: # Should-Stop:                sendmail
   19: # Default-Start:              2 3 5
   20: # Default-Stop:
   21: # Short-Description:          Monitors disk and tape health via S.M.A.R.T.
   22: # Description:                Start S.M.A.R.T. disk and tape monitor.
   23: ### END INIT INFO
   24: 
   25: # This program is free software; you can redistribute it and/or modify it
   26: # under the terms of the GNU General Public License as published by the Free
   27: # Software Foundation; either version 2, or (at your option) any later
   28: # version. 
   29: # You should have received a copy of the GNU General Public License (for
   30: # example COPYING); if not, write to the Free Software Foundation, Inc.,
   31: # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   32: # This code was originally developed as a Senior Thesis by Michael Cornwell
   33: # at the Concurrent Systems Laboratory (now part of the Storage Systems
   34: # Research Center), Jack Baskin School of Engineering, University of
   35: # California, Santa Cruz. http://ssrc.soe.ucsc.edu/.
   36: 
   37: # Uncomment the line below to pass options to smartd on startup. 
   38: # Note that distribution specific configuration files like
   39: # /etc/{default,sysconfig}/smartmontools might override these
   40: #smartd_opts="--interval=1800"
   41: 
   42: SMARTD_BIN=/usr/local/sbin/smartd
   43: 
   44: report_unsupported () {
   45:     echo "Currently the smartmontools package has no init script for"
   46:     echo "the $1 OS/distribution. If you can provide one or this"
   47:     echo "one works after removing some ifdefs, please contact"
   48:     echo "smartmontools-support@lists.sourceforge.net."
   49:     exit 1
   50: }
   51: 
   52: # Red Hat or Yellow Dog or Mandrake
   53: if [ -f /etc/redhat-release -o -f /etc/yellowdog-release -o -f /etc/mandrake-release -o -f /etc/whitebox-release -o -f /etc/trustix-release -o -f /etc/tinysofa-release ] ; then
   54: 
   55:     # Source function library
   56:     . /etc/rc.d/init.d/functions
   57: 
   58:     # Source configuration file.  This should define the shell variable smartd_opts
   59:     [ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
   60: 
   61:     RETVAL=0
   62: 
   63:     prog=smartd
   64:     pidfile=/var/lock/subsys/smartd
   65:     config=/etc/smartd.conf
   66: 
   67:     start()
   68:     {
   69: 	[ $UID -eq 0 ] || exit 4
   70: 	[ -x $SMARTD_BIN ] || exit 5
   71: 	[ -f $config ] || exit 6
   72: 	echo -n $"Starting $prog: "
   73: 	daemon $SMARTD_BIN $smartd_opts
   74: 	RETVAL=$?
   75: 	echo
   76: 	[ $RETVAL = 0 ] && touch $pidfile
   77: 	return $RETVAL
   78:     }
   79: 
   80:     stop()
   81:     {
   82: 	[ $UID -eq 0 ] || exit 4
   83: 	echo -n $"Shutting down $prog: "
   84: 	killproc $SMARTD_BIN
   85: 	RETVAL=$?
   86: 	echo
   87: 	rm -f $pidfile
   88: 	return $RETVAL
   89:     }
   90: 
   91:     reload()
   92:     {
   93: 	echo -n $"Reloading $prog daemon configuration: "
   94: 	killproc $SMARTD_BIN -HUP
   95: 	RETVAL=$?
   96: 	echo
   97: 	return $RETVAL
   98:     }
   99: 
  100:     report()
  101:     {
  102: 	echo -n $"Checking SMART devices now: "
  103: 	killproc $SMARTD_BIN -USR1
  104: 	RETVAL=$?
  105: 	echo
  106: 	return $RETVAL
  107:     }
  108: 
  109:     case "$1" in
  110: 	start)
  111: 		start
  112: 		;;
  113: 	stop)
  114: 		stop
  115: 		;;
  116: 	reload)
  117: 		reload
  118: 		;;
  119: 	report)
  120: 		report
  121: 		;;
  122: 	restart)
  123: 		stop
  124: 		start
  125: 		;;
  126: 	condrestart|try-restart)
  127: 		if [ -f $pidfile ]; then
  128: 			stop
  129: 			start
  130: 		fi
  131: 		;;
  132: 	force-reload)
  133: 		reload || (stop; start)
  134: 		;;
  135: 	status)
  136: 		status $prog
  137: 		RETVAL=$?
  138: 		;;
  139: 	*)
  140: 		echo $"Usage: $0 {start|stop|restart|status|condrestart|try-restart|reload|force-reload|report}"
  141: 		RETVAL=2
  142: 		[ "$1" = 'usage' ] && RETVAL=0
  143:     esac
  144:     exit $RETVAL
  145: 
  146: # Slackware
  147: elif [ -f /etc/slackware-version ] ; then
  148: 
  149:     # Source configuration file.  This should define the shell variable smartd_opts.
  150:     # Email smartmontools-support@lists.sourceforge.net if there is a better choice
  151:     # of path for Slackware.
  152: 
  153:     [ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
  154: 
  155:     RETVAL=0
  156:     case "$1" in
  157: 	start)
  158: 	    echo -n "Starting smartd: "
  159: 	    $SMARTD_BIN $smartd_opts
  160: 	    RETVAL=$?
  161: 	    echo
  162: 	    ;;
  163: 	stop)
  164: 	    echo -n "Shutting down smartd: "
  165: 	    killall $SMARTD_BIN
  166: 	    RETVAL=$?
  167: 	    echo
  168: 	    ;;
  169: 	restart)
  170: 	    $0 stop
  171: 	    sleep 1
  172: 	    $0 start
  173: 	    RETVAL=$?
  174: 	    ;;
  175: 	try-restart)
  176: 	    if pidof $SMARTD_BIN >/dev/null; then
  177: 		$0 restart
  178: 		RETVAL=$?
  179: 	    fi
  180: 	    ;;
  181: 	force-reload)
  182: 	    $0 reload || $0 restart
  183: 	    RETVAL=$?
  184: 	    ;;
  185: 	reload)
  186: 	    echo -n "Reloading smartd configuration: "
  187: 	    killall -s HUP $SMARTD_BIN
  188: 	    RETVAL=$?
  189: 	    echo
  190: 	    ;;
  191: 	report)
  192: 	    echo -n "Checking SMART devices now: "
  193: 	    killall -s USR1 $SMARTD_BIN
  194: 	    RETVAL=$?
  195: 	    echo
  196: 	    ;;
  197: 	status)
  198: 	    if pidof $SMARTD_BIN >/dev/null; then
  199: 		echo "$SMARTD_BIN is running."
  200: 	    else
  201: 		echo "$SMARTD_BIN is not running."
  202: 		RETVAL=1
  203: 	    fi
  204: 	    ;;
  205: 	*)
  206: 	    echo "Usage: $0 {start|stop|restart|try-restart|force-reload|reload|report|status}"
  207: 	    RETVAL=1
  208:     esac
  209:     exit $RETVAL
  210: 
  211: # SuSE
  212: elif [ -f /etc/SuSE-release ] ; then
  213:     test -x $SMARTD_BIN || exit 5
  214: 
  215:     # Existence of config file is optional
  216:     SMARTD_CONFIG=/etc/smartd.conf
  217: 
  218:     # source configuration file.
  219:     [ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
  220:     smartd_opts=
  221:     if test -n "$SMARTD_CHECK_INTERVAL" -a "$SMARTD_CHECK_INTERVAL" != 1800 ; then
  222:        smartd_opts=" -i $SMARTD_CHECK_INTERVAL"
  223:     fi
  224:     if test -n "$SMARTD_LOG_FACILITY" -a "$SMARTD_LOG_FACILITY" != "daemon" ; then
  225:        smartd_opts="$smartd_opts -l $SMARTD_LOG_FACILITY"
  226:     fi
  227:     if test -n "$SMARTD_DRIVEDB" ; then
  228:        smartd_opts="$smartd_opts -B $SMARTD_DRIVEDB"
  229:     fi
  230:     if test "$SMARTD_SAVESTATES" = "no" ; then
  231: 	smartd_opts="$smartd_opts -s \"\""
  232:     fi
  233:     if test "$SMARTD_ATTRLOG" = "no" ; then
  234: 	smartd_opts="$smartd_opts -A \"\""
  235:     fi
  236:     if test -n "$SMARTD_EXTRA_OPTS" ; then
  237: 	smartd_opts="$smartd_opts $SMARTD_EXTRA_OPTS"
  238:     fi
  239: 
  240:     # Shell functions sourced from /etc/rc.status:
  241:     #      rc_check         check and set local and overall rc status
  242:     #      rc_status        check and set local and overall rc status
  243:     #      rc_status -v     be verbose in local rc status and clear it afterwards
  244:     #      rc_status -v -r  ditto and clear both the local and overall rc status
  245:     #      rc_status -s     display "skipped" and exit with status 3
  246:     #      rc_status -u     display "unused" and exit with status 3
  247:     #      rc_failed        set local and overall rc status to failed
  248:     #      rc_failed <num>  set local and overall rc status to <num>
  249:     #      rc_reset         clear both the local and overall rc status
  250:     #      rc_exit          exit appropriate to overall rc status
  251:     #      rc_active        checks whether a service is activated by symlinks
  252:     . /etc/rc.status
  253: 
  254:     # Reset status of this service
  255:     rc_reset
  256: 
  257:     # Return values acc. to LSB for all commands but status:
  258:     # 0       - success
  259:     # 1       - generic or unspecified error
  260:     # 2       - invalid or excess argument(s)
  261:     # 3       - unimplemented feature (e.g. "reload")
  262:     # 4       - user had insufficient privileges
  263:     # 5       - program is not installed
  264:     # 6       - program is not configured
  265:     # 7       - program is not running
  266:     # 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
  267:     #
  268:     # Note that starting an already running service, stopping
  269:     # or restarting a not-running service as well as the restart
  270:     # with force-reload (in case signaling is not supported) are
  271:     # considered a success.
  272: 
  273:     case "$1" in
  274: 	start)
  275: 	    echo -n "Starting smartd "
  276: 	    ## Start daemon with startproc(8). If this fails
  277: 	    ## the return value is set appropriately by startproc.
  278: 
  279: 	    # We don't use startproc - we need to check for return code 17.
  280: 	    if ! /sbin/checkproc $SMARTD_BIN ; then
  281: 		eval $SMARTD_BIN$smartd_opts
  282: 		# Remember status and be verbose
  283: 		if test $? -ne 17 ; then
  284: 		    rc_status -v
  285: 		else
  286: 		    rc_status -u
  287: 		fi
  288: 	    else
  289: 		rc_reset
  290: 		rc_status -v
  291: 	    fi
  292: 	    ;;
  293: 	stop)
  294: 	    echo -n "Shutting down smartd "
  295: 	    /sbin/killproc -TERM $SMARTD_BIN
  296: 	    # Remember status and be verbose
  297: 	    rc_status -v
  298: 	    ;;
  299: 	try-restart)
  300: 	    ## Do a restart only if the service was active before.
  301: 	    ## Note: try-restart is now part of LSB (as of 1.9).
  302: 	    $0 status
  303: 	    if test $? = 0; then
  304: 		$0 restart
  305: 	    else
  306: 		rc_reset	# Not running is not a failure.
  307: 	    fi
  308: 	    # Remember status and be quiet
  309: 	    rc_status
  310: 	    ;;
  311: 	restart)
  312: 	    $0 stop
  313: 	    $0 start
  314: 	    # Remember status and be quiet
  315: 	    rc_status
  316: 	    ;;
  317: 	force-reload|reload)
  318: 	    echo -n "Reload service smartd "
  319: 	    /sbin/killproc -HUP $SMARTD_BIN
  320: 	    rc_status -v
  321: 	    ;;
  322: 	report)
  323: 	    ## Checking SMART devices now (smartd specific function)
  324: 	    echo -n "Checking SMART devices now "
  325: 	    /sbin/killproc -USR1 $SMARTD_BIN
  326: 	    rc_status -v
  327: 	    ;;
  328: 	status)
  329: 	    echo -n "Checking for service smartd "
  330: 	    ## Check status with checkproc(8), if process is running
  331: 	    ## checkproc will return with exit status 0.
  332: 
  333: 	    # Return value is slightly different for the status command:
  334: 	    # 0 - service up and running
  335: 	    # 1 - service dead, but /var/run/  pid  file exists
  336: 	    # 2 - service dead, but /var/lock/ lock file exists
  337: 	    # 3 - service not running (unused)
  338: 	    # 4 - service status unknown :-(
  339: 	    # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
  340: 
  341: 	    # NOTE: checkproc returns LSB compliant status values.
  342: 	    /sbin/checkproc $SMARTD_BIN
  343: 	    rc_status -v
  344: 	    ;;
  345: 	probe)
  346: 	    ## Optional: Probe for the necessity of a reload, print out the
  347: 	    ## argument to this init script which is required for a reload.
  348: 	    ## Note: probe is not (yet) part of LSB (as of 1.9)
  349: 
  350: 	    test $SMARTD_CONFIG -nt /var/run/smartd.pid && echo reload
  351: 	    ;;
  352: 	*)
  353: 	    echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|report|probe}"
  354: 	    exit 1
  355:     esac
  356:     rc_exit
  357: 
  358: # Debian case
  359: elif [ -f /etc/debian_version ] ; then
  360:     PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  361:     SMARTDPID=/var/run/smartd.pid
  362:     [ -x $SMARTD_BIN ] || exit 0
  363:     RET=0
  364: 
  365:     # source configuration file
  366:     [ -r /etc/default/rcS ] && . /etc/default/rcS
  367:     [ -r /etc/default/smartmontools ] && . /etc/default/smartmontools
  368: 
  369:     smartd_opts="--pidfile $SMARTDPID $smartd_opts"
  370: 
  371:     case "$1" in
  372: 	start)
  373: 		echo -n "Starting S.M.A.R.T. daemon: smartd"
  374: 		if start-stop-daemon --start --quiet --pidfile $SMARTDPID \
  375: 			--exec $SMARTD_BIN -- $smartd_opts; then
  376: 			echo "."
  377: 		else
  378: 			echo " (failed)"
  379: 			RET=1
  380: 		fi
  381: 		;;
  382: 	stop)
  383: 		echo -n "Stopping S.M.A.R.T. daemon: smartd"
  384: 		start-stop-daemon --stop --quiet --oknodo --pidfile $SMARTDPID
  385: 		echo "."
  386: 		;;
  387: 	restart)
  388: 		$0 stop
  389: 		$0 start
  390: 		;;
  391: 	force-reload)
  392: 		$0 reload || $0 restart
  393: 		;;
  394: 	reload)
  395: 		echo -n "Reload S.M.A.R.T. daemon: smartd"
  396: 		if start-stop-daemon --stop --quiet --signal 1 \
  397: 			--pidfile $SMARTDPID; then
  398: 			echo "."
  399: 		else
  400: 			echo " (failed)"
  401: 			RET=1
  402: 		fi
  403: 		;;
  404: 	report)
  405: 		echo -n "Checking SMART devices now"
  406: 		if start-stop-daemon --stop --quiet --signal 10 \
  407: 			--pidfile $SMARTDPID; then
  408: 			echo "."
  409: 		else
  410: 			echo " (failed)"
  411: 			RET=1
  412: 		fi
  413: 		;;
  414: 	status)
  415: 		if pidof $SMARTD_BIN >/dev/null; then
  416: 			echo "$SMARTD_BIN is running."
  417: 		else
  418: 			echo "$SMARTD_BIN is not running."
  419: 			RET=1
  420: 		fi
  421: 		;;
  422: 	*)
  423: 		echo "Usage: $0 {start|stop|restart|force-reload|reload|report|status}"
  424: 		exit 1
  425:     esac
  426:     exit $RET
  427: 
  428: elif [ -f /etc/gentoo-release ] ; then
  429:     report_unsupported "Gentoo"
  430: 
  431: elif [ -f /etc/turbolinux-release ] ; then
  432:     report_unsupported "Turbolinux"
  433: 
  434: elif [ -f /etc/environment.corel ] ; then
  435:     report_unsupported "Corel"
  436: 
  437: # PLEASE ADD OTHER LINUX DISTRIBUTIONS JUST BEFORE THIS LINE, USING elif
  438: 
  439: elif uname -a | grep FreeBSD > /dev/null 2>&1 ; then
  440:     # following is replaced by port install
  441:     PREFIX=@@PREFIX@@
  442: 
  443:     # Updated to try both the RCNG version of things from 5.x, or fallback to
  444:     # oldfashioned rc.conf
  445: 
  446:     if [ -r /etc/rc.subr ]; then
  447: 	# This is RC-NG, pick up our values
  448: 	. /etc/rc.subr
  449: 	name="smartd"
  450: 	rcvar="smartd_enable"
  451: 	command="$SMARTD_BIN"
  452: 	load_rc_config $name
  453:     elif [ -r /etc/defaults/rc.conf ]; then
  454: 	# Not a 5.x system, try the default location for variables
  455: 	. /etc/defaults/rc.conf
  456: 	source_rc_confs
  457:     elif [ -r /etc/rc.conf ]; then
  458: 	# Worst case, fallback to system config file
  459: 	. /etc/rc.conf
  460:     fi
  461: 
  462:     if [ -r /etc/rc.subr ]; then
  463: 	# Use new functionality from RC-NG
  464: 	run_rc_command "$1"
  465:     else
  466: 	PID_FILE=/var/run/smartd.pid
  467: 	case "$1" in
  468: 	    start)
  469: 		$SMARTD_BIN -p $PID_FILE $smartd_flags
  470: 		echo -n " smartd"
  471: 		;;
  472: 	    stop)
  473: 		kill `cat $PID_FILE`
  474: 		echo -n " smartd"
  475: 		;;
  476: 	    restart)
  477: 		$0 stop
  478: 		sleep 1
  479: 		$0 start
  480: 		;;
  481: 	    reload)
  482: 		kill -s HUP `cat $PID_FILE`
  483: 		;;
  484: 	    report)
  485: 		kill -s USR1 `cat $PID_FILE`
  486: 		;;
  487: 	    *)
  488: 		echo "Usage: $0 {start|stop|restart|reload|report}"
  489: 		exit 1
  490: 	esac
  491: 	exit 0
  492:     fi
  493: 
  494: elif uname -a | grep SunOS > /dev/null 2>&1 ; then
  495: 
  496:     # Source configuration file.  This should define the shell variable smartd_opts.
  497:     # Email smartmontools-support@lists.sourceforge.net if there is a better choice
  498:     # of path for Solaris
  499: 
  500:     [ -r /etc/default/smartmontools ] && . /etc/default/smartmontools
  501: 
  502:     PID_FILE=/var/run/smartd.pid
  503: 
  504:     case "$1" in
  505: 	start)
  506: 	    $SMARTD_BIN -p $PID_FILE $smartd_opts
  507: 	    echo -n "smartd "
  508: 	    ;;
  509: 	stop)
  510: 	    [ -f $PID_FILE ] && kill `cat $PID_FILE`
  511: 	    echo -n "smartd "
  512: 	    ;;
  513: 	restart)
  514: 	    $0 stop
  515: 	    sleep 1
  516: 	    $0 start
  517: 	    ;;
  518: 	reload)
  519: 	    kill -s HUP `cat $PID_FILE`
  520: 	    ;;
  521: 	report)
  522: 	    kill -s USR1 `cat $PID_FILE`
  523: 	    ;;
  524: 	*)
  525: 	    echo "Usage: $0 {start|stop|restart|reload|report}"
  526: 	    exit 1
  527:     esac
  528:     exit 0
  529: 
  530: # Cygwin
  531: elif uname | grep -i CYGWIN > /dev/null 2>&1 ; then
  532: 
  533:     # The following settings may be changed by the configuration file below
  534:     # Service Name (must be unique)
  535:     smartd_svcname=smartd
  536:     # Service display name
  537:     smartd_svcdisp="CYGWIN smartd"
  538:     # Service description
  539:     smartd_svcdesc="\
  540: Controls and monitors storage devices using the Self-Monitoring \
  541: Analysis and Reporting Technology System (S.M.A.R.T.) \
  542: built into ATA and SCSI Hard Drives. \
  543: http://smartmontools.sourceforge.net/"
  544: 
  545:     # Source configuration file.  This should define the shell variable smartd_opts.
  546:     # Email smartmontools-support@lists.sourceforge.net if there is a better choice
  547:     # of path for Cygwin
  548: 
  549:     [ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
  550: 
  551:     PID_FILE=/var/run/smartd.pid
  552:     RETVAL=0
  553: 
  554:     # Note: "[ -r $PID_FILE ]" is not used here. On Cygwin, this command may
  555:     # return success even if the file is present but cannot be read by current user.
  556:     # If smartd is running as service, smartd.pid is owned by local system account
  557:     # which is different from any user ever executing this script.
  558: 
  559:     case "$1" in
  560:         start)
  561:             if cygrunsrv -L 2>/dev/null | grep "^${smartd_svcname}$" >/dev/null 2>&1; then
  562:                 echo -n "Starting service $smartd_svcname: "
  563:                 cygrunsrv -S "$smartd_svcname"
  564:             else
  565:                 echo -n "Starting smartd as daemon: "
  566:                 $SMARTD_BIN -p $PID_FILE $smartd_opts
  567:             fi
  568:             RETVAL=$?
  569:             ;;
  570:         stop)
  571:             echo -n "Shutting down smartd: "
  572:             pid="`cat $PID_FILE 2>/dev/null`" && kill "$pid"
  573:             RETVAL=$?
  574:             ;;
  575:         reload)
  576:             echo -n "Reloading smartd configuration: "
  577:             pid="`cat $PID_FILE 2>/dev/null`" && kill -HUP "$pid"
  578:             RETVAL=$?
  579:             ;;
  580:         report)
  581:             echo -n "Checking SMART devices now: "
  582:             pid="`cat $PID_FILE 2>/dev/null`" && kill -USR1 "$pid"
  583:             RETVAL=$?
  584:             ;;
  585:         restart)
  586:             $0 stop
  587:             sleep 1
  588:             $0 start
  589:             exit $?
  590:             ;;
  591:         install)
  592:             shift
  593:             [ $# -eq 0 ] || smartd_opts="$*"
  594:             dep=; dep2=
  595:             if cygrunsrv -L 2>/dev/null | grep "^syslogd$" >/dev/null 2>&1; then
  596:                 dep="syslogd"
  597:             fi
  598:             if cygrunsrv -L 2>/dev/null | grep "^syslog-ng" >/dev/null 2>&1; then
  599:                 dep2="syslog-ng"
  600:             fi
  601:             if [ -z "$dep" ]; then
  602:                 if [ -z "$dep2" ]; then
  603:                     echo "Warning: no syslog service installed, smartd will write to windows event log.";
  604:                 else
  605:                     dep="$dep2"
  606:                 fi
  607:             else
  608:                 if [ -z "$dep2" ]; then
  609:                     :
  610:                 else
  611:                     dep=
  612:                     echo "Warning: both syslogd and syslog-ng installed, dependency not set."
  613:                 fi
  614:             fi
  615:             echo "Installing service ${smartd_svcname}${dep:+ (depending on '$dep')}${smartd_opts:+ with options '$smartd_opts'}:"
  616:             cygrunsrv -I "$smartd_svcname" -d "$smartd_svcdisp"  -f "$smartd_svcdesc" ${dep:+-y} $dep \
  617:               -e CYGWIN="$CYGWIN" -p $SMARTD_BIN -a "-n -p ${PID_FILE}${smartd_opts:+ }$smartd_opts"
  618:             RETVAL=$?
  619:             ;;
  620:         remove)
  621:             echo "Removing service $smartd_svcname:"
  622:             cygrunsrv -R "$smartd_svcname"
  623:             RETVAL=$?
  624:             ;;
  625:         status)
  626:             echo -n "Checking smartd status: "
  627:             if cygrunsrv -L 2>/dev/null | grep "^${smartd_svcname}$" >/dev/null 2>&1; then
  628:                 if cygrunsrv -Q "$smartd_svcname" 2>/dev/null | grep "State *: Running" >/dev/null 2>&1; then
  629:                     echo "running as service '$smartd_svcname'."
  630:                 elif ps -e 2>/dev/null | grep " ${SMARTD_BIN}$" >/dev/null 2>&1; then
  631:                     echo "installed as service '$smartd_svcname' but running as daemon."
  632:                 else
  633:                     echo "installed as service '$smartd_svcname' but not running."
  634:                     RETVAL=1
  635:                 fi
  636:             elif ps -e 2>/dev/null | grep " ${SMARTD_BIN}$" >/dev/null 2>&1; then
  637:                 echo "running as daemon."
  638:             else
  639:                 echo "not running."
  640:                 RETVAL=1
  641:             fi
  642:             exit $RETVAL
  643:             ;;
  644:         *)
  645:             echo "Usage: $0 {start|stop|restart|reload|report|status}"
  646:             echo "       $0 {install [options]|remove}"
  647:             exit 1
  648:     esac
  649: 
  650:     if [ "$RETVAL" -eq 0 ]; then echo "done"; else echo "ERROR"; fi
  651:     exit $RETVAL
  652: 
  653: # Add other OSes HERE, using elif...
  654: else
  655:     report_unsupported "Unknown"
  656: fi
  657: 
  658: # One should NEVER arrive here, except for a badly written case above,
  659: # that fails to exit.
  660: echo "SOMETHING IS WRONG WITH THE SMARTD STARTUP SCRIPT"
  661: echo "PLEASE CONTACT smartmontools-support@lists.sourceforge.net"
  662: exit 1

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>