smartmontools/smartd.initd
Tomáš Mráz 9b8343902b - set cloexec on device descriptor so it doesn't leak to sendmail (#214182)
- fixed minor bug in initscript (#213683)
- backported SATA disk detection from upstream
2006-11-07 10:19:40 +00:00

90 lines
2.5 KiB
Bash

#! /bin/sh
# smartmontools init file for smartd
# Copyright (C) 2002-4 Bruce Allen <smartmontools-support@lists.sourceforge.net>
# $Id: smartd.initd,v 1.4 2006/11/07 10:19:40 tmraz Exp $
# For RedHat and cousins:
# chkconfig: 2345 99 01
# description: Self Monitoring and Reporting Technology (SMART) Daemon
# processname: smartd
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any later
# version.
# You should have received a copy of the GNU General Public License (for
# example COPYING); if not, write to the Free Software Foundation, Inc., 675
# Mass Ave, Cambridge, MA 02139, USA.
# This code was originally developed as a Senior Thesis by Michael Cornwell
# at the Concurrent Systems Laboratory (now part of the Storage Systems
# Research Center), Jack Baskin School of Engineering, University of
# California, Santa Cruz. http://ssrc.soe.ucsc.edu/.
# Uncomment the line below to pass options to smartd on startup.
# Note that distribution specific configuration files like
# /etc/{default,sysconfig}/smartmontools might override these
#smartd_opts="--interval=1800"
SMARTD_BIN=/usr/sbin/smartd
# Source function library
. /etc/rc.d/init.d/functions
[ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
case "$1" in
start | reload | restart)
GEN_CONF="*SMARTD*AUTOGENERATED*"
[ ! -f /etc/smartd.conf ] || read DUMMY GEN_CONF DUMMY </etc/smartd.conf \
&& [ "$GEN_CONF" == "*SMARTD*AUTOGENERATED*" ] \
&& smartd-conf.py 2>/dev/null >/etc/smartd.conf.new-autogenerated \
&& mv -f /etc/smartd.conf.new-autogenerated /etc/smartd.conf
;;
esac
RETVAL=0
prog=smartd
case "$1" in
start)
echo -n $"Starting $prog: "
daemon $SMARTD_BIN $smartd_opts
touch /var/lock/subsys/smartd
echo
exit 0
;;
stop)
echo -n $"Shutting down $prog: "
killproc $SMARTD_BIN
rm -f /var/lock/subsys/smartd
echo
;;
reload)
echo -n $"Reloading $prog daemon configuration: "
killproc $SMARTD_BIN -HUP
RETVAL=$?
echo
;;
report)
echo -n $"Checking SMART devices now: "
killproc $SMARTD_BIN -USR1
RETVAL=$?
echo
;;
restart)
$0 stop
$0 start
;;
status)
status $prog
;;
*)
echo $"Usage: $0 {start|stop|reload|report|restart|status}"
RETVAL=1
esac
exit $RETVAL