[go: up one dir, main page]

File: mon_statd

package info (click to toggle)
s390-tools 2.15.1-2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 8,216 kB
  • sloc: ansic: 130,144; sh: 9,397; cpp: 8,359; perl: 2,517; makefile: 1,960; asm: 1,016
file content (161 lines) | stat: -rwxr-xr-x 2,938 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
### BEGIN INIT INFO
# Provides: mon_statd
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: 
# Should-Stop: 
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: Configure the mon_fsstatd and mon_procd daemons.
# Description: Configures the mon_fsstatd and mon_procd daemons. It uses the
#              configuration file /etc/sysconfig/mon_statd.
### END INIT INFO

# chkconfig: 235 01 99

DAEMON=mon_statd
FSSTATD=mon_fsstatd
PROCD=mon_procd
FSSTATD_PATH=/usr/sbin/$FSSTATD
PROCD_PATH=/usr/sbin/$PROCD
CONFIG_FILE=/etc/sysconfig/$DAEMON
FSSTATD_PID_FILE=/run/$FSSTATD.pid
PROCD_PID_FILE=/run/$PROCD.pid

# source function library
. /lib/lsb/init-functions

# Source config file
if [ -f $CONFIG_FILE ]; then
	. $CONFIG_FILE
fi

UDEVSETTLE=/bin/udevadm
if [ ! -e $UDEVSETTLE ]
then
	UDEVSETTLE=/sbin/udevsettle
	UDEVSETTLE_CALL="$UDEVSETTLE --timeout=10"
else
	UDEVSETTLE_CALL="$UDEVSETTLE settle --timeout=10"
fi

load_kernel_module()
{
	if [ ! -e /dev/monwriter ]; then
		echo "Loading monwriter module..."
		modprobe monwriter 2>&1
		if [ $? -ne 0 ]; then
			exit 1
		fi
		if [ -e $UDEVSETTLE ]
		then
			$UDEVSETTLE_CALL
		fi
	fi
}

start_daemon()
{
	local daemon_name=$1
	local daemon_interval=$2
	local daemon_pid_file=$3
	local daemon_path=$4

	if [ ! -f $daemon_pid_file ]; then
		load_kernel_module
		echo -n "Starting $daemon_name:"
		$daemon_path -i $daemon_interval
		if [ $? -eq 0 ]; then
			log_success_msg
		else
			log_failure_msg
		fi
	else
		echo "$daemon_name (pid $(cat $daemon_pid_file)) is already running..."
	fi
}
	
start()
{
	if [ "$FSSTAT" = "yes" ]; then
		start_daemon $FSSTATD $FSSTAT_INTERVAL $FSSTATD_PID_FILE \
			$FSSTATD_PATH
	fi

	if [ "$PROC" = "yes" ]; then
		start_daemon $PROCD $PROC_INTERVAL $PROCD_PID_FILE \
			$PROCD_PATH
	fi
}

stop_daemon()
{
	local daemon_name=$1
	local daemon_pid_file=$2
	local daemon_path=$3

	echo -n "Stopping $daemon_name:"
	if [ -f $daemon_pid_file ]; then
		killproc $daemon_path -TERM
		log_success_msg
		rm -f $daemon_pid_file
	else
		log_failure_msg
	fi
}

stop()
{
	if [ "$FSSTAT" = "yes" ]; then
		stop_daemon $FSSTATD $FSSTATD_PID_FILE $FSSTATD_PATH
	fi
	if [ "$PROC" = "yes" ]; then
		stop_daemon $PROCD $PROCD_PID_FILE $PROCD_PATH
	fi
}

restart() {
	stop
	start
}

status_daemon()
{
	local daemon_name=$1
	local daemon_pid_file=$2
	local daemon_interval=$3

	if [ ! -f $daemon_pid_file ]; then
		echo "$daemon_name is not running."
	else
		echo "$daemon_name (pid $(cat $daemon_pid_file), interval: $daemon_interval) is running."
	fi
}

status()
{
	status_daemon $FSSTATD $FSSTATD_PID_FILE $FSSTAT_INTERVAL
	status_daemon $PROCD $PROCD_PID_FILE $PROC_INTERVAL
}

# How are we called?
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status
		;;
	restart|reload|force-reload)
		restart
		;;
	*)
		echo "Usage: $DAEMON {start|stop|status|restart|reload}"
		exit 1
esac

exit 0