SliTaz SliTaz Forum

You are not logged in.

#1 2011-07-30 15:52:22

nim108
Member
Registered: 2011-07-29
Posts: 12

How to autostart script AFTER bootup?

Since I need a very small terminal based distro, I am running the base flavor of the latest Slitaz cooking. However, I am running into two problems:

1) autologin in kernel boot options does not auto login in the terminal. I still need to specify tux or root/root when terminal comes up.

2) I need to autostart a script AFTER the system is booted to the terminal so that the user can see what is going on. If I stick in the commands in /etc/init.d/local.sh, that is executed at boot time and the user won't be able to see anything. To make matters worse, the only way to see if commands are properly being executed by local.sh is looking in /var/boot/boot.log, which I don't want to do. So how do I auto exec a script after terminal is booted up (or in general as I may want to do the same for a full fledged cooking version in the future)?

Offline

#2 2011-07-30 19:42:51

bellard
Administrator
Registered: 2011-03-28
Posts: 657

Re: How to autostart script AFTER bootup?

Try this:

# sed -i 's|.*shell.*|tty1::respawn:/bin/ash|;/getty/d' /etc/inittab

# cat >> /etc/profile <<EOT

Your commands...

EOT

-pascal

Offline

#3 2011-07-31 12:40:31

nim108
Member
Registered: 2011-07-29
Posts: 12

Re: How to autostart script AFTER bootup?

Bellard, thank you for the help. Replacing getty in inittab for tty1 with /bin/ash worked great, now I am auto logged in. However, putting my test script (./test.sh) at the end of /etc/profile did not do anything as far as I can tell. My test script simply echos "hello" but I do not see it when the system is up. Basically, base cooking ISO boots up, displays default display message "Welcome to your box" "Slitaz boot time: 3s" then goes to the ash prompt, no execution of script. If you could, I'd prefer a solution that works on both base and justx cooking flavors of Slitaz as I am using both and must auto exec a script AFTER boot up on both sides. Also, I must run this script as root if it's possible. I'm not sure if what you provided me would allow me to run it as root. Thanks.

Offline

#4 2011-08-02 22:39:19

nim108
Member
Registered: 2011-07-29
Posts: 12

Re: How to autostart script AFTER bootup?

Any ideas guys? Sorry to bump this but I'm stumped on this.

Offline

#5 2011-08-03 17:04:21

Guest
Guest

Re: How to autostart script AFTER bootup?

I can confirm your experience totally, nim108 and I'm also searching desperately for a solution for that problem.

If anyone knows, please response

Djego

#6 2011-08-03 18:18:13

claudinei
Administrator
Registered: 2011-03-29
Posts: 102

Re: How to autostart script AFTER bootup?

Hi,

You can try the autologin approach described in:

http://forum.slitaz.org/topic/auto-login-sem-x#post-2271

Then, you can modify the file /usr/bin/autologin to add your script:

[c]#!/bin/sh

exec /bin/login -f tux

exec /path/to/your/script[/c]

I haven't tried it myself, but you can try and return here to tell if it works for you.

Offline

#7 2011-08-04 15:40:52

nim108
Member
Registered: 2011-07-29
Posts: 12

Re: How to autostart script AFTER bootup?

Claudinei, the exec /bin/login -f tux command works fine to login automatically as user tux, however, it will not exec my test script. If I exec it manually after boot up, it works just fine, so I know it's not the script (which is just supposed to echo "hello"). Any other ideas on how to get it to exec automatically? Thanks, I do appreciate all the help / responses.

Offline

#8 2011-08-04 18:03:24

Guest
Guest

Re: How to autostart script AFTER bootup?

Tanks for your advice Claudinei.

nim108, try this:

add [c]exec /path/to/your/script[/c] to the second to last line (before [c]fi # logged[/c]) in the /etc/init.d/rcS file.

I tried and it worked, but I'm not shure and of course want to know if that's the "nice" way to realize a autoexecution?

#9 2011-08-04 22:02:46

nim108
Member
Registered: 2011-07-29
Posts: 12

Re: How to autostart script AFTER bootup?

djego, thanks for the suggestion. I figured editing rcS would work, but that file should never be touched in my opinion, especially when there are config files directly concerning rcS. It's a hack at best, but it might be the only way to do it in terminal based versions of Slitaz. Editing inittab with autolaunching an autologin script is fine for autologging in; I have no issues with that, but I don't think we should have to edit rcS to autolaunch a custom script after boot. Any other way to do this?

Offline

#10 2011-08-08 22:45:25

nim108
Member
Registered: 2011-07-29
Posts: 12

Re: How to autostart script AFTER bootup?

djego, I finally tried this your way (hacking rcS with the script path on the bottom of the script) but I ran into an issue. It seems my test script executes twice on startup after boot as I get "hello" printed two times. Is this happening to you as well?

Offline

#11 2011-08-09 09:14:08

Guest
Guest

Re: How to autostart script AFTER bootup?

If you add the exec-line at the absolutely end of the file, then "hello" gets printed twice. I noticed this as well, though cannot explain it. But if you paste the line BEFORE [c]fi # logged[/c] as described above, it should run just once.

djego

#12 2011-08-09 10:11:02

nim108
Member
Registered: 2011-07-29
Posts: 12

Re: How to autostart script AFTER bootup?

Oh sorry, I didn't see that you said BEFORE fi # logged. Thank you sir. I guess I'll go this route for now until a better solution arrives. I was contemplating using Tiny Core because of these minor issues but it seems to be a lot harder to customize (especially since Slitaz has all these flavors you can start out with plus all the taz tools). I'm hoping version 4 addresses these issues and makes things like this doable without hacking away at main files like rcS.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.019 seconds, 7 queries executed - Memory usage: 1.55 MiB (Peak: 1.77 MiB) ]