HTDIG ::: A Fedora & centos service shell script for /etc/init.d/ so that a user can start and stop htdig as a service
mark ---- <[email protected]> Thu, 24 Feb 2011 16:56:09 +0000
| Newsgroups | gmane.comp.web.htdig.general |
|---|---|
| Message-ID | <[email protected]> |
--===============3584494613061999035==
Content-Type: multipart/alternative;
boundary="_2b6ae49a-34d7-4a31-8d42-6db894841b66_"
--_2b6ae49a-34d7-4a31-8d42-6db894841b66_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi=20
This is a shell script I wrote to start and stop htdig when it is running o=
n a fedora or Centos or redhat=20
linux machine.
This was not an easy script to write htdig is a very noisy program to kill =
from a bash script which made
it very difficult to kill . Which made it very difficult to get to work wit=
h the Fedora service script system.
The issue solved were kill -9 pid returning "Killed" or "terminated". Yo=
u can not trap a SIGINT signal=20
ie -9 where as you can trap a SIGTERM signal from pkill
Please include this script in future releases of htdig and install it into=
/etc/init.d from the make install
process.
Best wishes=20
Mark Adam Tkac <atkac@redhat com>
Here is the script=20
#!/bin/sh=20
#
# htdig: 345 81 35
# description: Starts and stops the htdig search engine
# Source function library.
. /etc/rc.d/init.d/functions ### This library is called from=20
# See how we were called.
case "$1" in
start)
echo -n "Starting htdig search engine : "
rundig=3D$(pgrep rundig) # find all the process
if [ -z "$rundig" ] # check that another instants of rundig is not runni=
ng before=20
then # before running rundig
rundig& # rundig as a background task.
fi
=09
echo "OK"
=3B=3B
=09
stop)
echo -n "Stopping htdig search engine : "
# Notes
# =3D=3D=3D=3D=3D=20
# this checks to see is there is a pid process number for the process say =
"rundig"
# if there is a process it kills it off
# send annoying "killed" or "terminated messages to junk bin { comand } 2=
>/dev/null
# then the final
=09
rundig=3D$(pgrep rundig) # find all the process=20
htdig=3D$(pgrep htdig)
htmerge=3D$(pgrep htmerge)
htnotify=3D$(pgrep htnotify)
htfuzzy=3D$(pgrep htfuzzy)
=09
=09
# check the process has a PID job number and if it does kill it quitely
=09
if [ "$rundig" ] =3Bthen trap " $(pkill rundig | 2>/dev/null )" SIGTERM =
=3Bfi
if [ "$htdig" ]=3B then trap " $(pkill htdig | 2>/dev/null )" SIGTERM =3Bf=
i
if [ "$htmerge" ]=3B then trap " $(pkill htmerge | 2>/dev/null )" SIGTERM =
=3Bfi
if [ "$htnotify" ]=3B then trap " $(pkill htnotify | 2>/dev/null)" SIGTERM=
=3Bfi
if [ "$htfuzzy" ]=3B then trap " $(pkill htfuzzy | 2>/dev/null)" SIGTERM =
=3Bfi
=09
echo "OK"
=3B=3B
=20
#status)
# echo ""
#=3B=3B
restart)
echo -n "Restarting htdig search engine : "
echo " "
echo -n "Stopping htdig search engine : "
rundig=3D$(pgrep rundig) # find all the process=20
htdig=3D$(pgrep htdig)
htmerge=3D$(pgrep htmerge)
htnotify=3D$(pgrep htnotify)
htfuzzy=3D$(pgrep htfuzzy)
# check the process has a PID job number and if it does kill it quitely
if [ "$rundig" ] =3Bthen trap " $(pkill rundig | 2>/dev/null )" SIGTERM =
=3Bfi
if [ "$htdig" ]=3B then trap " $(pkill htdig | 2>/dev/null )" SIGTERM =3Bf=
i
if [ "$htmerge" ]=3B then trap " $(pkill htmerge | 2>/dev/null )" SIGTERM =
=3Bfi
if [ "$htnotify" ]=3B then trap " $(pkill htnotify | 2>/dev/null)" SIGTERM=
=3Bfi
if [ "$htfuzzy" ]=3B then trap " $(pkill htfuzzy | 2>/dev/null)" SIGTERM =
=3Bfi
echo "OK"
echo -n "Starting htdig search engine : "
rundig&
echo "OK"
echo -n " Restart complete done."
=3B=3B
*)
echo "Usage: htdig search engine {start|stop|restart}"
exit 1
esac
=
--_2b6ae49a-34d7-4a31-8d42-6db894841b66_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<style><!--
.hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 10pt=3B
font-family:Tahoma
}
--></style>
</head>
<body class=3D'hmmessage'>
Hi =3B<BR><br><BR>This is a shell script I wrote to start and stop htdi=
g when it is running on a fedora or Centos or redhat =3B<BR>linux machi=
ne.<BR><br><BR>This was not an easy script to write htdig is a very noisy p=
rogram to kill from a bash script which made<BR>it very difficult to kill .=
Which made it very difficult to get to work with the Fedora service script=
system.<BR><br><BR>The issue solved were kill -9 pid  =3B returning "K=
illed" or "terminated".  =3BYou can not trap a SIGINT signal =3B<BR=
>ie -9 where as you can trap a SIGTERM signal from pkill<BR><br><BR>Please =
include this script in future releases of  =3Bhtdig and install it into=
/etc/init.d from the make  =3Binstall<BR>process.<BR><br><BR>Best wish=
es =3B<BR><br><BR>Mark  =3BAdam Tkac <=3Batkac@redhat com>=3B<B=
R><br><BR><br><BR>Here is the script =3B<BR><br><BR>#!/bin/sh <br>#<br>=
# htdig: 345 81 35<br># description: Starts and stops the htdig search engi=
ne<br><br># Source function library.<br>. /etc/rc.d/init.d/functions  =
=3B ### This library is called from =3B<br><br># See how we were called=
.<br>case "$1" in<br> start)<br> echo -n "Starting htdig search engine : =
"<br> rundig=3D$(pgrep rundig) # find all the process<br> if [ -z "$rundig=
" ] # check that another instants of rundig is not running before <br> th=
en # before running rundig<br> rundig&=3B # rundig as a background =
task.<br> fi<br> <br> echo "OK"<br> =3B=3B<br> <br> stop)<br> echo -n "Sto=
pping htdig search engine : "<br><br> # Notes<br> # =3D=3D=3D=3D=3D <br> # =
this checks to see is there is a pid process number for the process say "ru=
ndig"<br> # if there is a process it kills it off<br> # send annoying "kill=
ed" or "terminated messages to junk bin { comand } 2>=3B/dev/null<br> # =
then the final<br> <br> rundig=3D$(pgrep rundig) # find all the process <b=
r> htdig=3D$(pgrep htdig)<br> htmerge=3D$(pgrep htmerge)<br> htnotify=3D$(p=
grep htnotify)<br> htfuzzy=3D$(pgrep htfuzzy)<br> <br> <br> # check the pro=
cess has a PID job number and if it does kill it quitely<br> <br> if [ "$ru=
ndig" ] =3Bthen trap " $(pkill rundig | 2>=3B/dev/null )" SIGTERM =3Bfi<b=
r> if [ "$htdig" ]=3B then trap " $(pkill htdig | 2>=3B/dev/null )" SIGTE=
RM =3Bfi<br> if [ "$htmerge" ]=3B then trap " $(pkill htmerge | 2>=3B/dev=
/null )" SIGTERM =3Bfi<br> if [ "$htnotify" ]=3B then trap " $(pkill htnoti=
fy | 2>=3B/dev/null)" SIGTERM =3Bfi<br> if [ "$htfuzzy" ]=3B then trap " =
$(pkill htfuzzy | 2>=3B/dev/null)" SIGTERM =3Bfi<br> <br><br> echo "OK"<b=
r> =3B=3B<br> <br> #status)<br> # echo ""<br> #=3B=3B<br> restart)<br>=
echo -n "Restarting htdig search engine : "<br> echo " "<br> echo -n "Sto=
pping htdig search engine : "<br> rundig=3D$(pgrep rundig) # find all the =
process <br> htdig=3D$(pgrep htdig)<br> htmerge=3D$(pgrep htmerge)<br> htno=
tify=3D$(pgrep htnotify)<br> htfuzzy=3D$(pgrep htfuzzy)<br> # check the pro=
cess has a PID job number and if it does kill it quitely<br> if [ "$rundig"=
] =3Bthen trap " $(pkill rundig | 2>=3B/dev/null )" SIGTERM =3Bfi<br> if=
[ "$htdig" ]=3B then trap " $(pkill htdig | 2>=3B/dev/null )" SIGTERM =
=3Bfi<br> if [ "$htmerge" ]=3B then trap " $(pkill htmerge | 2>=3B/dev/nu=
ll )" SIGTERM =3Bfi<br> if [ "$htnotify" ]=3B then trap " $(pkill htnotify =
| 2>=3B/dev/null)" SIGTERM =3Bfi<br> if [ "$htfuzzy" ]=3B then trap " $(p=
kill htfuzzy | 2>=3B/dev/null)" SIGTERM =3Bfi<br> echo "OK"<br> echo -n "=
Starting htdig search engine : "<br> rundig&=3B<br> echo "OK"<br><br><b=
r> echo -n " Restart complete done."<br> =3B=3B<br> *)<br> echo "Usage: ht=
dig search engine {start|stop|restart}"<br> exit 1<br>esac<br><br><br><BR> =
</body>
</html>=
--_2b6ae49a-34d7-4a31-8d42-6db894841b66_--
--===============3584494613061999035==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
--===============3584494613061999035==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ht://Dig general mailing list: <[email protected]>
ht://Dig FAQ: http://htdig.sourceforge.net/FAQ.html
List information (subscribe/unsubscribe, etc.)
https://lists.sourceforge.net/lists/listinfo/htdig-general
--===============3584494613061999035==--