LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   add script to boot centos (https://www.linuxquestions.org/questions/linux-newbie-8/add-script-to-boot-centos-829283/)

nibau 08-30-2010 05:40 AM

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

vinaytp 08-30-2010 05:56 AM

Just add it using chkconfig

Code:

/sbin/chkconfig -add <yourscriptname>
Make it to start on boot
Code:

/sbin/chkconfig --levels 3,5 <yourscriptname> on

nibau 08-30-2010 06:17 AM

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

vinaytp 08-30-2010 06:21 AM

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.

nibau 08-30-2010 06:26 AM

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...

bathory 08-30-2010 06:26 AM

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

nibau 08-30-2010 06:27 AM

i'll add that line thank u very much

nibau 08-30-2010 06:33 AM

hi
yes you're right, while copy pasting i missed the cardinal!lol
thank u

nibau 08-30-2010 06:53 AM

I think I got it working!
thank you both!!


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