Operating System - HP-UX
1820483 Members
2457 Online
109624 Solutions
New Discussion юеВ

startup script not working

 
SOLVED
Go to solution
Todd McDaniel_1
Honored Contributor

startup script not working

Hey all.

I have a startup script I attempted to use over the weekend. I made the links to the exe in rc3.d and rc2.d for S and K symlinks. The file is executable...

However, it didnt start up upon a reboot. Must I have the exe in /sbin? b/c of the system reading into memory the startup scripts at boot time before the system has mounted my other filesystems?

Here is what I have... I think I just answered my own question! hehe...

root:/root
#ll /appl/finapps/applmgr/local/bin/run_Xvfb.sh
-rwxr-xr-x 1 applmgr fin 206 Jan 15 13:17 /appl/finapps/applmgr/
local/bin/run_Xvfb.sh

root:/var/adm/sa
# ll /sbin/rc3.d/S888run_Xvfb.sh
lrwx--x--x 1 root sys 43 Jan 15 14:26 /sbin/rc3.d/S888run_Xv
fb.sh -> /appl/finapps/applmgr/local/bin/run_Xvfb.sh

root:/var/adm/sa
# ll /sbin/rc2.d/K888run_Xvfb.sh
lrwx--x--x 1 root sys 43 Jan 15 14:27 /sbin/rc2.d/K888run_Xv
fb.sh -> /appl/finapps/applmgr/local/bin/run_Xvfb.sh


I am guessing I need to do:

mv /appl/finapps/applmgr/local/bin/run_Xvfb.sh /sbin/init.d/run_Xvfb.sh

And relink my S and K scripts...

PS. I went ahead and posted this for anyone else who may be wondering how to do this...

I had to talk this out to get it right. I just haven't had to do this in a long while, so my brain is in recovery mode!
Unix, the other white meat.
14 REPLIES 14
Pete Randall
Outstanding Contributor

Re: startup script not working

Todd,

Give yourself a bunny - you've got it!!


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: startup script not working

It's possible that the filesystems were not mounted but I suspect that the real problem is that the arguments "stop", "start", "start_msg", and "stop_msg" supplied by rc were not understood by your script. It's really important to follow the proper conventions. Both your S and K scripts should be soft-linked to the same file in /sbin/init.d and that file should process the arguments and take the appropriate actions.
If it ain't broke, I can fix that.
Todd McDaniel_1
Honored Contributor

Re: startup script not working

I dont have any start/stop functionality in the script. I merely linked it to the rc* directories. The script belongs to one of my DBAs.

I will have my DBA modify his script...for stop/start input.
Unix, the other white meat.
A. Clay Stephenson
Acclaimed Contributor

Re: startup script not working

The other "gotcha" is not properly setting up the environment. Scripts that run fine in an interactive environemtn may not work under rc. It's very important that all needed variables be set and exported and also avoid any interactive commands.

A very typical problem occurs with
su - oracle ... commands
instead of su oracle ... command. The "-" causes su to execute oracle's .profile which contains commands like tput, stty, tabs, ... that will probably hang when not attached to a terminal.
If it ain't broke, I can fix that.
Jeff Schussele
Honored Contributor
Solution

Re: startup script not working

Hi Todd,

Don't forget to setup a config file to easily toggle auto-start on/off

Create a file in /etc/rc.config.d & name it Xvfbconf
In it place
XVFB_START=1 #for auto-start
XVFB_START_COMMAND="/appl/finapps/applmgr/local/bin/run_Xvfb.sh"



Then place logic in the /sbin/init.d/run_Xvfb.sh file
like the following examples:

if [ -f /etc/rc.config.d/Xvfbconf ]
then . /etc/rc.config.d/Xvfbconf
else echo "ERROR /etc/rc.config.d/Xvfbconf file MISSING"
fi

In the 'start') section add the following to check the conf value & check whether the start script is executable:

if ["$XVFB_START != 1 ]
then rval=2
else
if [-x /appl/finapps/applmgr/local/bin/run_Xvfb.sh ]
then
if [ "$XVFB_START_COMMAND != "" ]
then eval $XVFB_START_COMMAND
else /appl/finapps/applmgr/local/bin/run_Xvfb.sh
fi
fi
fi

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Jeff Schussele
Honored Contributor

Re: startup script not working

Hmmmm - both those snippets should be under the start section - not just the last one.

Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Jeff Schussele
Honored Contributor

Re: startup script not working

Hi (again) Todd,

I just saw your post RE not having atrt/stop/start_msg/stop_msg sections & I *highly* recommend you do add these.

Have whomever's writing it just use /sbin/init.d/template as the actual template & just fill in what you need & save it with appropriate filename.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Todd McDaniel_1
Honored Contributor

Re: startup script not working

Jeff my actual path is /sbin/init.d/run_Xvfb.sh now...

I am editing it now.


My question is about the start section... I have this so far...

# cat /sbin/init.d/run_Xvfb.sh
#!/bin/ksh

# setup virtual x server for Oracle ERP 11i graphical display


# Read /etc/rc.config.d/Xvfbconf for start toggle upon boot time.
# XVFB_START=1 is for start... XVFB_START=0 is for dont start

if [ -f /etc/rc.config.d/Xvfbconf ]
then . /etc/rc.config.d/Xvfbconf
else echo "ERROR /etc/rc.config.d/Xvfbconf file MISSING"
fi

PATH=/usr/sbin:/usr/bin:/sbin; export PATH
mode=$1
case "$mode" in
'start_msg')
echo "Start Xvfb"
exit 0
;;

'stop_msg')
echo "Stop Xvfb"
exit 0
;;

'start')
if ["$XVFB_START != 1 ]
then rval=2
else
if [-x /sbin/init.d/run_Xvfb.sh ]
then
if [ "$XVFB_START_COMMAND != "" ]
then eval $XVFB_START_COMMAND
else /sbin/init.d/run_Xvfb.sh
fi
fi
fi

nohup /usr/bin/X11/Xvfb :4 -screen 0 1024x800x8 -pn -fp /usr/lib/X11/fon
ts/misc -sp /etc/X11/SecurityPolicy &
;;

'stop')
PIDS=`ps -aef |grep -v grep|grep Xvfb |awk '{ print $2 }'`
kill $PIDS
;;
*)
echo "Usage: \$0 { start | stop }"
exit 1
;;
esac
exit 0
Where do I put my command line in there? is it fine at the end of the start section? or is that bad coding?
Unix, the other white meat.
Todd McDaniel_1
Honored Contributor

Re: startup script not working

I copied it to my workstation so i can test it there!!
Unix, the other white meat.
Todd McDaniel_1
Honored Contributor

Re: startup script not working

Gonna refer to the template... I have an error around the fi fi fi area... "fi" unexpected error.

Thanks for everyone's help!
Unix, the other white meat.
Jeff Schussele
Honored Contributor

Re: startup script not working

Hi Todd,

Actual startup command follows the final else in that script. I guess I didn't understand what your actual startup command was - it wasn't in the org post. So change the conf file as well as all calls to the actual startup command to your actual startup
I also noticed a missing double quote in the test for whether the start command is null - the var needs an ending double quote. The double double-quote is the actual null.
The template does not have this error & they keep the fi with each if-then section - I just put them all at the end & I also test to make sure the startup is executable whereas the template does not.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Todd McDaniel_1
Honored Contributor

Re: startup script not working

Jeff: Let me say I got the script to work with the template portion for the start section... but I wanted to get your script working as well...

Okay I got it except for one small error.

On line 34 where the test for the var is:

if ["$XVFB_START" != 1 ]



I get a [1: not found error


---------------------------------------------------
# cat run_Xvfb.sh
# setup virtual x server for Oracle ERP 11i graphical display
# Steve Wang 1/12/04
#### OLD LINE EDITED
#nohup /usr/bin/X11/Xvfb :4 -screen 0 1024x800x8 -pn -fp /usr/lib/X11/fonts/misc
-sp /etc/X11/SecurityPolicy &
# Read /etc/rc.config.d/Xvfbconf for start toggle upon boot time.
# XVFB_START=1 is for start... XVFB_START=0 is for dont start
if [ -f /etc/rc.config.d/Xvfbconf ]
then . /etc/rc.config.d/Xvfbconf
else echo "ERROR /etc/rc.config.d/Xvfbconf file MISSING"
fi
####
## New script changed 01-20-2004 Todd McDaniel...
PATH=/usr/sbin:/usr/bin:/sbin; export PATH
mode=$1
case "$mode" in
"start_msg")
echo "Start Xvfb"
exit 0
;;

"stop_msg")
echo "Stop Xvfb"
exit 0
;;
"start")
if ["$XVFB_START" != 1 ]
then rval=2
else
if [ -x/sbin/init.d/run_Xvfb.sh ]
then
if [ "$XVFB_START_COMMAND" != "" ]
then eval $XVFB_START_COMMAND
else /sbin/init.d/run_Xvfb.sh
nohup /usr/bin/X11/Xvfb :4 -screen 0 1024x800x8 -pn -fp /usr/lib/X11/fon
ts/misc -sp /etc/X11/SecurityPolicy &
fi
fi
fi

;;
"stop")
PIDS=`ps -aef |grep -v grep|grep Xvfb |awk '{ print $2 }'`
kill $PIDS
;;
*)
echo "Usage: \$0 { start | stop }"
exit 1
;;
esac
exit 0
Unix, the other white meat.
Jeff Schussele
Honored Contributor

Re: startup script not working

Hi Todd,

Don'r worry about mine - it works.
That wasn't a copy/paste - I typed it freehand - hence the typos.
Glad to hear you got yours going now.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Elmar P. Kolkman
Honored Contributor

Re: startup script not working

Tod, what you miss is a space between the square bracket ('[') and the double quote ('"') making it one string instead of the command '['.
Every problem has at least one solution. Only some solutions are harder to find.