Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
MaximilianVINCENT

Start program upon boot?

Question

I have a program at /usr/bin/cc.lua that I want to run after booting is complete. If possible, add an argument as well (i.e. cc v )

 

I tried cp /usr/bin/cc.lua /autorun.lua and nothing.

 

Then tried adding

  •    cc
  •    /usr/bin/cc.lua
  •    os.execute("cc.lua v")  -- really expected this one to work
  •    os.execute(cc.lua)
  •    os.shell(cc.lua)
  •    os.shell("cc.lua v")

  to a clean autorun.lua and still nothing. Grr.

 

What is the correct way to do this?

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

The proper way to do this would be using the rc system (/etc/rc.cfg and /etc/rc.d/). I can't find any documentation on how to use it, so here's a rough guide:

  1. In the /etc/rc.d/ folder, create a new Lua script (e. g. autorun_cc.lua).
  2. The script must define a start function that can take at least one argument. That function is executed when the system is started, and can contain whatever code you want. In your case that would probably be os.execute("cc.lua v").
  3. Now edit the /etc/rc.cfg config file. Add the name of the script (e. g. "autorun_cc") to the "enabled" list.
  4. Done.

This is only the most basic thing you can do with the rc system. If you want to see how it works internally, check the /boot/99_rc.lua and /lib/rc.lua files.

 

FYI, the autorun.lua is only executed when freshly connecting a storage device. (Might even only work on floppies.) It does nothing on the boot drive as far as I'm aware.

Link to post
Share on other sites
  • 0

autorun.lua does work in root, had it print "Hi there" and show me the error caused by os.execute and sleep for a few seconds. It also works on other media, commonly to mount it to a certain location on the root filesystem (/home, for instance).

 

I am going on vacation for a while, when I get back I will be trying out the rc system. Thank you!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.