Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted
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

share|improve this answer
    
hmm... i can't edit the target script unfortunately. Is there an easy way to create a wrapper? –  ralph Apr 8 '11 at 9:47
    
Edited my post. –  Bart De Vos Apr 8 '11 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. –  ralph Apr 8 '11 at 10:12
    
Sorry, brainfart... Edit above –  Bart De Vos Apr 8 '11 at 10:16
    
cool, thanksss. –  ralph Apr 8 '11 at 11:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.