LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-01-2006, 11:07 AM   #1
bitpail
LQ Newbie
 
Registered: Oct 2006
Distribution: Fedora 6/SUSE 10
Posts: 20

Rep: Reputation: 0
Problem with Service script.


I have installed fail2ban recently and I want to run it as a service on my FC5 server so that when I reboot, it starts again. There is a init.d file that is provided by the product however it doesn't seem to work. This is what I get:

service fail2ban start
env: /etc/init.d/fail2ban: No such file or directory

even though:

ls -l | grep fail2ban
-rwxr-xr-x 1 root root 1335 Oct 31 16:54 fail2ban

I can start the program fine on the command line by using just

fail2ban

however this doesn't work with the service. Here is the script that was provided by the software package.
---------------------------------------------------------------

#!/bin/bash
#
# fail2ban
#
# chkconfig: 345 91 9
# description: if many unsuccessfull login attempts from some ip address \
# during a short period happen, this address is banned \
# by the firewall
#
# Author: Andrey G. Grozin
#
# $Revision: 1.2 $

# Source function library.
. /etc/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0
[ -f /etc/fail2ban.conf ] || exit 0

FAIL2BAN="/usr/bin/fail2ban"
PIDFILE="/var/run/fail2ban.pid"

RETVAL=0

start() {
echo -n $"Starting fail2ban: "
"${FAIL2BAN}" -b > /dev/null
RETVAL=$?
echo
}

stop() {
if [ -f "${PIDFILE}" ]; then
echo -n $"Stopping fail2ban: "
"${FAIL2BAN}" -k > /dev/null
echo
fi
}

restart() {
stop
start
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status fail2ban
RETVAL=$?
;;
reload)
restart
;;
restart)
restart
;;
condrestart)
if [ -f "${PIDFILE}" ]; then
restart
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
exit 1
;;
esac

exit $RETVAL

------------------------------------------------------------

Does anyone have any ideas? I really need this to start on boot.
 
Old 11-01-2006, 12:14 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,938

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Here is a quick intro to init scripts. http://www.netadmintools.com/art94.html

What happends when you add the service via chkconfig -add is that a link is created in the rcx.d directory to start / stop the service during boot. The x corresponds to the runlevel. The link will have a name in this case of s91fail2ban. The s means start and 91 is the order of how the daemons start. 1 being it starts first and 99 last. Since you have not added the daemon yet the service command fails.
 
Old 11-01-2006, 12:59 PM   #3
bitpail
LQ Newbie
 
Registered: Oct 2006
Distribution: Fedora 6/SUSE 10
Posts: 20

Original Poster
Rep: Reputation: 0
Opps, I forgot to add that I did do the following

chkconfig fail2ban --add
chkconfig fail2ban on

Here's a list showing that there are files there:

# for i in 1 2 3 4 5 6
> do
> ls rc$i.d/*fail2ban*
> done
rc1.d/K09fail2ban
rc2.d/S91fail2ban
rc3.d/S91fail2ban
rc4.d/S91fail2ban
rc5.d/S91fail2ban
rc6.d/K09fail2ban

I still experience the same problem. Any ideas?
 
Old 11-01-2006, 02:43 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,938

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Is it listed in the output of chkconfig --lsit?
 
Old 11-01-2006, 02:50 PM   #5
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 542

Rep: Reputation: 33
Good luck figuring out why it won't start after reboot. Looks like you've covered all the bases I would think of.

Is there anything in your boot log or messages log showing a problem with starting it?

Like Michaelk said be sure it is listed when you do a chkconfig --list

Let us know if you get it going. Sounds like an addon that I could use.
 
Old 11-01-2006, 04:22 PM   #6
bitpail
LQ Newbie
 
Registered: Oct 2006
Distribution: Fedora 6/SUSE 10
Posts: 20

Original Poster
Rep: Reputation: 0
Here's the output from chkconfig --list

# chkconfig --list | grep fail2ban
fail2ban 0ff 1ff 2n 3n 4n 5n 6ff


By the way those are colons followed by o's, not intended to be face icons

Last edited by bitpail; 11-01-2006 at 04:26 PM.
 
Old 11-01-2006, 06:00 PM   #7
bitpail
LQ Newbie
 
Registered: Oct 2006
Distribution: Fedora 6/SUSE 10
Posts: 20

Original Poster
Rep: Reputation: 0
Got It

Arggghhh!

Wow, this was a dumb mistake. The end-of-line characters were windows for some reason! I used dos2unix on the /etc/init.d/fail2ban. I can't believe it took me that long to figure it out....oh well. Thanks for your help guys! The actual program works fairly well.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
turn a script to a service gsr_kashyap Linux - Software 1 04-05-2006 03:31 AM
Service check script assafde Linux - Networking 1 02-02-2006 07:46 PM
Service check script MPowers Linux - Networking 1 01-24-2006 01:42 AM
Starting a service in a bash script AMMullan Programming 3 02-19-2004 12:06 PM
script to check if the service is running eyt Linux - Newbie 2 02-16-2004 08:27 AM


All times are GMT -5. The time now is 10:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration