-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.d.HP-UX
146 lines (116 loc) · 3.32 KB
/
init.d.HP-UX
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
:
################################################################################
#
# Program: syslog-ng init script
#
# Description:
#
# This is an init script for syslog-ng on the HP-UX platform.
#
# To start the service, we check if the daemon program is executable.
# Accordingly, the preferred way to disable the service PERMANENTLY
# is to rename the binary or remove execute permissions.
# Ideally, you would remove the software from your system entirely.
#
# The lowest PID of a running instance of the executable is logged to a
# file. This PID is used for killing the daemon. This is a best guess of
# course, it is much better to use built-in shutdown functions if the
# daemon has those.
#
#
# Platforms (tested): HP-UX (B.10.20)
#
#
# Author: Gregor Binder <[email protected]>
#
# Last Changed: October 10, 2000
#
# Copyright (c) 2000 by sysfive.com GmbH, All rights reserved.
#
################################################################################
################################################################################
# configuration
#
INIT_PROG="/path_to/syslog-ng" # FULL path to daemon required for fuser
INIT_OPTS="" # options passed to daemon
INIT_HOOK="1" # in case you want to use /etc/rc.config.d
# comment this out and edit code below
INIT_RDIR="/var/run"
PATH=/bin:/sbin:/usr/bin:/usr/sbin
INIT_NAME=`basename "$INIT_PROG"`
INIT_RPID="${INIT_RDIR}/${INIT_NAME}.pid"
################################################################################
# init
#
INIT_RETURN=0
umask 077
# Error Handling the HP way
#
set_return () {
x=$?
if [ $x -ne 0 ]; then
echo "EXIT CODE: $x"
INIT_RETURN=1 # always 1 so that 2 can be used for other reasons
fi
}
case "$1" in
'start_msg')
echo "Start $INIT_NAME"
;;
'stop_msg')
echo "Stopping $INIT_NAME"
;;
'start')
# Remove comments to enable reading config files
#
# if [ -f /etc/rc.config ] ; then
# . /etc/rc.config
# else
# echo "ERROR: /etc/rc.config defaults file MISSING"
# fi
if [ "$INIT_HOOK" -eq 1 -a -x $INIT_PROG ] ; then
$INIT_PROG $INIT_OPTS && echo "$INIT_NAME"
set_return
else
INIT_RETURN=2
fi
;;
'stop')
# Remove comments to enable reading config files
#
# if [ -f /etc/rc.config ] ; then
# . /etc/rc.config
# else
# echo "ERROR: /etc/rc.config defaults file MISSING"
# fi
# Determine PID of process(es) to stop
#
if [ "$INIT_HOOK" -ne 1 ] ; then
INIT_RETURN=2
else
[ -r "$INIT_RPID" ] && {
INIT_CPID=`cat "$INIT_RPID"`
INIT_CPRG="`ps -ef | awk '$2 == '"$INIT_CPID"' { print $9 }'`"
set_return
[ "${INIT_CPRG:="unknown"}" = "$INIT_PROG" ] || {
echo "process ID mismatch: [$INIT_CPID] is $INIT_CPRG"
INIT_RETURN=1
}
[ $INIT_RETURN -eq 0 ] && kill "$INIT_CPID"
set_return
[ $INIT_RETURN -eq 0 ] && rm -f "$INIT_RPID"
set_return
if [ $INIT_RETURN -eq 0 ]; then
echo "$INIT_NAME stopped"
else
echo "Unable to stop $INIT_NAME"
fi
}
fi
;;
*)
echo "usage: $0 {start|stop}"
INIT_RETURN=1
;;
esac
exit $INIT_RETURN