run script on boot

4 posts / 0 new
Last post
#1 Tue, 2016-03-15 16:56
rpereyra
  • rpereyra's picture
  • Offline
  • Last seen: 2 years 2 weeks ago
  • Joined: 2016-03-15

Hi

How I can run a script on boot.

I've set a lot of network and iptables rules in a script and want to run on boot.

Thanks

roberto

Sat, 2016-03-26 06:59
roger.newman
  • roger.newman's picture
  • Offline
  • Last seen: 1 year 11 months ago
  • Joined: 2016-03-26

Hi rpereyra,

you could use the "local service" if you are not going to write your own one.
Add your scripts to the /etc/local.d/ and add the service to the desired run-level.

e.g.

rc-update add local default


More details can be found in the README in the same directory.

cat /etc/local.d/README
This directory should contain programs or scripts which are to be run
when the local service is started or stopped.
 
If a file in this directory is executable and it has a .start extension,
it will be run when the local service is started. If a file is
executable and it has a .stop extension, it will be run when the local
service is stopped.
 
All files are processed in lexical order.
 
Keep in mind that files in this directory are processed sequencially,
and the local service is not considered started or stopped until
everything is processed, so if you have a process which takes a long
time to run, it can delay your boot or shutdown processing.


Regards,

Roger Newman

Thu, 2018-03-22 05:02 (Reply to #2)
herald
  • herald's picture
  • Offline
  • Last seen: 1 week 3 days ago
  • Joined: 2017-11-29

That's a good method, thank you!

Wed, 2018-03-28 12:17
jodumont
  • jodumont's picture
  • Offline
  • Last seen: 16 hours 46 min ago
  • Joined: 2018-02-06

To manage the dependency related to others process
such as open a LUKS crypt before whatever else

https://wiki.gentoo.org/wiki/OpenRC#Dependency_behavior

Log in or register to post comments