maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   [Question] How to write start-up scripts? (https://talk.maemo.org/showthread.php?t=80932)

noetus 2011-12-17 09:36

[Question] How to write start-up scripts?
 
I was under the impression you can write scripts and put them in /etc/init/apps. But I can't seem to get mine to work. I would like to write one to delete /home/user/.local/share/applications/simatk.desktop at startup, which is a useless app put there by my SIM card provider and which is recreated at every startup if it is not present.

Is there a tutorial somewhere or can we have a little thread to walk through writing scripts to run at startup and solve problems, etc?

noetus 2011-12-17 10:36

Re: [Question] How to write start-up scripts?
 
So here is what I did. First I wrote a script to delete the offending .desktop file:

Code:

sleep 45
rm /home/user/.local/share/applications/simatk.desktop

The long wait is needed because if the .desktop file was previously deleted it takes up to half a minute for it to be recreated on the next startup.

That is saved as /usr/include/del-t-mobile.sh

Then I executed

Code:

chmod a+rx /usr/include/del-t-mobile.sh
to make sure the script is executable. Note that the script only works when it is run as user, not as root, but it does work.

Now I created the following file

Code:

description "Deletes the program icon for T-Mobile SIM card"

author "aebl"

stop on stopping xsession

console none

nice 2

exec /usr/bin/aegis-exec -s -u user -l  "sh /usr/include/del-t-mobile.sh"

which I then saved as /etc/init/apps/t-mobile.conf

In theory this should work, but it doesn't. Running the script del-t-mobile.sh manually works fine; for some reason t-mobile.conf does not call it at startup.

So what am I doing wrong?

ammyt 2011-12-17 10:56

Re: [Question] How to write start-up scripts?
 
Well, on my N900, if I ever want to start a script at bootup, I usually create a file in etc/event.d like:
/etc/event.d/dbus-scripts-session which I used to start dbus-scripts when my N900 starts. it contains:
Code:

start on started hildon-desktop
stop on stopping hildon-desktop

console none

exec run-standalone.sh /usr/sbin/dbus-scripts --session

respawn

EDIT: Wait, you put that in init,d, are you sure you did a "update-rc.d <script> defaults" afterwards?

noetus 2011-12-17 11:04

Re: [Question] How to write start-up scripts?
 
I believe this is disabled by aegis on the N9. I cannot create files in /etc/init.d/ even as root. The directory /etc/init/apps is, I believe, intended for applications to be able to have daemons, and I'm sort of piggy-backing on that... still stuck

jalyst 2011-12-20 10:01

Re: [Question] How to write start-up scripts?
 
Quote:

Originally Posted by noetus (Post 1138681)
I believe this is disabled by aegis on the N9. I cannot create files in /etc/init.d/ even as root. The directory /etc/init/apps is, I believe, intended for applications to be able to have daemons, and I'm sort of piggy-backing on that... still stuck

Interested in hearing the solution to this so I can add it to my how-to's

AlMehdi 2011-12-20 10:15

Re: [Question] How to write start-up scripts?
 
Try doing it with "exec sh /usr/include/del-t-mobile.sh" as i don't think the user are allowed to do that ;)

But i am sure there is a cleaner way in doing this. Isn't that just an app icon?

noetus 2011-12-20 12:01

Re: [Question] How to write start-up scripts?
 
Quote:

Originally Posted by AlMehdi (Post 1139867)
But i am sure there is a cleaner way in doing this. Isn't that just an app icon?

It is just an icon and I'd love to know a cleaner way of doing it.. but it gets created on every boot of the device, even if the file already exists (so adding NotShowIn=X-MeeGo; to it only works until the next reboot). I also tried modifying permissions on it but it just got rewritten with the 'correct permissions on the next boot.

AlMehdi 2011-12-20 15:33

Re: [Question] How to write start-up scripts?
 
Have you looked in "/etc/init/xsession*" or "/etc/default/*" ? Be careful though as changing this things could brick the phone.

coderus 2011-12-20 15:55

Re: [Question] How to write start-up scripts?
 
/etc/init/apps/*.conf autostart always work fine. autostart started after some seconds after reboot.

uber 2011-12-20 19:04

Re: [Question] How to write start-up scripts?
 
Running a script using "exec <script>" will run it as root. Trying to use "exec aegis-exec -s -u user" will run the script as nobody even though you specified user. I think you need to package your script in a .deb to get it signed by aegis when you install it to be able to run it as a different user with aegis-exec.

ejasmudar 2012-01-05 19:26

Re: [Question] How to write start-up scripts?
 
Quote:

Originally Posted by coderus (Post 1140024)
/etc/init/apps/*.conf autostart always work fine. autostart started after some seconds after reboot.

Can you please tell me what the format for the *.conf file is? Or please link to a guide.

jalyst 2012-01-05 20:11

Re: [Question] How to write start-up scripts?
 
Quote:

Originally Posted by ejasmudar (Post 1146277)
Can you please tell me what the format for the *.conf file is? Or please link to a guide.


maybe something like this
http://talk.maemo.org/showthread.php...92#post1129092

caco3 2012-01-05 20:21

Re: [Question] How to write start-up scripts?
 
Just read the instructions here and use the template there.

bullx 2012-08-27 21:41

Re: [Question] How to write start-up scripts?
 
maybe i come late

but there, if u just want to disable the simatk coin, just edit this file
/etc/default/csd-simatk
trun the var ENABLE to 0, save and reboot, that's the best way

in this way, there will never be a process try to create a simatk coin

my N9 flashed the openmode kernel, if u can't modify or what, try this kernel, it disabled the aegis

hope this can help u somewhat~

topet2k12001 2012-08-27 21:56

Re: [Question] How to write start-up scripts?
 
Friends,

Does this not achieve the objective (of removing the SIM icon)?

http://n9-apps.com/remove-sim-shortcut-app


All times are GMT. The time now is 00:36.

vBulletin® Version 3.8.8