• 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

Son of Beastie

Thanks: 875
Messages: 2,657

#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

Son of Beastie

Thanks: 875
Messages: 2,657

#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: 92
Messages: 126

#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

Daemon

Thanks: 657
Messages: 1,123

#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

Son of Beastie

Thanks: 875
Messages: 2,657

#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: 92
Messages: 126

#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.
 

Phishfry

Son of Beastie

Thanks: 875
Messages: 2,657

#10
Thanks to mrclksr as I stole his startup script and tweaked it for my use case.
I wanted Ascending notes for startup and Descending notes for exit. Just like monoWall used.
So I made two separate services. One for startup and next up one for shutdown.
/etc/rc.d/startup_sound
Code:
#!/bin/sh
# PROVIDE: startup_sound
# REQUIRE: LOGIN
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
# kld_list="speaker"
# startup_sound_enable (bool):  Set to NO by default.
#                               Set it to YES to enable startup_sound.
#

. /etc/rc.subr

name=startup_sound
required_modules="speaker"
start_cmd="play_startup_sound"
notes="FGABC"

rcvar=startup_sound_enable

load_rc_config $name

: ${startup_sound_enable:="NO"}

play_startup_sound()
{
   echo ${notes} > /dev/speaker
}

run_rc_command "$1"
 
Top