LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 08-30-2010, 06:40 AM   #1
nibau
LQ Newbie
 
Registered: Aug 2010
Location: Portugal
Distribution: CentOS, Fedora
Posts: 19

Rep: Reputation: 0
add script to boot centos


hi there!

newbie question again:

how can i add a script to boot? I've created a script for my firewall definitions and I've already placed it in /etc/init.d.
Now what?

thank u very much
 
Old 08-30-2010, 06:56 AM   #2
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
Just add it using chkconfig

Code:
/sbin/chkconfig -add <yourscriptname>
Make it to start on boot
Code:
/sbin/chkconfig --levels 3,5 <yourscriptname> on
 
1 members found this post helpful.
Old 08-30-2010, 07:17 AM   #3
nibau
LQ Newbie
 
Registered: Aug 2010
Location: Portugal
Distribution: CentOS, Fedora
Posts: 19

Original Poster
Rep: Reputation: 0
thank u!

but i think my script may not support something...check this out:

Code:
[root@vas ~]# /sbin/chkconfig -add firewall
-add: unknown option
[root@vas ~]# /sbin/chkconfig --add firewall
service firewall does not support chkconfig
it doesn't support chkconfig? what does that mean?

thx
 
Old 08-30-2010, 07:21 AM   #4
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
How does your firewall script starts with ?

Lets take a sample init.d script mysqld, Here are starting few lines of it.

Code:
#!/bin/bash
#
# mysqld        This shell script takes care of starting and stopping
#               the MySQL subsystem (mysqld).
#
# chkconfig: - 64 36
# description:  MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile: /var/run/mysqld/mysqld.pid
If you can observe the line which starts with chkconfig tells the priority of the script to start ( 64 ) and Priority of the script to stop ( 36 ).

Hope you are missing out this line. Please add above lines to your script.

Do change the priority values.
 
1 members found this post helpful.
Old 08-30-2010, 07:26 AM   #5
nibau
LQ Newbie
 
Registered: Aug 2010
Location: Portugal
Distribution: CentOS, Fedora
Posts: 19

Original Poster
Rep: Reputation: 0
my script doesn't have that line in fact....
Code:
!/bin/sh

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

IPTABLES=/sbin/iptables

start() {
	#definicao de regras de firewall

        $IPTABLES -F


        #INPUT
	$IPTABLES -P INPUT DROP
etc...
 
Old 08-30-2010, 07:26 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,596

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
You can add an entry in /etc/rc.local, like:
Code:
/etc/init.d/myscript.sh
Cheers

### EDIT ###
The script must start with the shebang
Quote:
#!/bin/sh

Last edited by bathory; 08-30-2010 at 07:28 AM.
 
1 members found this post helpful.
Old 08-30-2010, 07:27 AM   #7
nibau
LQ Newbie
 
Registered: Aug 2010
Location: Portugal
Distribution: CentOS, Fedora
Posts: 19

Original Poster
Rep: Reputation: 0
i'll add that line thank u very much
 
Old 08-30-2010, 07:33 AM   #8
nibau
LQ Newbie
 
Registered: Aug 2010
Location: Portugal
Distribution: CentOS, Fedora
Posts: 19

Original Poster
Rep: Reputation: 0
hi
yes you're right, while copy pasting i missed the cardinal!lol
thank u
 
Old 08-30-2010, 07:53 AM   #9
nibau
LQ Newbie
 
Registered: Aug 2010
Location: Portugal
Distribution: CentOS, Fedora
Posts: 19

Original Poster
Rep: Reputation: 0
I think I got it working!
thank you both!!
 
  


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
I can't add new users CentOS Treikayan Linux - Newbie 4 11-22-2008 07:20 PM
need to dual boot centos 5.1 with xp but centos is already installed. extendedping Linux - Software 4 05-13-2008 09:40 PM
CentOs - how to Add different Mirror ? marshalx Linux - Newbie 2 01-03-2008 04:08 AM
How to add script to boot process NetAX Linux - General 7 07-29-2004 04:52 PM
how do I add script to set default gateway on boot for eth1 abg Linux - Networking 3 10-01-2003 06:22 PM


All times are GMT -5. The time now is 07:09 PM.

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