a start up script in rc.M stops the following scripts from running
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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.
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..
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.