1752815 Members
6287 Online
108789 Solutions
New Discussion юеВ

Re: Script on startup

 
SOLVED
Go to solution
Jean Samarani
Frequent Advisor

Script on startup

Hi Guys,

I have the below scripts that I would like to run on start up on hp-ux 11i v2 but the routes are not being added automatically.

#!/sbin/sh
/usr/sbin/route add net 10.1.136.0 netmask 255.255.255.0 10.1.156.36 1
/usr/sbin/route add net 10.1.16.0 netmask 255.255.255.0 10.1.156.36 1

I have added the script under /sbin/rc3.d/
and the permission are 744.

my runlevel is 3 :


#who -r
. run-level 3 Jan 23 20:34 3 0 S

Can anyone advise what could be the issue ?

thanks a lot for your usual support.

Jean
6 REPLIES 6
Dennis Handly
Acclaimed Contributor

Re: Script on startup

>I have added the script under /sbin/rc3.d/

What is the name of the script?
All rc(1m) scripts should be under /sbin/init.d/. Then you should symlink them under the appropriate run level:
ln -s /sbin/rc3.d/nice-name /sbin/rc3.d/S###nice-name

$ ll /sbin/rc3.d/
S100nfs.server@ -> /sbin/init.d/nfs.server

Anything in /etc/rc.log?
Jose Mosquera
Honored Contributor
Solution

Re: Script on startup

Hi,

Have you tested them manually (from prompt) to ensure that are reachable?

After this you must create in /sbin/init.d a file with the following content:
#!/sbin/sh

RVAL=0
case $1 in
start_msg)
echo "Adding extra routes"
;;
'start')
/usr/sbin/route add net 10.1.136.0 netmask 255.255.255.0 10.1.156.36 1
/usr/sbin/route add net 10.1.16.0 netmask 255.255.255.0 10.1.156.36 1
;;
'stop')
/usr/sbin/route delete net 10.1.136.0 netmask 255.255.255.0 10.1.156.36
/usr/sbin/route delete net 10.1.16.0 netmask 255.255.255.0 10.1.156.36
;;
*)
echo "usage: $0 {start|stop}"
RVAL=1
;;
esac
exit $RVAL


And finally, from /sbin/rc3.d you must create a symbolic link name with "S" prefix that aims to /sbin/init.d/ to start procedure, then in /sbin/rc0.d you must create a similar symbolic link with "K" prefix to stop procedure, this is optional because when the server go down this route definitions will be off.

Rgds.
Pete Randall
Outstanding Contributor

Re: Script on startup

All you're doing is adding routes. Why have a separate script? Add them into /etc/rc.config.d/netconf.


Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: Script on startup

Hi Jean:

You might want to review the 'rc(1M)' manpages which document the requirements for start/kill scripts.

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: Script on startup

All start/stop scripts must honor 4 parameters, not just 2: start stop start_msg stop_msg

If you do not provide the start_msg and stop_msg, then your system shutdown screen will be filled up with dots .............

However, using an rc (start/stop) script is definitely the wrong way to set a permanent route. As mentioned before, you edit the netconf file in /etc/rc.config.d to add routes.


Bill Hassell, sysadmin
Jean Samarani
Frequent Advisor

Re: Script on startup

The netconf file approach to add routes for subnets didn't work that's why I have used the script to add them .