Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 05-29-2013, 07:31 PM   #1
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
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
But, my script don't run after plugin installation.

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.
Mingyar is offline   Reply With Quote
Old 05-30-2013, 04:31 AM   #2
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
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.
Lucas Malor is offline   Reply With Quote
Advert
Old 05-30-2013, 12:06 PM   #3
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
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.
Mingyar is offline   Reply With Quote
Old 05-30-2013, 03:12 PM   #4
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
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
in MyScript.sh :
Code:
#!/bin/sh

...

cp /root/autorun.log /mnt/onboard/.kobo/autorun_from_root.log 1>/mnt/onboard/.kobo/a.log 2>&1
After copy of the KoboRoot.tgz in .kobo folder and unplug the Kobo, update phase is succedded by restart.

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.
Mingyar is offline   Reply With Quote
Old 05-30-2013, 03:40 PM   #5
xor_
Zealot
xor_ ought to be getting tired of karma fortunes by now.xor_ ought to be getting tired of karma fortunes by now.xor_ ought to be getting tired of karma fortunes by now.xor_ ought to be getting tired of karma fortunes by now.xor_ ought to be getting tired of karma fortunes by now.xor_ ought to be getting tired of karma fortunes by now.xor_ ought to be getting tired of karma fortunes by now.xor_ ought to be getting tired of karma fortunes by now.xor_ ought to be getting tired of karma fortunes by now.xor_ ought to be getting tired of karma fortunes by now.xor_ ought to be getting tired of karma fortunes by now.
 
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.
xor_ is offline   Reply With Quote
Advert
Old 05-30-2013, 03:41 PM   #6
tshering
Wizard
tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.
 
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"
mnt/onboard is not yet mounted, therefore you cannot write to /mnt/onboard/.kobo/autorun.log.
tshering is offline   Reply With Quote
Old 05-30-2013, 03:47 PM   #7
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
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.
Mingyar is offline   Reply With Quote
Old 05-30-2013, 04:15 PM   #8
tshering
Wizard
tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.
 
Posts: 3,489
Karma: 2914715
Join Date: Jun 2012
Device: kobo touch
Quote:
Originally Posted by xor_ View Post
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.)
That is why Mingyar takes the nightmode hack as model. It should go somehow like this:
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.
tshering is offline   Reply With Quote
Old 05-30-2013, 05:10 PM   #9
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
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 ...
Mingyar is offline   Reply With Quote
Old 05-30-2013, 05:19 PM   #10
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
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
Lucas Malor is offline   Reply With Quote
Old 05-30-2013, 05:28 PM   #11
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
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.
Lucas Malor is offline   Reply With Quote
Old 05-30-2013, 05:42 PM   #12
tshering
Wizard
tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.tshering ought to be getting tired of karma fortunes by now.
 
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.
tshering is offline   Reply With Quote
Old 05-30-2013, 07:29 PM   #13
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
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
With your help, I progress
Mingyar is offline   Reply With Quote
Old 05-31-2013, 02:41 PM   #14
Mingyar
Connoisseur
Mingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to beholdMingyar is a marvel to behold
 
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) ?
Mingyar is offline   Reply With Quote
Old 05-31-2013, 03:00 PM   #15
KevinShort
Addict
KevinShort ought to be getting tired of karma fortunes by now.KevinShort ought to be getting tired of karma fortunes by now.KevinShort ought to be getting tired of karma fortunes by now.KevinShort ought to be getting tired of karma fortunes by now.KevinShort ought to be getting tired of karma fortunes by now.KevinShort ought to be getting tired of karma fortunes by now.KevinShort ought to be getting tired of karma fortunes by now.KevinShort ought to be getting tired of karma fortunes by now.KevinShort ought to be getting tired of karma fortunes by now.KevinShort ought to be getting tired of karma fortunes by now.KevinShort ought to be getting tired of karma fortunes by now.
 
KevinShort's Avatar
 
Posts: 348
Karma: 209937
Join Date: Jan 2012
Location: Virginia, US
Device: Kobo Wifi, Kobo Glo
Quote:
Originally Posted by Mingyar View Post
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) ?
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.
KevinShort is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 05:17 AM.


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