scripts dutchification - batch 1

This commit is contained in:
bergware
2023-10-02 12:21:56 +02:00
parent 661fdf7a25
commit ef13df4ea6
3 changed files with 69 additions and 25 deletions

View File

@@ -19,8 +19,8 @@
# License along with avahi; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
# limetech - 'status' modified to exit with correct status
# limetech - 'start' modified to enable/disable ipv4/ipv6
# LimeTech - 'status' modified to exit with correct status
# LimeTech - 'start' modified to enable/disable ipv4/ipv6
# Bergware - added interface bind functionality
#
# LimeTech - modified for Unraid OS

View File

@@ -1,28 +1,33 @@
# /etc/rc.d/rc.inet1.conf
# Configuration file
#
# script: rc.inet1.conf
#
# This file contains the configuration settings for network interfaces.
# If USE_DHCP[interface] is set to "yes", this overrides any other settings.
# If you don't have an interface, leave the settings null ("").
#
# You can configure network interfaces other than eth0,eth1... by setting
# IFNAME[interface] to the interface's name. If IFNAME[interface] is unset
# or empty, it is assumed you're configuring eth<interface>.
# =============================================================================
#
# LimeTech - modified for Unraid OS
# Bergware - modified for Unraid OS, October 2023
# change this to "yes" for debugging output to stdout.
# Unfortunately, /sbin/hotplug seems to disable stdout so you'll only see debugging output when rc.inet1 is called directly.
# change this to "yes" for debugging output to stdout. Unfortunately,
# /sbin/hotplug seems to disable stdout so you'll only see debugging output
# when rc.inet1 is called directly.
DEBUG_ETH_UP=no
DHCP_DEBUG=no
# bergware - use associative format for multi-dimensional arrays
# Bergware - use associative format for multi-dimensional arrays
declare -A VLANID USE_DHCP IPADDR NETMASK GATEWAY METRIC USE_DHCP6 IPADDR6 NETMASK6 GATEWAY6 METRIC6 PRIVACY6 DESCRIPTION PROTOCOL
# limetech - read settings from config file
cfg=/boot/config/network.cfg
if [[ -s $cfg ]]; then
source <(/usr/bin/fromdos < $cfg)
# LimeTech - read settings from config file
CFG=/boot/config/network.cfg
if [[ -s $CFG ]]; then
. <(fromdos <$CFG)
else
# default legacy settings
IPADDR=
NETMASK=
GATEWAY=
@@ -69,12 +74,28 @@ if [[ $DHCP6_KEEPRESOLV == yes ]]; then
[[ $DHCP_KEEPRESOLV == no ]] && cp -f $RESOLV $RESOLV.tail
fi
make_cfg(){
[[ -s $CFG ]] && return
for VAR in "$@"; do
if [[ ${VAR:0:1} == '#' ]]; then
# add comment
echo -ne "$VAR\r\n" >>$CFG
elif [[ ${VAR: -1} == '#' ]]; then
# add global variable
VAR=${VAR::-1}
echo -ne "$VAR=\"${!VAR}\"\r\n" >>$CFG
else
# add variable per interface
echo -ne "$VAR[0]=\"${!VAR}\"\r\n" >>$CFG
fi
done
}
if [[ -n $SYSNICS ]]; then
# bergware - set number of interfaces as present in the system
# Bergware - set number of interfaces as present in the system
MAXNICS=$SYSNICS
else
# bergware - legacy configuration of first interface
MAXNICS=1
# Bergware - legacy configuration of first interface
if [[ $BONDING == yes && $BRIDGING == yes ]]; then
# both bonding and bridging selected
BONDNAME=bond0
@@ -86,6 +107,7 @@ else
BRSTP=no
BRFD=0
IFNAME=$BRNAME
SETTINGS="BONDNAME BONDNICS BONDING_MODE BONDING_MIIMON BRNAME BRNICS BRSTP BRFD"
elif [[ $BONDING == yes ]]; then
# bonding selected
BONDNAME=bond0
@@ -93,6 +115,7 @@ else
BONDING_MODE=${BONDING_MODE:-1}
BONDING_MIIMON=${BONDING_MIIMON:-100}
IFNAME=$BONDNAME
SETTINGS="BONDNAME BONDNICS BONDING_MODE BONDING_MIIMON"
elif [[ $BRIDGING == yes ]]; then
# bridging selected
BRNAME=br0
@@ -100,8 +123,12 @@ else
BRSTP=no
BRFD=0
IFNAME=$BRNAME
SETTINGS="BRNAME BRNICS BRSTP BRFD"
else
# normal interface
IFNAME=eth0
fi
SYSNICS=1
MAXNICS=$SYSNICS
make_cfg "# Generated settings:" $SETTINGS IFNAME USE_DHCP DHCP_KEEPRESOLV# SYSNICS#
fi

View File

@@ -1,21 +1,36 @@
#!/bin/sh
#!/bin/bash
#
# script: rc.inetd
# Start/stop/restart inetd, the BSD Internet super-daemon.
# Start inetd:
# LimeTech - modified for Unraid OS
# Bergware - modified for Unraid OS, October 2023
# run & log functions
. /etc/rc.d/rc.runlog
DAEMON="Internet daemon"
inetd_start() {
if [ -x /usr/sbin/inetd ]; then
echo "Starting Internet super-server daemon: /usr/sbin/inetd"
/usr/sbin/inetd
log "Starting $DAEMON..."
if [[ -x /usr/sbin/inetd ]]; then
run /usr/sbin/inetd
REPLY="Started"
else
REPLY="Failed"
fi
log "$DAEMON... $REPLY."
}
# Stop inetd:
inetd_stop() {
killall inetd
log "Stopping $DAEMON..."
killall inetd 2>/dev/null
log "$DAEMON... Stopped."
}
# Restart inetd:
inetd_restart() {
log "Restarting $DAEMON..."
inetd_stop
sleep 1
inetd_start
@@ -32,5 +47,7 @@ case "$1" in
inetd_restart
;;
*)
echo "usage $0 start|stop|restart"
echo "Usage: $BASENAME start|stop|restart"
exit 1
esac
exit 0