source: trunk/dsys/initscript@ 9

Last change on this file since 9 was 1, checked in by katerina, 19 years ago

Initial import

File size: 2.5 KB
Line 
1#! /bin/sh
2
3startup=no
4
5# arg1: the --enable-nocl=password password (use 'start' for none)
6# arg2(optional): if 'startup', start the client and exit
7#
8#
9# 'nocl' is used to handle the --enable-nocl=password option. 'start' is a
10# reserved word, hence cannot be the password.
11# We are called with one argument, which may be 'start' to indicate that
12# the --enable-nocl=password option is not used.
13#
14if test "x$1" = x
15then
16 nocl=start
17else
18 nocl="$1"
19fi
20
21if test "x$2" = x
22then
23 command="data"
24else
25 command="$2"
26fi
27
28name=`./samhain-install.sh --print-config name`
29sbin=`./samhain-install.sh --print-config sbin_dir`
30
31# execute and exit for start|stop|restart|reload|status, else fallthrough
32case $command in
33 start | stop)
34 MONIT=""
35 test -f /usr/local/bin/monit && MONIT="/usr/local/bin/monit"
36 if test x"$MONIT" = x
37 then
38 test -f /usr/bin/monit && MONIT="/usr/bin/monit"
39 if test x"$MONIT" = x
40 then
41 :
42 else
43 zz=`/usr/bin/monit status | grep ${name}`
44 if test x"$zz" = x
45 then
46 :
47 else
48 ${MONIT} "${command}" "${name}"
49 exit 0
50 fi
51 fi
52 fi
53
54 retval=0
55
56 if test -f /etc/init.d/${name}
57 then
58 /etc/init.d/${name} ${command}
59 retval=$?
60 elif test -f /etc/rc.d/init.d/${name}
61 then
62 /etc/rc.d/init.d/${name} ${command}
63 retval=$?
64 elif test -f "$sbin/$name"
65 then
66 $sbin/$name ${command}
67 retval=$?
68 else
69 exit 1
70 fi
71 if test x"$command" = xstop
72 then
73 exit 0
74 fi
75 exit $retval
76 ;;
77
78 reload | restart | status )
79 if test -f /etc/init.d/${name}
80 then
81 /etc/init.d/${name} ${command}
82 elif test -f /etc/rc.d/init.d/${name}
83 then
84 /etc/rc.d/init.d/${name} ${command}
85 elif test -f "$sbin/$name"
86 then
87 $sbin/$name ${command}
88 else
89 exit 1
90 fi
91 exit $?
92 ;;
93
94 *)
95 ;;
96esac
97
98data=`./samhain-install.sh --print-config data_file`
99ddir=`./samhain-install.sh --print-config data_dir`
100
101remfile=no
102remdir=no
103
104if test -d "$ddir"
105then
106 test -f "$data" || remfile=yes
107else
108 ./samhain-install.sh --mkinstalldirs "$ddir"
109 remdir=yes
110fi
111
112if test -f "$sbin/$name"
113then
114 if test -f "$data"
115 then
116 rm "$data" || exit 1
117 fi
118
119 if test x"$nocl" = xstart
120 then
121 $sbin/$name -t init -p err
122 else
123 echo '-t init -p err' | $sbin/$name "$nocl"
124 fi
125else
126 echo "$sbin/$name not found" >&2
127 exit 1
128fi
129
130if test -f "$data"
131then
132 cp "$data" ./data
133else
134 echo "$data not found" >&2
135 exit 1
136fi
137
138if test x"$remdir" = xyes
139then
140 rm -rf "$ddir"
141elif test x"$remfile" = xyes
142then
143 rm -f "$data"
144fi
145
146exit 0
147
Note: See TracBrowser for help on using the repository browser.