]>
git.proxmox.com Git - mirror_smartmontools-debian.git/blob - smartd.cygwin.initd.in
3 # smartmontools initd file for Cygwin smartd
5 # Home page of code is: http://www.smartmontools.org
7 # Copyright (C) 2004-17 Christian Franke
9 # SPDX-License-Identifier: GPL-2.0-or-later
11 # $Id: smartd.cygwin.initd.in 4760 2018-08-19 18:45:53Z chrfranke $
14 SMARTD_BIN
=/usr
/local
/sbin
/smartd
16 # The following settings may be changed by the configuration file below
17 # Service Name (must be unique)
19 # Service display name
20 smartd_svcdisp
="CYGWIN smartd"
23 Controls and monitors storage devices using the Self-Monitoring, \
24 Analysis and Reporting Technology System (SMART) built into \
25 ATA/SATA and SCSI/SAS hard drives and solid-state drives. \
26 www.smartmontools.org"
28 # Source configuration file.
29 [ -r /etc
/sysconfig
/smartmontools
] && .
/etc
/sysconfig
/smartmontools
31 PID_FILE
=/var
/run
/smartd.pid
34 # Note: "[ -r $PID_FILE ]" is not used here. On Cygwin, this command may
35 # return success even if the file is present but cannot be read by current user.
36 # If smartd is running as service, smartd.pid is owned by local system account
37 # which is different from any user ever executing this script.
41 if cygrunsrv
-L 2>/dev
/null |
grep "^${smartd_svcname}$" >/dev
/null
2>&1; then
42 echo -n "Starting service $smartd_svcname: "
43 cygrunsrv
-S "$smartd_svcname"
45 echo -n "Starting smartd as daemon: "
46 $SMARTD_BIN -p $PID_FILE $smartd_opts
51 echo -n "Shutting down smartd: "
52 pid
="`cat $PID_FILE 2>/dev/null`" && kill "$pid"
56 echo -n "Reloading smartd configuration: "
57 pid
="`cat $PID_FILE 2>/dev/null`" && kill -HUP "$pid"
61 echo -n "Checking SMART devices now: "
62 pid
="`cat $PID_FILE 2>/dev/null`" && kill -USR1 "$pid"
73 [ $# -eq 0 ] || smartd_opts
="$*"
75 if cygrunsrv
-L 2>/dev
/null |
grep "^syslogd$" >/dev
/null
2>&1; then
78 if cygrunsrv
-L 2>/dev
/null |
grep "^syslog-ng" >/dev
/null
2>&1; then
81 if [ -z "$dep" ]; then
82 if [ -z "$dep2" ]; then
83 echo "Warning: no syslog service installed, smartd will write to windows event log.";
88 if [ -z "$dep2" ]; then
92 echo "Warning: both syslogd and syslog-ng installed, dependency not set."
95 echo "Installing service ${smartd_svcname}${dep:+ (depending on '$dep')}${smartd_opts:+ with options '$smartd_opts'}:"
96 cygrunsrv
-I "$smartd_svcname" -d "$smartd_svcdisp" -f "$smartd_svcdesc" ${dep:+-y} $dep \
97 -e CYGWIN
="$CYGWIN" -p $SMARTD_BIN -a "-n -p ${PID_FILE}${smartd_opts:+ }$smartd_opts"
101 echo "Removing service $smartd_svcname:"
102 cygrunsrv
-R "$smartd_svcname"
106 echo -n "Checking smartd status: "
107 if cygrunsrv
-L 2>/dev
/null |
grep "^${smartd_svcname}$" >/dev
/null
2>&1; then
108 if cygrunsrv
-Q "$smartd_svcname" 2>/dev
/null |
grep "State *: Running" >/dev
/null
2>&1; then
109 echo "running as service '$smartd_svcname'."
110 elif ps
-e 2>/dev
/null |
grep " ${SMARTD_BIN}$" >/dev
/null
2>&1; then
111 echo "installed as service '$smartd_svcname' but running as daemon."
113 echo "installed as service '$smartd_svcname' but not running."
116 elif ps
-e 2>/dev
/null |
grep " ${SMARTD_BIN}$" >/dev
/null
2>&1; then
117 echo "running as daemon."
125 echo "Usage: $0 {start|stop|restart|reload|report|status}"
126 echo " $0 {install [options]|remove}"
130 if [ "$RETVAL" -eq 0 ]; then echo "done"; else echo "ERROR"; fi