Merge pull request #1442 from bergware/master

Miscellaneous updates and fixes
This commit is contained in:
tom mortensen
2023-10-08 08:56:33 -07:00
committed by GitHub
7 changed files with 62 additions and 49 deletions

View File

@@ -92,9 +92,31 @@ refresh(); // automatically include new ethernet ports
Array.prototype.same = function(){return this.sort().filter(function(v,i,o){return i&&v===o[i-1]?v:0;}).length;}
function prepareSettings(form) {
var metrics = [];
var metrics6 = [];
var bondnics = [], brnics = [];
for (var i=0,nic; nic=form.BONDNICS.options[i]; i++) {
if (nic.selected) {
bondnics.push(nic.value);
nic.selected = false;
}
}
nic = form.BONDNICS.options[0];
nic.value = bondnics.join(',');
nic.selected = true;
nic.disabled = false;
for (var i=0,nic; nic=form.BRNICS.options[i]; i++) {
if (nic.selected) {
brnics.push(nic.value);
nic.selected = false;
}
}
nic = form.BRNICS.options[0];
nic.value = form.BONDING.value=='yes' ? form.BONDNAME.value : brnics.join(',');
nic.selected = true;
nic.disabled = false;
if (brnics.length>1) form.BRSTP.value = 'yes';
if ($(form).find('input[name="#arg[1]"]').val()=='none') return true;
var metrics = [], metrics6 = [];
$(form).find('input[name^="METRIC:"]').each(function(){if($(this).val()>0) metrics.push($(this).val());});
$(form).find('input[name^="METRIC6:"]').each(function(){if($(this).val()>0) metrics6.push($(this).val());});
if (metrics.same() || metrics6.same()) {
@@ -123,31 +145,6 @@ function prepareSettings(form) {
return false;
}
}
var member = '';
for (var i=0,item; item=form.BONDNICS.options[i]; i++) {
if (item.selected) {
if (member.length) member += ',';
member += item.value;
item.selected = false;
}
}
item = form.BONDNICS.options[0];
item.value = member;
item.selected = true;
item.disabled = false;
var member = '';
for (var i=0,item; item=form.BRNICS.options[i]; i++) {
if (item.selected) {
if (member.length) member += ',';
member += item.value;
item.selected = false;
}
}
item = form.BRNICS.options[0];
item.value = form.BONDING.value=='yes' ? form.BONDNAME.value : member;
item.selected = true;
item.disabled = false;
if (member.indexOf(',')>0) form.BRSTP.value = 'yes';
$(form).find('select[name^="PROTOCOL:"]').each(function() {
var protocol = $(this).val() || 'ipv4';
var i = $(this).attr('name').split(':')[1];

View File

@@ -466,9 +466,9 @@ while (true) {
});
if (count($current_subpools) < count($subpools)) {
$current_subpools_list = str_replace("$pool~","", implode(',', $current_subpools));
$subPoolButton = "<input type='button' value='Add Subpool' style='margin:0' onclick='addSubpoolPopup(\"$pool\",\"$current_subpools_list\")'>";
$subPoolButton = "<input type='button' value='"._('Add Subpool')."' style='margin:0' onclick='addSubpoolPopup(\"$pool\",\"$current_subpools_list\")'>";
} else {
$subPoolButton = "<input type='button' value='Add Subpool' style='margin:0' disabled>";
$subPoolButton = "<input type='button' value='"._('Add Subpool')."' style='margin:0' disabled>";
}
$echo[$n] .= "<tr class='tr_last'><td></td><td colspan='8'>$subPoolButton</td><td></td></tr>";
}

View File

@@ -81,7 +81,7 @@ if ($run) {
}
// create configuration file for all available interfaces
$i = 0; $new = []; $new[] = "# Generated settings:";
$i = 0; $new = ["# Generated settings:"];
foreach ($ini as $name => $port) {
$bonding = $port['BONDING']=='yes';
$bridging = $port['BRIDGING']=='yes';
@@ -126,8 +126,8 @@ file_put_contents($cfg,implode("\r\n",$new)."\r\n");
// start interface with updated (new) configuration
// don't execute when only interface description has changed
if ($run) {
exec("/etc/rc.d/rc.inet1 {$ifname}_start >/dev/null 2>&1");
exec("/usr/local/sbin/create_network_ini $ifname >/dev/null 2>&1 &");
exec("/etc/rc.d/rc.inet1 {$ifname}_start &>/dev/null");
exec("/usr/local/sbin/create_network_ini $ifname &>/dev/null &");
update_wireguard($ifname);
}
exit(0);

View File

@@ -155,8 +155,9 @@ else
[[ $RETVAL -gt 0 ]] && abort "failed to remount $UNRAIDROOT r/w with return value $RETVAL"
fi
# invoke testing hook
if [[ -f /boot/config/rc.S.extra ]]; then
# invoke testing hook (only for test versions)
. /etc/unraid-version
if [[ -f /boot/config/rc.S.extra && $version =~ beta ]]; then
. /boot/config/rc.S.extra
fi
# and continue in separate script

View File

@@ -62,6 +62,9 @@
# - added error logging to syslog
# - replace logging for generic add-in module
# Adapted by Bergware for use in Unraid OS - August 2023
# - added interface carrier check when polling for DHCP server
# Bergware - modified for Unraid OS, October 2023
###########
@@ -149,11 +152,18 @@ set_mtu(){
fi
}
# function to wait for carrier of interface
carrier_up(){
for i in {1..5}; do
[[ $(cat $SYSTEM/$1/carrier 2>/dev/null) == 1 ]] && return 0 || sleep 1
done
return 1
}
# function to create bond interface
bond_up(){
[[ -d /proc/net/bonding ]] || modprobe bonding mode=${BONDING_MODE[$i]} miimon=${BONDING_MIIMON[$i]}
run ip link add name ${BONDNAME[$i]} type bond mode ${BONDING_MODE[$i]} miimon ${BONDING_MIIMON[$i]}
run ip link set ${BONDNAME[$i]} up
set_mtu ${BONDNAME[$i]}
PRIMARY=;
# loop thru assigned interfaces in bond
@@ -167,8 +177,6 @@ bond_up(){
fi
done
[[ -n $PRIMARY ]] && run ip link set name ${BONDNAME[$i]} type bond primary $PRIMARY
# delay to allow bond initialization
sleep 3
}
# function to delete bond interface
@@ -194,7 +202,6 @@ br_up(){
BRSTP[$i]=${BRSTP[$i]/no/0}
BRSTP[$i]=${BRSTP[$i]/yes/1}
run ip link add name $BRIDGE type bridge stp_state ${BRSTP[$i]} forward_delay ${BRFD[$i]}
run ip link set $BRIDGE up
# loop thru assigned interfaces in bridge
for BRNIC in ${BRNICS[$i]}; do
[[ $j -eq 0 ]] && BRIF=$BRNIC || BRIF=$BRNIC.${VLANID[$i,$j]}
@@ -347,14 +354,22 @@ ipaddr_up(){
[[ $IP == ipv4 ]] && DHCP_OPTIONS="$DHCP_OPTIONS -4"
[[ $IP == ipv6 ]] && DHCP_OPTIONS="$DHCP_OPTIONS -6"
[[ $IP != ipv4 && -n $PRIV6 && -d $CONF6/$IFACE ]] && echo $PRIV6 >$CONF6/$IFACE/use_tempaddr
log "polling up to 60 sec for DHCP server on interface $IFACE"
if ! run timeout 60 dhcpcd -w $DHCP_OPTIONS $IFACE; then
log "can't obtain IP address, continue polling in background on interface $IFACE"
if carrier_up $IFACE; then
# interface is UP
log "interface $IFACE is UP, polling up to 60 sec for DHCP $IP server"
if ! run timeout 60 dhcpcd -w $DHCP_OPTIONS $IFACE; then
log "can't obtain IP address, continue polling in background on interface $IFACE"
run dhcpcd -b $DHCP_OPTIONS $IFACE
fi
else
# interface is DOWN
log "interface $IFACE is DOWN, polling DHCP $IP server in background"
run dhcpcd -b $DHCP_OPTIONS $IFACE
fi
[[ $j -eq $((${VLANS[$i]}-1)) ]] && sleep 3
elif [[ $DHCP == no ]]; then
# bring up interface using static IP address
[[ carrier_up ]]
ipv6_addr 0 1
if [[ $IP != ipv6 ]]; then
[[ $j -eq 0 ]] && ADDR=${IPADDR[$i]} || ADDR=${IPADDR[$i,$j]}
@@ -461,6 +476,7 @@ if_up(){
[[ -n ${HWADDR[$i]} ]] && run ip link set $1 addr ${HWADDR[$i]}
set_mtu $1
fi
run ip link set $IFACE up
# set interface address
[[ $i -eq 0 && $j -eq 0 ]] && MAIN=1 || MAIN=
if [[ $IP == ipv4 ]]; then
@@ -490,7 +506,6 @@ if_up(){
DHCP_KEEP_RESOLV=$DHCP6_KEEP_RESOLV
ipaddr_up
fi
run ip link set $IFACE up
done
}

View File

@@ -49,7 +49,7 @@ dbus_stop(){
if ! dbus_running; then
REPLY="Already stopped"
else
run kill $(cat $PIDFILE 2>/dev/null)
run kill $(cat $PIDFILE)
# Just in case:
run killall dbus-daemon
rm -f $PIDFILE

View File

@@ -107,10 +107,10 @@ case "$1" in
cp --preserve=all --recursive --update /lib/udev/devices/* /dev 2>/dev/null
# Add any locally defined additional device nodes:
cp --preserve=all --recursive --update /etc/udev/devices/* /dev 2>/dev/null
log "Starting udevd: /sbin/udevd --daemon"
log "Starting udevd..."
run udevd --daemon
# Since udev is just now being started we want to use add events:
log "Triggering udev events: /sbin/udevadm trigger --action=add"
log "Triggering udev events..."
# Call udevtrigger and udevsettle to do the device configuration:
run udevadm trigger --type=subsystems --action=add
run udevadm trigger --type=devices --action=add
@@ -141,7 +141,7 @@ case "$1" in
NEW=$(grep -Po $MAC $RAM | sort)
# Bergware - set persistent rules of existing interfaces
grep -B2 "$NEW" $ROM | /usr/bin/fromdos >$RAM
udevadm control --reload
run udevadm control --reload
# Bergware - find the unique drivers currently in use by the interface(s)
DRIVERS=
for PORT in $(ls --indicator-style=none /sys/class/net | grep -P '^eth\d+$'); do
@@ -166,15 +166,15 @@ case "$1" in
# Update the hardware database index (/etc/udev/hwdb.bin), if possible:
if touch /etc/udev/testfile 2>/dev/null; then
rm -f /etc/udev/testfile
log "Updating hardware database index: udevadm hwdb --update"
log "Updating hardware database index..."
run udevadm hwdb --update
fi
# Since udevd is running, most of the time we only need change events:
log "Triggering udev events: udevadm trigger --action=change"
log "Triggering udev events..."
run udevadm trigger --type=subsystems --action=change
run udevadm trigger --type=devices --action=change
fi
udevadm settle --timeout=120
run udevadm settle --timeout=120
;;
'stop')
log "Stopping udevd is STRONGLY discouraged and not supported."