2

I want to run a script when FreeBSD boots. I tried symlinking to it from /usr/local/etc/rc.d, but the script itself (myscript.sh) uses paths such as ./init-site.sh. These don't resolve correctly when invoked from /usr/local/etc/rc.d.

What would a simple script look like that would start myscript.sh and allow it's use of dot characters to correctly resolve to the script's own directory rather than /usr/local/etc/rc.d?

1 Answer 1

2
cd /actual/path/to/script 

On top of your script?

Or you could add your script to /etc/rc.local. That way the script will run form it's current location and you would not have to worry about the path.

/etc/rc.conf is normally a file that contains loads of variables, but you can call commands to run at runtime also. Just add your script at the bottom.

 ./actual/path/to/script/myscript.sh 

More info: FreeBSD Handbook

5
  • hmm... i can't edit the target script unfortunately. Is there an easy way to create a wrapper? Commented Apr 8, 2011 at 9:47
  • Edited my post. Commented Apr 8, 2011 at 9:53
  • I tried symlinking to the script from /usr/local/etc/rc.d but it can't resolve paths in ./xxx format. I can't copy the script into /usr/local/etc/rc.d or the same thing will happen. Commented Apr 8, 2011 at 10:12
  • Sorry, brainfart... Edit above Commented Apr 8, 2011 at 10:16
  • NEVER, I repeat, NEVER add script calls to rc.conf. This file is sourced many times during boot process and any operations with rc-scripts. There is old /etc/rc.local file for commands which need to be executed during boot (which is sourced by /etc/rc.d/local). Check rcorder /etc/rc.d/* to ensure that it called at the right time. Commented Apr 9, 2011 at 21:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.