xref: /OK3568_Linux_fs/yocto/meta-openembedded/meta-oe/recipes-extended/smartmontools/files/initd.smartd (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#! /bin/sh
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun# smartmontools init file for smartd
4*4882a593Smuzhiyun# Copyright (C) 2002-8 Bruce Allen <smartmontools-support@lists.sourceforge.net>
5*4882a593Smuzhiyun# $Id: smartd.initd.in 3360 2011-06-06 19:25:36Z chrfranke $
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun# For RedHat and cousins:
8*4882a593Smuzhiyun# chkconfig: - 60 60
9*4882a593Smuzhiyun# description: Self Monitoring and Reporting Technology (SMART) Daemon
10*4882a593Smuzhiyun# processname: smartd
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun# For SuSE and cousins
13*4882a593Smuzhiyun### BEGIN INIT INFO
14*4882a593Smuzhiyun# Provides:                   smartd
15*4882a593Smuzhiyun# Required-Start:             $syslog $remote_fs
16*4882a593Smuzhiyun# Should-Start:               sendmail
17*4882a593Smuzhiyun# Required-Stop:              $syslog $remote_fs
18*4882a593Smuzhiyun# Should-Stop:                sendmail
19*4882a593Smuzhiyun# Default-Start:              2 3 4 5
20*4882a593Smuzhiyun# Default-Stop:               0 1 6
21*4882a593Smuzhiyun# Short-Description:          Monitors disk and tape health via S.M.A.R.T.
22*4882a593Smuzhiyun# Description:                Start S.M.A.R.T. disk and tape monitor.
23*4882a593Smuzhiyun### END INIT INFO
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun# This program is free software; you can redistribute it and/or modify it
26*4882a593Smuzhiyun# under the terms of the GNU General Public License as published by the Free
27*4882a593Smuzhiyun# Software Foundation; either version 2, or (at your option) any later
28*4882a593Smuzhiyun# version.
29*4882a593Smuzhiyun# You should have received a copy of the GNU General Public License (for
30*4882a593Smuzhiyun# example COPYING); if not, write to the Free Software Foundation, Inc., 675
31*4882a593Smuzhiyun# Mass Ave, Cambridge, MA 02139, USA.
32*4882a593Smuzhiyun# This code was originally developed as a Senior Thesis by Michael Cornwell
33*4882a593Smuzhiyun# at the Concurrent Systems Laboratory (now part of the Storage Systems
34*4882a593Smuzhiyun# Research Center), Jack Baskin School of Engineering, University of
35*4882a593Smuzhiyun# California, Santa Cruz. http://ssrc.soe.ucsc.edu/.
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun# Uncomment the line below to pass options to smartd on startup.
38*4882a593Smuzhiyun# Note that distribution specific configuration files like
39*4882a593Smuzhiyun# /etc/{default,sysconfig}/smartmontools might override these
40*4882a593Smuzhiyun#smartd_opts="--interval=1800"
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunSMARTD_BIN=/usr/sbin/smartd
43*4882a593SmuzhiyunSMARTDPID=/var/run/smartd.pid
44*4882a593Smuzhiyun[ -x $SMARTD_BIN ] || exit 0
45*4882a593SmuzhiyunRET=0
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun# source configuration file
48*4882a593Smuzhiyun[ -r /etc/default/rcS ] && . /etc/default/rcS
49*4882a593Smuzhiyun[ -r /etc/default/smartmontools ] && . /etc/default/smartmontools
50*4882a593Smuzhiyun
51*4882a593Smuzhiyunsmartd_opts="--pidfile $SMARTDPID $smartd_opts"
52*4882a593Smuzhiyun
53*4882a593Smuzhiyuncase "$1" in
54*4882a593Smuzhiyun	start)
55*4882a593Smuzhiyun		if [ "$start_smartd" != "yes" ]; then
56*4882a593Smuzhiyun			[ "$VERBOSE" != "no" ] && echo "Not starting S.M.A.R.T. daemon smartd, disabled via /etc/default/smartmontools"
57*4882a593Smuzhiyun			exit 0
58*4882a593Smuzhiyun		fi
59*4882a593Smuzhiyun		echo -n "Starting S.M.A.R.T. daemon: smartd"
60*4882a593Smuzhiyun		if start-stop-daemon --start --quiet --pidfile $SMARTDPID \
61*4882a593Smuzhiyun			--exec $SMARTD_BIN -- $smartd_opts; then
62*4882a593Smuzhiyun			echo "."
63*4882a593Smuzhiyun		else
64*4882a593Smuzhiyun			echo " (failed)"
65*4882a593Smuzhiyun			RET=1
66*4882a593Smuzhiyun		fi
67*4882a593Smuzhiyun		;;
68*4882a593Smuzhiyun	stop)
69*4882a593Smuzhiyun		echo -n "Stopping S.M.A.R.T. daemon: smartd"
70*4882a593Smuzhiyun		start-stop-daemon --stop --quiet --oknodo --pidfile $SMARTDPID
71*4882a593Smuzhiyun		echo "."
72*4882a593Smuzhiyun		;;
73*4882a593Smuzhiyun	restart)
74*4882a593Smuzhiyun		$0 stop
75*4882a593Smuzhiyun		$0 start
76*4882a593Smuzhiyun		;;
77*4882a593Smuzhiyun	force-reload)
78*4882a593Smuzhiyun		$0 reload || $0 restart
79*4882a593Smuzhiyun		;;
80*4882a593Smuzhiyun	reload)
81*4882a593Smuzhiyun		echo -n "Reload S.M.A.R.T. daemon: smartd"
82*4882a593Smuzhiyun		if start-stop-daemon --stop --quiet --signal 1 \
83*4882a593Smuzhiyun			--pidfile $SMARTDPID; then
84*4882a593Smuzhiyun			echo "."
85*4882a593Smuzhiyun		else
86*4882a593Smuzhiyun			echo " (failed)"
87*4882a593Smuzhiyun			RET=1
88*4882a593Smuzhiyun		fi
89*4882a593Smuzhiyun		;;
90*4882a593Smuzhiyun	report)
91*4882a593Smuzhiyun		echo -n "Checking SMART devices now"
92*4882a593Smuzhiyun		if start-stop-daemon --stop --quiet --signal 10 \
93*4882a593Smuzhiyun			--pidfile $SMARTDPID; then
94*4882a593Smuzhiyun			echo "."
95*4882a593Smuzhiyun		else
96*4882a593Smuzhiyun			echo " (failed)"
97*4882a593Smuzhiyun			RET=1
98*4882a593Smuzhiyun		fi
99*4882a593Smuzhiyun		;;
100*4882a593Smuzhiyun	status)
101*4882a593Smuzhiyun		if pidof $SMARTD_BIN >/dev/null; then
102*4882a593Smuzhiyun			echo "$SMARTD_BIN is running."
103*4882a593Smuzhiyun		else
104*4882a593Smuzhiyun			echo "$SMARTD_BIN is not running."
105*4882a593Smuzhiyun			RET=1
106*4882a593Smuzhiyun		fi
107*4882a593Smuzhiyun		;;
108*4882a593Smuzhiyun	*)
109*4882a593Smuzhiyun		echo "Usage: $0 {start|stop|restart|force-reload|reload|report|status}"
110*4882a593Smuzhiyun		exit 1
111*4882a593Smuzhiyunesac
112*4882a593Smuzhiyunexit $RET
113