• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Beep on sucessful bootup

Phishfry

Daemon

Thanks: 573
Messages: 2,050

#1
I have several headless machines and I would like to have a beep "song" play on successful bootup.
Just like pfSense. On my APU's it beeps on BIOS POST test but i want more.

What is recommended? Do I need to make a rc.d daemon that starts last?

Any tutorials or similar threads? I can't find what I am looking for.
 

Phishfry

Daemon

Thanks: 573
Messages: 2,050

#3
I also want to add this to some Arm devices with a Piezo buzzer.
How would I assign GPIO pin with a piezo buzzer to /dev/speaker ?
 

mrclksr

Active Member

Thanks: 100
Messages: 118

#5
Do I need to make a rc.d daemon that starts last?
An rc script should do the job. Just make it start after LOGIN.

So kldload speaker and then echo "cdefgab" > /dev/speaker
Really nice! I couldn't resist:

Code:
#!/bin/sh

# PROVIDE: beep
# REQUIRE: LOGIN
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# beep_enable (bool):       Set to NO by default.
#                           Set it to YES to enable beep.
#

. /etc/rc.subr

name=beep
required_modules="speaker"
start_cmd="do_beep"
score="O0 G G G L8 D#. L16 A# L4 G L8 D#. L16 A# L2 G"

rcvar=beep_enable

load_rc_config $name

: ${beep_enable:="NO"}

do_beep()
{
   echo ${score} > /dev/speaker
}

run_rc_command "$1"
 

ralphbsz

Aspiring Daemon

Thanks: 322
Messages: 758

#6
An rc.d script is the cleaner solution. Would a single line in /etc/rc.local do the trick more easily? That file is executed a little bit too early, but pretty close.
 

Phishfry

Daemon

Thanks: 573
Messages: 2,050

#8
I am not sure which way to go yet.
Having a continually running daemon for a startup tone seems like a overkill for something that only runs on boot.
Can I have it close the daemon after running?

For a buzzer on Arm boards I could not find how to redirect gpio pin to /dev/speaker.
So I am using mono tone with beep-beep-beep by cycling power on the gpio pin in my rc.d script.
If I understand things right I could do a melody with the peizo buzzer if I used PWM. I don't need that level of sophistication.

What mechanisms exists if I wanted to do the reverse tone on shutdown?
 

mrclksr

Active Member

Thanks: 100
Messages: 118

#9
Having a continually running daemon for a startup tone seems like a overkill for something that only runs on boot.
Can I have it close the daemon after running?
The rc script I posted does what you want, if I understood your question correctly. It loads the speaker module if necessary, plays the motive of the Imperial March, and exits.