rc: refactor, add missing copyright header, rename

Scott committed this in 2005 so it is safe to assume the BSD
license fits...

See also: https://github.com/pfsense/pfsense/commit/fa94531eaba
This commit is contained in:
Franco Fichtner 2021-02-01 09:39:09 +01:00
parent c33af5b33f
commit 9121ee88ce
6 changed files with 56 additions and 30 deletions

2
plist
View File

@ -1667,9 +1667,9 @@
/usr/local/opnsense/www/themes/opnsense/build/images/favicon.png
/usr/local/opnsense/www/themes/opnsense/build/images/icon-logo.svg
/usr/local/sbin/3gstats.php
/usr/local/sbin/beep.sh
/usr/local/sbin/carp_service_status
/usr/local/sbin/configctl
/usr/local/sbin/opnsense-beep
/usr/local/sbin/opnsense-importer
/usr/local/sbin/opnsense-installer
/usr/local/sbin/opnsense-shell

View File

@ -1209,7 +1209,7 @@ function reset_factory_defaults($sync = true)
mwexec('/bin/rm -fr /conf/* /var/log/* /root/.history');
disable_security_checks();
mwexec('/usr/local/sbin/beep.sh stop');
mwexec('/usr/local/sbin/opnsense-beep stop');
/* as we go through a special case directly shut down */
$shutdown_cmd = '/sbin/shutdown -op now';

View File

@ -1,3 +1,3 @@
#!/bin/sh
/usr/local/sbin/beep.sh start
opnsense-beep start

View File

@ -1,3 +1,3 @@
#!/bin/sh
/usr/local/sbin/beep.sh stop
opnsense-beep stop

View File

@ -1,26 +0,0 @@
#!/bin/sh
COMMAND=${1}
NOTELENGTH=25
if [ -f /conf/config.xml ]; then
if [ "$(/usr/bin/grep -c disablebeep /conf/config.xml)" != "0" ]; then
exit;
fi
fi
if [ -c "/dev/speaker" ]; then
if [ "${COMMAND}" = "start" ]; then
/usr/local/bin/beep -p 500 $NOTELENGTH
/usr/local/bin/beep -p 400 $NOTELENGTH
/usr/local/bin/beep -p 600 $NOTELENGTH
/usr/local/bin/beep -p 800 $NOTELENGTH
/usr/local/bin/beep -p 800 $NOTELENGTH
elif [ "${COMMAND}" = "stop" ]; then
/usr/local/bin/beep -p 600 $NOTELENGTH
/usr/local/bin/beep -p 800 $NOTELENGTH
/usr/local/bin/beep -p 500 $NOTELENGTH
/usr/local/bin/beep -p 400 $NOTELENGTH
/usr/local/bin/beep -p 400 $NOTELENGTH
fi
fi

52
src/sbin/opnsense-beep Executable file
View File

@ -0,0 +1,52 @@
#!/bin/sh
# Copyright (C) 2020-2021 Franco Fichtner <franco@opnsense.org>
# Copyright (C) 2005 Scott Ullrich <sullrich@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
COMMAND=${1}
START="500 400 600 800 800"
STOP="600 800 500 400 400"
if [ ! -c "/dev/speaker" ]; then
exit
fi
if [ -f /conf/config.xml ]; then
if [ "$(/usr/bin/grep -c disablebeep /conf/config.xml)" != "0" ]; then
exit
fi
fi
case "${COMMAND}" in
start)
for NOTE in ${START}; do /usr/local/bin/beep -p ${NOTE} 25; done
;;
stop)
for NOTE in ${STOP}; do /usr/local/bin/beep -p ${NOTE} 25; done
;;
*)
;;
esac