When is rc.local run?

hruodr

Well-Known Member

Reaction score: 46
Messages: 362

Excuse me the question, but I never understood why rc becomes always more complicated, non transparent and distateful (linux guys have, after many init levels, now a systemd).

As I see, /etc/rc.local is run by the script /etc/rc.d/local, but I do not know in what order the scripts in /etc/rc.d are run.

I just want a bell ringing three times after all booting is ready (because I want to boot without monitor/keyboard and then connect with internet).

Another question is, how to ring the bell. With the sh echo builtin should be with: echo -e "\a". Is there a better way?
 
OP
OP
H

hruodr

Well-Known Member

Reaction score: 46
Messages: 362

This means, rc.local is not the last script?

Is the solution to use brute force and add at the end of /etc/rc the commands for ringing bells?!

Is that the sense of this hypercomplicated rc system?!
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,698
Messages: 30,639

If you look at the order you'll see that networking is already active long before the last script gets executed. So there's no need to wait until the very last script is executed.
 
OP
OP
H

hruodr

Well-Known Member

Reaction score: 46
Messages: 362

/etc/rc ends with:

Code:
echo ''
date
exit 0
Some more echos after date, bell ringing echos, will not make a catastrophe.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,698
Messages: 30,639

Your solution is going to be removed next time you run an update.

It's actually quite simple. And easier to maintain, just create a /usr/local/etc/rc.d/beep:
Code:
#!/bin/sh

# REQUIRE: NETWORKING sshd
# PROVIDE: beep

. /etc/rc.subr

name="beep"
rcvar="${name}_enable"
start_cmd="beep_start"

: ${beep_enable:="NO"}

load_rc_config $name

beep_start () {
        echo -e "\a"
}

run_rc_command "$1"
Make sure it's executable: chmod +x /usr/local/etc/rc.d/beep.

This will run when NETWORKING and sshd are done, you should have network access by that time. Enable it with sysrc beep_enable="YES". I haven't actually tested this, besides just running it. I can't hear the server, it's in a datacenter a couple of kilometers away ;)
 
OP
OP
H

hruodr

Well-Known Member

Reaction score: 46
Messages: 362

Thanks. Good to get an idea of how this rc philosophy works. For patient people that only use FreeBSD may be recommendable to learn it. I like simplicity, even if it looks like less professional.
 

Elazar

Member

Reaction score: 23
Messages: 38

You could also ring a bell right at the login prompt.
Just add ^G to /etc/gettytab.

So for example, the default section in /etc/gettytab could then look like:
Code:
default:\
             :cb:ce:ck:lc:fd#1000:im=^G\r\n%s/%m (%h) (%t)\r\n\r\n:sp#1200:\
             :if=/etc/issue:
 
Top