FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Kubuntu User

 
 
LinkBack Thread Tools
 
Old 03-14-2009, 04:44 PM
"Howard Coles Jr."
 
Default Why won't my script run?

On Saturday 14 March 2009 12:07:21 pm Mark Greenwood wrote:

> Another question for the boffins..

>

> My Acer Aspire One needs a special script to control the fan. This script

> is called /usr/local/bin/acerfand and, when I run it from the command line

> it does indeed control the fan. acerfand is a bash script which daemonises

> itself using magic I do not understand.

>

> To get it to start at boot I'm instructed to place the command line into

> /etc/rc.local, so ignoring comments my /etc/rc.local now looks like

>

> #!/bin/sh -e

> /usr/local/bin/acerfand

> exit 0

>

> If I run 'sudo /etc/rc.local' from the command line my fan script starts

> running, the fan is being controlled and I can see acerfand as a running

> process.

>

> On boot however, the script starts and then immediately exits (I put debug

> in, I can see it in syslog starting up and then exiting). There is no

> running process called acerfand after boot. Again, I type 'sudo

> /etc/rc.local' at a command line and now there is a running acerfand

> process.

>

> Why the different behaviour at boot, and how can I make it work?

>

> It worked on Mandriva....

>

> Thanks,

>

> Mark



It would be easier to copy your fan control script into the /etc/init.d directory and then add it to the /etc/rc#.d/ as a softlink with either "S##acerfan" or "K##acerfan" (s is for start and the number is the order in which you want it to start, K is for kill or stop, and again the number indicates when you want it to stop relative to the other K's in the directory.).



create a "acerfan" file (using /bin/bash instead of sh as its default on most Debian based distros) in /etc/init.d with the contents of what you put in rc.local (leaving off the "exit 0" line).

then softlink the script in rc2.d (default runlevel in Debian based distros) as follows:

ln -s /etc/init.d/acerfan /etc/rc2.d/S99acerfan

ln -s /etc/init.d/acerfan /etc/rc6.d/K03acerfan

that last line is optional.

Then see what happens.



--

See Ya'

Howard Coles Jr.

John 3:16!



--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 03-14-2009, 05:43 PM
Nigel Ridley
 
Default Why won't my script run?

Howard Coles Jr. wrote:
> On Saturday 14 March 2009 12:07:21 pm Mark Greenwood wrote:
>> Another question for the boffins..
>>
>> My Acer Aspire One needs a special script to control the fan. This script
>> is called /usr/local/bin/acerfand and, when I run it from the command line
>> it does indeed control the fan. acerfand is a bash script which daemonises
>> itself using magic I do not understand.
>>
>> To get it to start at boot I'm instructed to place the command line into
>> /etc/rc.local, so ignoring comments my /etc/rc.local now looks like
>>
>> #!/bin/sh -e
>> /usr/local/bin/acerfand
>> exit 0
>>
>> If I run 'sudo /etc/rc.local' from the command line my fan script starts
>> running, the fan is being controlled and I can see acerfand as a running
>> process.
>>
>> On boot however, the script starts and then immediately exits (I put debug
>> in, I can see it in syslog starting up and then exiting). There is no
>> running process called acerfand after boot. Again, I type 'sudo
>> /etc/rc.local' at a command line and now there is a running acerfand
>> process.
>>
>> Why the different behaviour at boot, and how can I make it work?
>>
>> It worked on Mandriva....
>>
>> Thanks,
>>
>> Mark
>
> It would be easier to copy your fan control script into the /etc/init.d
> directory and then add it to the /etc/rc#.d/ as a softlink with either
> "S##acerfan" or "K##acerfan" (s is for start and the number is the order in
> which you want it to start, K is for kill or stop, and again the number
> indicates when you want it to stop relative to the other K's in the
> directory.).
>
> create a "acerfan" file (using /bin/bash instead of sh as its default on most
> Debian based distros) in /etc/init.d with the contents of what you put in
> rc.local (leaving off the "exit 0" line).
> then softlink the script in rc2.d (default runlevel in Debian based distros)
> as follows:
> ln -s /etc/init.d/acerfan /etc/rc2.d/S99acerfan
> ln -s /etc/init.d/acerfan /etc/rc6.d/K03acerfan
> that last line is optional.
> Then see what happens.
>
>

The correct Debian way (and I suppose it [still] applies to *ubuntu) is:

[quote]
Suppose a system needs to execute script foo on start-up, or on entry to a particular (System V)
runlevel. Then the system administrator should:

* Enter the script foo into the directory /etc/init.d/.

* Run the Debian command update-rc.d with appropriate arguments, to specify which runlevels
should start the service, and which runlevels should stop the service.

* Consider rebooting the system to check that the service starts correctly (assuming that
you've asked for it to be started in the default runlevel). Otherwise, manually start it by
running `/etc/init.d/foo start'.

One might, for example, cause the script foo to execute at boot-up, by putting it in /etc/init.d/
and running update-rc.d foo defaults 19. The argument `defaults' refers to the default runlevels,
which means (at least in absence of any LSB comment block to the contrary) to start the service
in runlevels 2 through 5, and to stop the service in runlevels 0, 1 and 6. (Any LSB Default-Start
and Default-Stop directives in foo take precedence when using the sysv-rc version of update-rc.d,
but are ignored by the current (v0.8.10) file-rc version of update-rc.d.) The argument `19'
ensures that foo is called after all scripts whose number is less than 19 have completed, and
before all scripts whose number is 20 or greater.
[end quote]
(Taken from: http://www.debian.org/doc/FAQ/ch-customizing.en.html (11.6)

Blessings,

Nigel

--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 03-14-2009, 06:12 PM
Martin Laberge
 
Default Why won't my script run?

On Saturday 14 March 2009 13:07:21 Mark Greenwood wrote:
> Another question for the boffins..
>
> My Acer Aspire One needs a special script to control the fan. This script is called /usr/local/bin/acerfand and, when I run it from the command line it does indeed control the fan. acerfand is a bash script which daemonises itself using magic I do not understand.
>
> To get it to start at boot I'm instructed to place the command line into /etc/rc.local, so ignoring comments my /etc/rc.local now looks like
>
> #!/bin/sh -e
> /usr/local/bin/acerfand
> exit 0
>
> If I run 'sudo /etc/rc.local' from the command line my fan script starts running, the fan is being controlled and I can see acerfand as a running process.
>
> On boot however, the script starts and then immediately exits (I put debug in, I can see it in syslog starting up and then exiting). There is no running process called acerfand after boot. Again, I type 'sudo /etc/rc.local' at a command line and now there is a running acerfand process.
>
> Why the different behaviour at boot, and how can I make it work?
>
> It worked on Mandriva....
>
> Thanks,
>
> Mark
>

The /etc/rc.local script is runned at the end of boot process.

Your script should run at this time.

BUT... You should check what environment variables are availables at this time.
Maybe one important one is missing, (rc.local has few environment set when runned)
then add to rc.local the init environment needed. (ex followed)

#!/bin/sh -e
MYVAR="myvalue"
HOME="/mypath/here"
WHATEVER="whatever other things you may need"
export MYVAR HOME WHATEVER
echo "Starting acerfand"
/usr/local/bin/acerfand || echo "wrong start of acerfand"
exit 0

This would surely help you do the right thing.

--
Martin Laberge
mlsoft@videotron.ca
Tel418)521-6823
30 Years of Unix Admin, and still learning...

--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 03-14-2009, 06:28 PM
Mark Greenwood
 
Default Why won't my script run?

On Saturday 14 March 2009 18:43:14 Nigel Ridley wrote:
> Howard Coles Jr. wrote:
> > On Saturday 14 March 2009 12:07:21 pm Mark Greenwood wrote:
> >> Another question for the boffins..
> >>
> >> My Acer Aspire One needs a special script to control the fan. This script
> >> is called /usr/local/bin/acerfand and, when I run it from the command line
> >> it does indeed control the fan. acerfand is a bash script which daemonises
> >> itself using magic I do not understand.
> >>
> >> To get it to start at boot I'm instructed to place the command line into
> >> /etc/rc.local, so ignoring comments my /etc/rc.local now looks like
> >>
> >> #!/bin/sh -e
> >> /usr/local/bin/acerfand
> >> exit 0
> >>
> >> If I run 'sudo /etc/rc.local' from the command line my fan script starts
> >> running, the fan is being controlled and I can see acerfand as a running
> >> process.
> >>
> >> On boot however, the script starts and then immediately exits (I put debug
> >> in, I can see it in syslog starting up and then exiting). There is no
> >> running process called acerfand after boot. Again, I type 'sudo
> >> /etc/rc.local' at a command line and now there is a running acerfand
> >> process.
> >>
> >> Why the different behaviour at boot, and how can I make it work?
> >>
> >> It worked on Mandriva....
> >>
> >> Thanks,
> >>
> >> Mark
> >
> > It would be easier to copy your fan control script into the /etc/init.d
> > directory and then add it to the /etc/rc#.d/ as a softlink with either
> > "S##acerfan" or "K##acerfan" (s is for start and the number is the order in
> > which you want it to start, K is for kill or stop, and again the number
> > indicates when you want it to stop relative to the other K's in the
> > directory.).
> >
> > create a "acerfan" file (using /bin/bash instead of sh as its default on most
> > Debian based distros) in /etc/init.d with the contents of what you put in
> > rc.local (leaving off the "exit 0" line).
> > then softlink the script in rc2.d (default runlevel in Debian based distros)
> > as follows:
> > ln -s /etc/init.d/acerfan /etc/rc2.d/S99acerfan
> > ln -s /etc/init.d/acerfan /etc/rc6.d/K03acerfan
> > that last line is optional.
> > Then see what happens.
> >
> >
>
> The correct Debian way (and I suppose it [still] applies to *ubuntu) is:
>
> [quote]
> Suppose a system needs to execute script foo on start-up, or on entry to a particular (System V)
> runlevel. Then the system administrator should:
>
> * Enter the script foo into the directory /etc/init.d/.
>
> * Run the Debian command update-rc.d with appropriate arguments, to specify which runlevels
> should start the service, and which runlevels should stop the service.
>
> * Consider rebooting the system to check that the service starts correctly (assuming that
> you've asked for it to be started in the default runlevel). Otherwise, manually start it by
> running `/etc/init.d/foo start'.
>
> One might, for example, cause the script foo to execute at boot-up, by putting it in /etc/init.d/
> and running update-rc.d foo defaults 19. The argument `defaults' refers to the default runlevels,
> which means (at least in absence of any LSB comment block to the contrary) to start the service
> in runlevels 2 through 5, and to stop the service in runlevels 0, 1 and 6. (Any LSB Default-Start
> and Default-Stop directives in foo take precedence when using the sysv-rc version of update-rc.d,
> but are ignored by the current (v0.8.10) file-rc version of update-rc.d.) The argument `19'
> ensures that foo is called after all scripts whose number is less than 19 have completed, and
> before all scripts whose number is 20 or greater.
> [end quote]
> (Taken from: http://www.debian.org/doc/FAQ/ch-customizing.en.html (11.6)
>
> Blessings,
>
> Nigel
>
OK this is wierd.. I've got it so it runs as you suggest - but it still starts and then exits. In fact, it looks as though something is actually telling it to quit! There is a trap statement in the script that executes a command on receiving INT, TERM, or EXIT and this statement gets executed. I'm not sure what INT does, perhaps that has something to do with it?

But I can still do 'sudo service acerfan start' and it starts and does not exit.. so what's going on? Why does it work from the command line but not as part of the init process?

Mark

--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 03-14-2009, 08:34 PM
Jonas Norlander
 
Default Why won't my script run?

2009/3/14 Mark Greenwood <fatgerman@ntlworld.com>:
> But I can still do 'sudo service acerfan start' and it starts and does not exit.. so what's going on? Why does it work from the command line but not as part of the init process?
>
> Mark

Do it still run if you close the console you started it from?
Perhaps you need to start the script in background from /etc/rc.local
like: /usr/local/bin/acerfand &

/ Jonas

--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 03-14-2009, 09:14 PM
Mark Greenwood
 
Default Why won't my script run?

On Saturday 14 March 2009 21:34:35 Jonas Norlander wrote:
> 2009/3/14 Mark Greenwood <fatgerman@ntlworld.com>:
> > But I can still do 'sudo service acerfan start' and it starts and does not exit.. so what's going on? Why does it work from the command line but not as part of the init process?
> >
> > Mark
>
> Do it still run if you close the console you started it from?
> Perhaps you need to start the script in background from /etc/rc.local
> like: /usr/local/bin/acerfand &

Yes it still runs if I close the console. Doing 'acerfand &' doesn't work, it doesn't run at all.

Something is definitely deliberately killing it when I run it as part of the sysinit stuff. I'm exasperated because I got this script off the ubuntu wiki and it works on everything except ubuntu!

I'd post the whole script but it's quite long. If anyone thinks it'll help then I'll do it.

Thanks,

Mark


>
> / Jonas
>

--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 03-14-2009, 10:36 PM
Mark Greenwood
 
Default Why won't my script run?

On Saturday 14 March 2009 22:14:27 Mark Greenwood wrote:
> On Saturday 14 March 2009 21:34:35 Jonas Norlander wrote:
> > 2009/3/14 Mark Greenwood <fatgerman@ntlworld.com>:
> > > But I can still do 'sudo service acerfan start' and it starts and does not exit.. so what's going on? Why does it work from the command line but not as part of the init process?
> > >
> > > Mark
> >
> > Do it still run if you close the console you started it from?
> > Perhaps you need to start the script in background from /etc/rc.local
> > like: /usr/local/bin/acerfand &
>
> Yes it still runs if I close the console. Doing 'acerfand &' doesn't work, it doesn't run at all.
>
> Something is definitely deliberately killing it when I run it as part of the sysinit stuff. I'm exasperated because I got this script off the ubuntu wiki and it works on everything except ubuntu!
>
> I'd post the whole script but it's quite long. If anyone thinks it'll help then I'll do it.
>
> Thanks,
>
> Mark

Ah never mind, I found a kernel module that does the same thing, built it and now my fan is quiet.

Hell, 5 hours of my life....

Thanks for the replies.

Mark

>
>
> >
> > / Jonas
> >
>

--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 03-15-2009, 08:42 PM
"Terrell Prudé Jr."
 
Default Why won't my script run?

_______________________________


Do you GNU?


Microsoft Free since 2003--the
ultimate antivirus protection!







Nigel Ridley wrote:
<div class="moz-text-flowed" style="font-family:
-moz-fixed">Howard Coles Jr. wrote:


On Saturday 14 March 2009 12:07:21 pm Mark
Greenwood wrote:


Another question for the boffins..




My Acer Aspire One needs a special script to control the fan. This
script


is called /usr/local/bin/acerfand and, when I run it from the command
line


it does indeed control the fan. acerfand is a bash script which
daemonises


itself using magic I do not understand.




To get it to start at boot I'm instructed to place the command line
into


/etc/rc.local, so ignoring comments my /etc/rc.local now looks like




#!/bin/sh -e


/usr/local/bin/acerfand


exit 0




If I run 'sudo /etc/rc.local' from the command line my fan script
starts


running, the fan is being controlled and I can see acerfand as a
running


process.




On boot however, the script starts and then immediately exits (I put
debug


in, I can see it in syslog starting up and then exiting). There is no


running process called acerfand after boot. Again, I type 'sudo


/etc/rc.local' at a command line and now there is a running acerfand


process.




Why the different behaviour at boot, and how can I make it work?




It worked on Mandriva....




Thanks,




Mark





It would be easier to copy your fan control script into the /etc/init.d
directory and then add it to the /etc/rc#.d/ as a softlink with either
"S##acerfan" or "K##acerfan"* (s is for start and the number is the
order in which you want it to start, K is for kill or stop, and again
the number indicates when you want it to stop relative to the other K's
in the directory.).




create a "acerfan" file (using /bin/bash instead of sh as its default
on most Debian based distros) in /etc/init.d with the contents of what
you put in rc.local (leaving off the "exit 0" line).


then softlink the script in rc2.d (default runlevel in Debian based
distros) as follows:


ln -s /etc/init.d/acerfan /etc/rc2.d/S99acerfan


ln -s /etc/init.d/acerfan /etc/rc6.d/K03acerfan


that last line is optional.


Then see what happens.









The correct Debian way (and I suppose it [still] applies to *ubuntu)
is:




[quote]


Suppose a system needs to execute script foo on start-up, or on entry
to a particular (System V) runlevel. Then the system administrator
should:




*** * Enter the script foo into the directory /etc/init.d/.




*** * Run the Debian command update-rc.d with appropriate arguments, to
specify which runlevels should start the service, and which runlevels
should stop the service.




*** * Consider rebooting the system to check that the service starts
correctly (assuming that you've asked for it to be started in the
default runlevel). Otherwise, manually start it by running
`/etc/init.d/foo start'.




One might, for example, cause the script foo to execute at boot-up, by
putting it in /etc/init.d/ and running update-rc.d foo defaults 19. The
argument `defaults' refers to the default runlevels, which means (at
least in absence of any LSB comment block to the contrary) to start the
service in runlevels 2 through 5, and to stop the service in runlevels
0, 1 and 6. (Any LSB Default-Start and Default-Stop directives in foo
take precedence when using the sysv-rc version of update-rc.d, but are
ignored by the current (v0.8.10) file-rc version of update-rc.d.) The
argument `19' ensures that foo is called after all scripts whose number
is less than 19 have completed, and before all scripts whose number is
20 or greater.


[end quote]


(Taken from: http://www.debian.org/doc/FAQ/ch-customizing.en.html
(11.6)




Blessings,




Nigel




The odd part is that the script certainly is executing, and apparently
so is acerfand.* But acerfand is apparently exiting immediately
thereafter.* Given that /etc/rc.local executes in root's context, this
is *very* weird behaviour indeed.



Unless there's something horribly broken in Ubuntu, then it shouldn't
matter one damned bit how you start the daemon, be it in /etc/rc.local
or in a SysV init script.* I put stuff in /etc/rc.local all the time on
many distros, including Debian and Ubuntu Dapper/Hardy.



Let's try a couple of things, just to make _absolutely_ sure
/usr/local/bin/acerfand is starting.* Tweak /etc/rc.local to look like
this:



#!/bin/sh -e


echo "Starting acerfand..."* # new line

/usr/local/bin/acerfand


echo "Done."*** # new line

sleep 1

exit 0




If that doesn't work, then try also adding " &" after "acerfand".*
This will start the process in the background.* Yes, I know, it
automatically daemonizes, but just give it a shot anyway and see if it
stays alive.* It can't hurt to try.



--TP



--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 

Thread Tools




All times are GMT. The time now is 04:42 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org