LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-20-2007, 10:07 AM   #1
nass
Member
 
Registered: Apr 2006
Location: Athens, Greece
Distribution: slackware, debian, ubuntu
Posts: 666

Rep: Reputation: 39
a start up script in rc.M stops the following scripts from running


hello everyone,
please have a look at this loading script; it is a redhat intended startup script for the agent of my APC UPS unit. since im running slackware though, i had to make it work for this distro

im running the script from rc.M in a standard way
Quote:
# Start APC UPS Agent.
if [ -x /etc/rc.d/rc.PBEAgent ]; then
. /etc/rc.d/rc.PBEAgent start
fi
and of course its in 755 chmod..

it starts up fine and i get status about the ups to thats ok...
problem is this:

any scripts i start from rc.M that come AFTER the rc.PBEAgent, do not start!! so proftpd and gpm wouldnt start... i moved the PBEAgent to the very bottom of rc.M file and proftpd and gpm work again... weird... so im thinking there might be something weird in the PBEAgent script. could you please have a look at the 'start' section?... here it is:

Quote:
#!/bin/sh
case "$1" in
start)
runlevel | grep 1 > /dev/null
if [ $? = 0 ]
then
echo Can not start in runlevel 1.
exit 1
fi
ps `cat /etc/pbeagent.pid 2>/dev/null | awk "{ print "'$1'" }"` | grep Dpicard.main.thread > /dev/null
if [ $? = 0 -a -e /etc/pbeagent.pid ]
then
echo Process Already Started. Cannot start twice.
else
cd /opt/APC/PowerChuteBusinessEdition/Agent
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/APC/PowerChuteBusinessEdition/Agent/lib/linux
/bin/java/jre/1.4.2_11/bin/java -Dpicard.main.thread=blocking -classpath ./lib/AdvSnmp.jar:./lib/application.jar:./lib/jsdk.jar:./lib/comm.jar:./lib/mail.jar:./lib/RXTXComm.jar:./lib/activation.jar:./lib/util.jar:./lib/m11.jar:./lib/ds.jar:./lib/sss.jar:./lib/pcbe_ds.jar:./comp/AliCommunication.jar:./comp/CommandFileRunner.jar:./comp/DataLogger.jar:./comp/DiscoveryListener.jar:./comp/EventLogger.jar:./comp/EventTracker.jar:./comp/Host.jar:./comp/http.jar:./comp/picard.jar:./comp/PowerSource.jar:./comp/QueryServer.jar:./comp/Security.jar:./comp/ShutdownBehavior.jar:./comp/Shutdowner.jar:./comp/SimpleBroadcaster.jar:./comp/SMTPMailer.jar:./comp/UPSManagerAutoUpdate.jar:./comp/shutdownerlets/OSShutdownerlet.jar:./comp/shutdownerlets/ExchangeShutdownerlet.jar:./comp/shutdownerlets/IISShutdownerlet.jar:./comp/shutdownerlets/NotesShutdownerlet.jar:./comp/shutdownerlets/SQLShutdownerlet.jar:./comp/shutdownerlets/SiebelShutdownerlet.jar:./Resources/Japanese.jar com.apcc.m11.application.PicardApplication @critical.cfg 2>/dev/null 1>/dev/null &
echo "APC UPS Agent started"
echo $! >/etc/pbeagent.pid
touch /var/lock/subsys/PBEAgent 1>/dev/null 2>/dev/null
exit $?
fi
;;
stop)
PID=`cat /etc/pbeagent.pid 2>/dev/null | awk "{ print "'$1'" }"`
kill $PID 1>/dev/null 2>/dev/null
rm -f /etc/pbeagent.pid 1>/dev/null 2>/dev/null
rm -f /var/lock/subsys/PBEAgent 1>/dev/null 2>/dev/null
exit $?
;;
status)
ps `cat /etc/pbeagent.pid 2>/dev/null | awk "{ print "'$1'" }"` | grep Dpicard.main.thread > /dev/null
if [ $? = 0 -a -e /etc/pbeagent.pid ]
then
echo Running
else
echo Stopped
fi
;;
*)
echo "Usage $0 {start|stop|status}"
exit 1
;;
esac
thank you for your help
nass
 
Old 05-20-2007, 10:36 AM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
Code:
. /etc/rc.d/rc.PBEAgent start
remove the "."
 
Old 05-20-2007, 10:51 AM   #3
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
When you "source" a script (. /etc/rc.d/rc.PBEAgent start) it will run in the parent script's process.
If that script then calls "exit" not only your script (rc.PBEagent) will end but also the parent script (rc.M) will exit.
That is what you are experiencing here.

Try changing the line in rc.M to this:

Code:
/etc/rc.d/rc.PBEAgent start
I.e. with the dot (the "source" command) left out. Then it will not abort your rc.M script.

Eric
 
Old 05-20-2007, 02:20 PM   #4
ledow
Member
 
Registered: Apr 2005
Location: UK
Distribution: Slackware 13.0
Posts: 241

Rep: Reputation: 34
Shoot me down if I'm wrong but is rc.M really the right file to be fiddling with? Isn't this what rc.local was made for... user's custom changes for a local machine?

You will have (admittedly minor) problems upgrading to the next Slackware if you play about and you'll have to port all your changes to rc.M across to the new file. If you'd have done it in rc.local, you wouldn't have that bother.

Additionally, if something in rc.local goes wrong, you don't get this problem affecting everything. What would have happened is that your rc.local script would have stopped executing but not the main rc.M script... so your major services would have continued running.

And rc.local is ONLY run from rc.M, so you wouldn't change your ability to login in an emergency.

Personally, I run *all* my rc.custom scripts from my rc.local in this same way. And when I upgrade I don't have problems and when I mess it up, I know it can only be me that messed it up. And, if the worst comes to the worst, I just chmod -x rc.local and I know that my system will boot how it was originally designed to.
 
Old 05-20-2007, 05:26 PM   #5
nass
Member
 
Registered: Apr 2006
Location: Athens, Greece
Distribution: slackware, debian, ubuntu
Posts: 666

Original Poster
Rep: Reputation: 39
i see, but why was everything in rc.M chosen to be run as ". /etc/.... " ??and not without the dot?

as for rc.local, well there are somethings (like the no-ip start up script) that must be run prior to others...
so i can't masquerade proftpd correctly if i don't have the correct internet ip address.

of course i could perhaps move proftpd out of rc.M and put it in rc.local.. so im considering i could do exactly that now..

thank you for your help all
nass
 
Old 05-20-2007, 05:31 PM   #6
slimm609
Member
 
Registered: May 2007
Location: Chas, SC
Distribution: slackware, gentoo, fedora, LFS, sidewinder G2, solaris, FreeBSD, RHEL, SUSE, Backtrack
Posts: 430

Rep: Reputation: 67
with the "." it will source the file but as long as it is executable it should work fine. I will just call the file to be included with the rc.M start rather then calling the file to start.
 
Old 05-21-2007, 05:35 AM   #7
pdw_hu
Member
 
Registered: Nov 2005
Location: Budapest, Hungary
Distribution: Slackware, Gentoo
Posts: 346

Rep: Reputation: Disabled
Another thing, which i was lazy to bring up a topic for:
Did anyone experience the following:

/etc/rc.d/rc.cups start being called from rc.M normally (eg.:without the .),
but even so anything that's below (after) it doesn't load.
I circumvented it by deleting the exit 1. line from the en of rc.cups, but this probably
isn't the best solution.

Any thoughts?
 
Old 05-21-2007, 06:21 AM   #8
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,463
Blog Entries: 7

Rep: Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561
Quote:
Originally Posted by ledow
Personally, I run *all* my rc.custom scripts from my rc.local in this same way.
I tend to (mis)use Slackware's sysvinit compatibility. This makes it much easier to "package" software which requires init scripts.
 
  


Reply



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
Server aburptly stops running High CPU usage PERL script after about 5 hours bpmee Linux - Server 3 05-18-2007 11:24 AM
running perl scripts very system start abdul_zu Programming 16 09-26-2005 01:55 AM
Script to see if a process ir running, if not start it ncsuapex Programming 4 07-03-2005 01:27 PM
running start up script Kendo1979 Linux - General 2 11-08-2004 12:48 PM
Start Up Scripts not running MaverickApollo Linux - General 3 10-20-2003 09:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:12 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
Open Source Consulting | Domain Registration