Bryant Zimmerman
2012-Jan-17 14:11 UTC
[asterisk-users] /etc/init.d script and calling asterisk command line.
I have written a program that monitors asterisk to make sure my peers and channels are all in good order. The program calls asterisk once a min and then parses the output. The program works fine when launched from the command line. I then wrote a script to launch the program with the hope of launching it on boot up from /etc/init.d. When I log into a terminal session and run the script I am able to start/stop/status on the program and all is good. When I copy the same script to the /etc/init.d folder and run it the program fails to be able to access the asterisk bin. In all three cases I am logged in as root. The script is owned by root and all it's permissions set. Anyone have any idea why running my startup script from the /etc/init.d folder would act differently? I am running asterisk 1.8.x, On opensuse 11.x. The startup script is launching a mono application. Any ideas would be appreciated. Thanks Bryant -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120117/5b121ee0/attachment.htm>
Danny Nicholas
2012-Jan-17 14:21 UTC
[asterisk-users] /etc/init.d script and calling asterisk command line.
You want your program to live in /usr/local/bin. /etc/init.d is where the bash scripts that run programs that live elsewhere are housed. It is not a good practice to put executeables there. For example, /etc/init.d/asterisk runs /usr/sbin/safe-asterisk. The scenario I typically use is that /etc/init.d/foo runs /usr/local/bin/bar and puts its' output in /var/log/foobar. From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Bryant Zimmerman Sent: Tuesday, January 17, 2012 8:12 AM To: asterisk-users at lists.digium.com Subject: Re: [asterisk-users] /etc/init.d script and calling asterisk command line. I have written a program that monitors asterisk to make sure my peers and channels are all in good order. The program calls asterisk once a min and then parses the output. The program works fine when launched from the command line. I then wrote a script to launch the program with the hope of launching it on boot up from /etc/init.d. When I log into a terminal session and run the script I am able to start/stop/status on the program and all is good. When I copy the same script to the /etc/init.d folder and run it the program fails to be able to access the asterisk bin. In all three cases I am logged in as root. The script is owned by root and all it's permissions set. Anyone have any idea why running my startup script from the /etc/init.d folder would act differently? I am running asterisk 1.8.x, On opensuse 11.x. The startup script is launching a mono application. Any ideas would be appreciated. Thanks Bryant -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120117/ab90971a/attachment.htm>
A J Stiles
2012-Jan-17 14:30 UTC
[asterisk-users] /etc/init.d script and calling asterisk command line.
On Tuesday 17 January 2012, Bryant Zimmerman wrote:> I have written a program that monitors asterisk to make sure my peers and > channels are all in good order. The program calls asterisk once a min and > then parses the output. The program works fine when launched from the > command line. I then wrote a script to launch the program with the hope of > launching it on boot up from /etc/init.d. When I log into a terminal > session and run the script I am able to start/stop/status on the program > and all is good. When I copy the same script to the /etc/init.d folder and > run it the program fails to be able to access the asterisk bin. > > In all three cases I am logged in as root. The script is owned by root and > all it's permissions set. Anyone have any idea why running my startup > script from the /etc/init.d folder would act differently? > > > I am running asterisk 1.8.x, On opensuse 11.x. The startup script is > launching a mono application.Is it properly linked from /etc/rc2.d , /etc/rc3.d and so forth? When you enter a runlevel, init goes through in order executing files whose names start with a K (for Kill) with argument "stop", and then again executing files whose names start with an S (for Start) with argument "start". The filenames are contrived so as to force a particular order, and they in turn are symbolic links to scripts (usually) located in /etc/init.d/ . I say "usually" because, being symlinks, they could be anywhere; but /etc/init.d/ is the usual place to put them, just so they can be run manually from there. If you want your program to start in runlevels 2, 3, 4 and 5, but not in 0, 1 and 6, and it must wait until after all "S60*" have run, then you need to do somethink like # ln -s /etc/init.d/myfunkyservice /etc/rc2.d/S65myfunkyservice # ln -s /etc/init.d/myfunkyservice /etc/rc3.d/S65myfunkyservice # ln -s /etc/init.d/myfunkyservice /etc/rc4.d/S65myfunkyservice # ln -s /etc/init.d/myfunkyservice /etc/rc5.d/S65myfunkyservice # ln -s /etc/init.d/myfunkyservice /etc/rc0.d/K65myfunkyservice # ln -s /etc/init.d/myfunkyservice /etc/rc1.d/K65myfunkyservice # ln -s /etc/init.d/myfunkyservice /etc/rc6.d/K65myfunkyservice Also, I suggest you read your distro's documentation on custom boot scripts, because every distribution has its own slightly different ideas about how the bootup process should work. -- AJS Answers come *after* questions.
Luis Morales
2012-Jan-17 20:23 UTC
[asterisk-users] /etc/init.d script and calling asterisk command line.
Why not try include into startup/down init script of asterisk ? Regards, On Tue, Jan 17, 2012 at 9:41 AM, Bryant Zimmerman <BryantZ at zktech.com> wrote:> I have written a program that monitors asterisk to make sure my peers and > channels are all in good order. The program calls asterisk once a min and > then parses the output.? The program works fine when launched from the > command line. I then wrote a script to launch the program with the hope of > launching it on boot up from /etc/init.d. When I log into a terminal session > and run the script I am able to start/stop/status on the program and all is > good. When I copy the same script to the /etc/init.d folder and run it the > program fails to be able to access the asterisk bin. > In all three cases I am logged in as root. The script is owned by root and > all it's permissions set.?? Anyone have any idea why running my startup > script from the /etc/init.d folder would act differently? > > I am running asterisk 1.8.x, On opensuse 11.x. The startup script is > launching a mono application. > > Any ideas would be appreciated. > > Thanks > > Bryant > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > ? ? ? ? ? ? ? http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > ? http://lists.digium.com/mailman/listinfo/asterisk-users-- --------------------------------------------------------------------------------- Luis Morales Consultor de Tecnologia Cel: +58(0412)2352745 OpenID: http://lmorales.myopenid.com/ Twitter: @magnadata Linux User ID : 470650 --------------------------------------------------------------------------------- "Empieza por hacer lo necesario, luego lo que es posible... y de pronto estar?s haciendo lo imposible" Leonardo Da'Vinci ---------------------------------------------------------------------------------
Bryant Zimmerman
2012-Jan-17 20:30 UTC
[asterisk-users] /etc/init.d script and calling asterisk command line.
(Solved) ---------------------------------------- From: "Luis Morales" <fastonion at gmail.com> Sent: Tuesday, January 17, 2012 3:20 PM To: "Asterisk Users Mailing List - Non-Commercial Discussion" <asterisk-users at lists.digium.com> Subject: Re: [asterisk-users] /etc/init.d script and calling asterisk command line. Why not try include into startup/down init script of asterisk ? Regards, On Tue, Jan 17, 2012 at 9:41 AM, Bryant Zimmerman <BryantZ at zktech.com> wrote:> I have written a program that monitors asterisk to make sure my peersand> channels are all in good order. The program calls asterisk once a minand> then parses the output. The program works fine when launched from the> command line. I then wrote a script to launch the program with the hopeof> launching it on boot up from /etc/init.d. When I log into a terminalsession> and run the script I am able to start/stop/status on the program and allis> good. When I copy the same script to the /etc/init.d folder and run itthe> program fails to be able to access the asterisk bin.> In all three cases I am logged in as root. The script is owned by rootand> all it's permissions set. Anyone have any idea why running my startup> script from the /etc/init.d folder would act differently?>> I am running asterisk 1.8.x, On opensuse 11.x. The startup script is> launching a mono application.>> Any ideas would be appreciated.>> Thanks>> Bryant>> ---- ---------------------------------------------------------------------------- ----- Luis Morales I have solved my issue. Danny and several others suggested that it might have something to do with environment settings when running form the init.d folder and that is what it turned out to be. I could not get to the asterisk binary with the method I was using. I modified the methods path and my code started to work. Thanks all for your help. Bryant -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120117/799e5b78/attachment.htm>