05-29-2013, 07:31 PM | #1 |
Connoisseur
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
Run automaticaly a script just after plugin installation
Hi all,
I have a question I asked on another thread, but the object is on a different subject. So, I try to have an answer with a new thread. I make a plugin for wich the only thing I want is to run a script shell just after the installation. This script self-destroy at the last instruction. I looked at the nightmode plugin. I see a file /root/autorun.sh I made one for my plugin : If my script is /mnt/onboard/.kobo/MyShell.sh, /root/autorun.sh is : Code:
/mnt/onboard/.kobo/MyShell.sh rm /root/autorun.sh sync reboot Someone is able to help me please ? Thanks. EDIT : After a test with trace I can say that's /root/autorun.sh is not running after the plugin installation. Last edited by Mingyar; 05-29-2013 at 08:00 PM. |
05-30-2013, 04:31 AM | #2 |
Pain in the arse
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
|
Have you edited and added also /etc/udev/rules.d/98-autorunHook.rules ?
Your autorun script have also to remove that file. |
Advert | |
|
05-30-2013, 12:06 PM | #3 |
Connoisseur
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
I forgot this.
I just made a test with, but nothing better. I will work on this when at home. Thanks. |
05-30-2013, 03:12 PM | #4 |
Connoisseur
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
So, I made new investigations :
the autorun.sh : Code:
#!/bin/sh echo "autorun" >/mnt/onboard/.kobo/autorun.log echo "autorun" >/root/autorun.log /mnt/onboard/.kobo/MyScript.sh rm /etc/udev/rules.d/98-autorunHook.rules rm /root/autorun.sh sync reboot Code:
#!/bin/sh ... cp /root/autorun.log /mnt/onboard/.kobo/autorun_from_root.log 1>/mnt/onboard/.kobo/a.log 2>&1 I plug the Kobo to the PC, the autorun.log doesn't exist in the .kobo folder. I unplug then run MyScript.sh (user command in KoboTweaks plugin). I plug again the Kobo. I find the autorun_from_root.log in .kobo folder. So, it seems that autorun.sh has been executed but was not able to access /mnt/onboard/.kobo folder. Someone can confirm that ? If I'm right, is there a way to execute automatically a script in /mnt/onboard/.kobo just after a plugin is installed ? If not, I can put that script in the /root folder, but, this script has to work in the /mnt/onboard/.kobo/images ... I hope my English is enough good to be explain my problem. Last edited by Mingyar; 05-30-2013 at 03:34 PM. |
05-30-2013, 03:40 PM | #5 |
Zealot
Posts: 100
Karma: 470830
Join Date: Nov 2012
Location: Berlin
Device: Nook Simple Touch, Kobo Aura H2O, Kobo Libra 2
|
You could try to add a "sleep 60" (or so) line to your autorun script to wait until the sdcard stuff has been initialized.
Or you could add the invocation of your script to /etc/init.d/rcS, and then in the last line of your script restore the original /etc/init.d/rcS. (The latter is problematic, though, in case the user has modified his rcS.) Last edited by xor_; 05-30-2013 at 03:54 PM. |
Advert | |
|
05-30-2013, 03:41 PM | #6 |
Wizard
Posts: 3,489
Karma: 2914715
Join Date: Jun 2012
Device: kobo touch
|
Mingyar,
I am not sure whether I understand everything you are saying, and I am not a linux user. So chances are that I misunderstand the situation. autorun.sh is run before rcS, right? At the point, when you call Code:
echo "autorun" >/mnt/onboard/.kobo/autorun.log" |
05-30-2013, 03:47 PM | #7 |
Connoisseur
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
Thanks for your answers
@tshering, you're probably right, it's my deduction too, by the events, not a certitude. @xor_, good idea, I try this and reply here. Thanks again. |
05-30-2013, 04:15 PM | #8 | |
Wizard
Posts: 3,489
Karma: 2914715
Join Date: Jun 2012
Device: kobo touch
|
Quote:
1) let 98-autorunHook.rules start autorun.sh 2) autorun.sh inserts into rcS at some point, after the line that mounts mnt/onboard a line that starts runonlyonce.sh. Then it deletes 98-autorunHook.rules and itself. 3) When rcS is run, runonlyonce.sh does whatever it should do and then deletes itself. Optionally it could in addition also remove the line that was added to rcS which invokes runonlyonce.sh. Last edited by tshering; 05-30-2013 at 04:18 PM. |
|
05-30-2013, 05:10 PM | #9 |
Connoisseur
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
That's right tshering.
After a first test with the delay, it doesn't work. A second test, modifying /etc/init.d/rcS worked one time. My script in the .kobo directory has been launched. But I did a mistake somewere, at the next test I bricked my Kobo I'm restauring the SD before making other tests. Just a question to be sure. The call of my script in rcS should be in background (& at the end of the line, maybe nohup at the begin of line) ? I suppose yes, because if I want to clean rcS in my script (called by rcS), it should be impossible if it's running ... |
05-30-2013, 05:19 PM | #10 |
Pain in the arse
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
|
You can check if the device is mounted using:
mount | grep "/mnt/onboard" inside a while loop with a sleep 1. Source: http://usalug.com/phpBB3/viewtopic.php?p=110052#p110052 |
05-30-2013, 05:28 PM | #11 |
Pain in the arse
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
|
If I remember well, /etc/udev/rules.d scripts are launched at boot. You need to reboot the kobo to make it running. IMHO it's more simple to create a SSH connection.
|
05-30-2013, 05:42 PM | #12 |
Wizard
Posts: 3,489
Karma: 2914715
Join Date: Jun 2012
Device: kobo touch
|
@Lucas Malor
I thought Mingyar tries to make an install mechanism with KoboRoot.tgz. In this case the device will be rebooted after running the "if [ -e /mnt/onboard/.kobo/KoboRoot.tgz ]; then ..." part, and during the reboot the modified rcS will be run. If the call to runonlyonce.sh is inserted at the proper place, there should not be a doubt that mnt/onboard is already mounted. @Mingyar I don't think there is a problem modifying the file of the calling script, this doesn't influence the process. So nohub might not be necessary. However, I repeat that I have almost no knowledge about linux. So be warned. |
05-30-2013, 07:29 PM | #13 |
Connoisseur
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
Thanks all !
It works well now My way to make it work is not perfect maybe, but it works. autorun.sh : Code:
#!/bin/sh if [ `grep -c "MyScript" /etc/init.d/rcS` -eq 0 ] then cp /etc/init.d/rcS /root/rcS chmod a+x /root/rcS echo "" >>/etc/init.d/rcS echo "nohup /mnt/onboard/.kobo/MyScript.sh &" >>/etc/init.d/rcS echo "sleep 5" >>/etc/init.d/rcS echo "if [ -s /root/rcS ]" >>/etc/init.d/rcS echo "then" >>/etc/init.d/rcS echo " rm -rf /etc/init.d/rcS" >>/etc/init.d/rcS echo " mv -f /root/rcS /etc/init.d/rcS" >>/etc/init.d/rcS # for debug begin echo "else echo 'no /root/rcS' >/mnt/onboard/.kobo/NorcS.log 2>&1" >>/etc/init.d/rcS # for debug end echo "fi" >>/etc/init.d/rcS echo "" >>/etc/init.d/rcS fi rm /etc/udev/rules.d/98-autorunHook.rules rm /root/autorun.sh sync reboot |
05-31-2013, 02:41 PM | #14 |
Connoisseur
Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
I don't want to open a new thread for my little question.
Is it possible in script shell to know the kobo model (Mini, Touch, Glo or Aura) ? |
05-31-2013, 03:00 PM | #15 |
Addict
Posts: 348
Karma: 209937
Join Date: Jan 2012
Location: Virginia, US
Device: Kobo Wifi, Kobo Glo
|
You can use /bin/kobo_config.sh. It returns the codename of the device. Trilogy is Touch, kraken is Glo, pixie is Mini, and dragon is Aura.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
GUI Plugin help for Custom Export Script | iomari | Plugins | 4 | 10-28-2011 09:09 AM |
Kindle 3: run script when turning wifi on? | theblop | Kindle Developer's Corner | 1 | 11-09-2010 10:25 AM |
run script on wifi connect | sinisterguy | Kindle Developer's Corner | 1 | 10-18-2010 03:46 PM |
Universal Flasher run script | Jamp | Sony Reader Dev Corner | 1 | 08-26-2009 09:34 AM |
iLiad Can't run my first script | ragdoll | iRex Developer's Corner | 4 | 01-28-2008 06:40 AM |