Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 08-26-2013, 08:25 PM   #1
knauck
root
knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.
 
Posts: 26
Karma: 29272
Join Date: Jul 2013
Location: ntldll.dll
Device: Kindle Paperwhite
Best way to exec script on boot

If you want to execute a script on boot, use /etc/upstart. The following methods will NOT work:
  • /etc/crontab/root with @reboot task
  • /etc/init.d/
  • /etc/rc.local

Make a file with the extension '.conf' and add a start condition and a stop condition as your first and second lines. Be sure your script and your .conf are unix format and not windows. (CRLF is bad and will make big problems.)

For example: /etc/upstart/fubar.conf
Code:
start on started lab126_gui
# This line tells init.d where in the boot process to start this script. Good
# places are "start on started framework" if you need it to run after the
# framework daemon is running. "start on started lab126_gui" tells it to run
# after the ui is up. That is the final phase of the boot process.

stop on stopping lab126_gui
# This tells the system when in the shutdown process to kill your script. If
# you are just running a single command, this isn't terribly important.

script
	# exec /bin/sh /your/script/here.sh
	exec /bin/bash /var/local/dev/somescript.sh
end script
** !! NOTICE !! ** !! NOTICE !! ** !! NOTICE !! ** !! NOTICE !! **

If you choose to remove whatever this conf points to, you MUST MUST MUST delete this from the upstart folder. If anything in this folder errors out there is a very good chance your kindle will fail to boot!

Original question:
Spoiler:
As title implies, I am looking for the best way to effectively run a single script at boot time. This may be done after framework has started.

So far I have tried using @reboot in crontab, a conf file in /etc/upstart, and a service in init.d, none of which worked...what am I missing?

Last edited by knauck; 08-28-2013 at 12:04 PM.
knauck is offline   Reply With Quote
Old 08-28-2013, 12:02 PM   #2
knauck
root
knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.
 
Posts: 26
Karma: 29272
Join Date: Jul 2013
Location: ntldll.dll
Device: Kindle Paperwhite
Solved own problem. Updated OP to show solution for posterity.
knauck is offline   Reply With Quote
Old 08-29-2013, 11:18 AM   #3
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by knauck View Post
Solved own problem. Updated OP to show solution for posterity.
A variation on this problem solution which puts the scripts into user accessable storage published by dos1 about 5 months ago:
https://www.mobileread.com/forums/sho...d.php?t=198484

Also indexed under the K5 prefix.
knc1 is offline   Reply With Quote
Old 08-30-2013, 02:01 PM   #4
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
Wrapping up everything in tests is a good way to avoid everything blowing up if something's missing/wrong/broken.

(For debugging purposes (of the inlined parts of the script), testing your scripts with a shell in -e mode is also a good practice, especially if you rely on external tools with broken return codes).

Cf. dos1's tool for more examples, or the upstart jobs of the SS/Fonts hacks).

Last edited by NiLuJe; 08-30-2013 at 06:27 PM.
NiLuJe is offline   Reply With Quote
Old 08-30-2013, 03:57 PM   #5
knauck
root
knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.knauck is faster than slow light.
 
Posts: 26
Karma: 29272
Join Date: Jul 2013
Location: ntldll.dll
Device: Kindle Paperwhite
Quote:
Originally Posted by NiLuJe View Post
Wrapping up everything in tests is a good way to avoid everything blowing up if something's missing/wrong/broken.

(For debugging purposes (of the inlined parts of the script), testing test your scripts with a shell in -e mode is also a good practice, especially if you rely on external tools with broken return codes).

Cf. dos1's tool for more examples, or the upstart jobs of the SS/Fonts hacks).
Yeah and I forgot to mention that adding a return code of 0 is a good idea, too.
knauck is offline   Reply With Quote
Old 08-30-2013, 04:31 PM   #6
damaru
Enthusiast
damaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animals
 
damaru's Avatar
 
Posts: 45
Karma: 6672
Join Date: Apr 2011
Device: kindle
How can I go about it on the k3?
damaru is offline   Reply With Quote
Old 08-30-2013, 06:28 PM   #7
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
@damaru: A classic SYSV init script .

Lemme dig up the interesting runlevels, but, OTOH, 5 is boot, 6 is reboot, 0 is shutdown, and 3 is update.

For example, the same script I linked to earlier, but in its K3 version: ScreenSavers hack. (Check the install script for more details on the whole symlinking into the right runlevel stuff).

Last edited by NiLuJe; 08-30-2013 at 06:31 PM.
NiLuJe is offline   Reply With Quote
Old 08-30-2013, 06:29 PM   #8
thomass
Wizard
thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.
 
Posts: 1,669
Karma: 2300001
Join Date: Mar 2011
Location: Türkiye
Device: Kindle 5.3.7
Quote:
Originally Posted by damaru View Post
How can I go about it on the k3?
you can use kite
thomass is offline   Reply With Quote
Old 08-31-2013, 01:15 PM   #9
damaru
Enthusiast
damaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animals
 
damaru's Avatar
 
Posts: 45
Karma: 6672
Join Date: Apr 2011
Device: kindle
Quote:
Originally Posted by NiLuJe View Post
@damaru: A classic SYSV init script .
I kind of forget that we're on linux here

thanks!
damaru is offline   Reply With Quote
Old 08-31-2013, 01:19 PM   #10
damaru
Enthusiast
damaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animals
 
damaru's Avatar
 
Posts: 45
Karma: 6672
Join Date: Apr 2011
Device: kindle
Expanding on the init script - is it possible to disable the screensaver from that script?

would

lipc-set-prop com.lab126.powerd -i touchScreenSaverTimeout 1

work on k3?

Last edited by damaru; 08-31-2013 at 01:31 PM.
damaru is offline   Reply With Quote
Old 08-31-2013, 02:35 PM   #11
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
Nope, that doesn't disable screensavers, not at home right now, check the lipc-probe output for powerd. Once you have the right prop, just make sure your script starts after powerd, and you should be okay .
NiLuJe is offline   Reply With Quote
Old 08-31-2013, 03:07 PM   #12
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Disable screensaver:
lipc-set-prop com.lab126.powerd preventScreenSaver 1
Enable screensaver:
lipc-set-prop com.lab126.powerd preventScreenSaver 0
twobob is offline   Reply With Quote
Old 08-31-2013, 04:48 PM   #13
silver18
THE NOOB
silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.silver18 ought to be getting tired of karma fortunes by now.
 
silver18's Avatar
 
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
Quote:
Originally Posted by NiLuJe View Post
Wrapping up everything in tests is a good way to avoid everything blowing up if something's missing/wrong/broken.
Could you please explain this a little bit? Thanks!
silver18 is offline   Reply With Quote
Old 08-31-2013, 07:02 PM   #14
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
@silver18: Upstart runs its script portions more or less like a shell in 'honor return codes' (-e) mode. Meaning if *any* part of the script returns a non-zero return code, the full script/job will fail. Which might possibly halts the boot process, I'm not familiar enough with upstart and the job tree on the Kindle to be definitive on that, and I don't really want to be, so I just handle it with a touch of paranoia .

In the OP's examples, that means that if the file it tries to run doesn't exist, it'll fail to start the job, possibly not very gracefully, possibly halting the boot process.

So, simple workaround, check that the file exists before running it, (and eventually return 0 at the end for extra paranoia ^^):

Code:
exec /bin/bash /var/local/dev/somescript.sh
=>

Code:
[ -f /var/local/dev/somescript.sh ] && exec /bin/bash /var/local/dev/somescript.sh
Also, on a sidenote, I have no idea if relying on 'exec' in the script potion of an upstart job is safe at all. I'd just live with the fork, and just run it relying on the shebang.
NiLuJe is offline   Reply With Quote
Old 09-24-2013, 06:39 PM   #15
damaru
Enthusiast
damaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animalsdamaru is kind to children and small, furry animals
 
damaru's Avatar
 
Posts: 45
Karma: 6672
Join Date: Apr 2011
Device: kindle
That got resolve over IRC couldn't wait

continuing on launching a script on boot on k3, I would need a tad of help on it, I've createa a /etc/init.d/myscript file that launch the script in /mnt/us/documents/

both script are chmod +x and the script in the /mnt/us/documents works no problem when launched by itself then I should add a soft link in the rc5.d but I am not too sure how to call it?

like it should be S but then the number could be anything higher than what is there already? and I should also ln -s for the rc0 for when it stops?

Am I making thing way too complexe here? (or making any sense at all)

Last edited by damaru; 09-24-2013 at 07:05 PM. Reason: resolved
damaru is offline   Reply With Quote
Reply

Tags
kindle modifications

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ant Exec(scp) on Windows Os ? CapitainDerya Kindle Developer's Corner 5 08-19-2013 03:37 PM
How to show kernel boot information instead Amazon boot picture? madtrapper Kindle Developer's Corner 8 01-04-2013 08:51 AM
Story HD Mod: SHD Exec Wermesz iRiver Story 8 10-09-2012 01:12 PM
Opus cannot boot, stuck on boot screen baloma Bookeen 35 11-13-2010 04:20 AM
Best Ereader software for O2 xda exec rajendra8 Reading and Management 2 09-10-2009 05:40 AM


All times are GMT -4. The time now is 10:19 AM.


MobileRead.com is a privately owned, operated and funded community.