From 755d6577f720f169a35aafdb27c0018aeb8032c5 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 06:53:43 +0200 Subject: [PATCH 001/239] rc scripts: use common library source Library file is imported by each rc script, which has the common functions This makes maintenance easier --- .../plugins/dynamix/scripts/show_interfaces | 92 +------- etc/rc.d/rc.avahidaemon | 125 +---------- etc/rc.d/rc.library.source | 202 ++++++++++++++++++ etc/rc.d/rc.nfsd | 127 +---------- etc/rc.d/rc.nginx | 130 +---------- etc/rc.d/rc.ntpd | 130 +---------- etc/rc.d/rc.rpc | 120 +---------- etc/rc.d/rc.samba | 132 +----------- etc/rc.d/rc.sshd | 125 +---------- 9 files changed, 244 insertions(+), 939 deletions(-) create mode 100644 etc/rc.d/rc.library.source diff --git a/emhttp/plugins/dynamix/scripts/show_interfaces b/emhttp/plugins/dynamix/scripts/show_interfaces index 6991b2bc9..a3eddafc1 100755 --- a/emhttp/plugins/dynamix/scripts/show_interfaces +++ b/emhttp/plugins/dynamix/scripts/show_interfaces @@ -1,99 +1,21 @@ #!/bin/bash +SCRIPT="show" NETWORK_INI="/var/local/emhttp/network.ini" SYSTEM="/sys/class/net" EXTRA="/boot/config/network-extra.cfg" -link() { - grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth -} +# library functions +. /etc/rc.d/rc.library.source -zero() { - data=; - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 ]] && data=$1 - done - echo $data -} - -show() { - case $# in - 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; - 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - esac -} - -remove() { - [[ $# -eq 0 ]] && return - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 ]] && unset 'bind[i]' - done -} - -extra() { - source <(/usr/bin/fromdos <$EXTRA) - for net in $include_interfaces; do - if [[ -z ${net//[^.:]} ]]; then - # net is an interface name, validate - [[ -n $(show dev $net) && -z $(zero $net) ]] && bind+=($net) - else - # net is an IP address, convert to name - net=$(show $net) - [[ -n $net && -z $(zero $net) ]] && bind+=($net) - fi - done - for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} ]]; then - # net is an interface name, remove - remove $net - else - # net is an IP address, convert to name and remove - remove $(show $net) - fi - done -} - -bind=(); -if [[ -f $NETWORK_INI ]]; then - # get interface and vlan configurations - for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do - # main interface - if [[ -e $SYSTEM/$eth ]]; then - sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth - net=$eth - [[ $(link BONDING) == yes ]] && net=${eth/eth/bond} - [[ $(link BRIDGING) == yes ]] && net=${eth/eth/br} - net4=$(link IPADDR:0) - net6=$(link IPADDR6:0) - [[ -n $net4 || -n $net6 ]] && bind+=($net) - if [[ $(link TYPE) == trunk ]]; then - # vlan interface - for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do - net4=$(link IPADDR:$vlan) - net6=$(link IPADDR6:$vlan) - [[ -n $net4 || -n $net6 ]] && bind+=($net.$vlan) - done - fi - fi - done - # add active WG tunnels - for wg in $(wg show interfaces); do - net4=$(show -4 dev $wg) - net6=$(show -6 dev $wg) - [[ -n $net4 || -n $net6 ]] && bind+=($wg) - done - # add user defined interfaces - [[ -f $EXTRA ]] && extra - # remove temporary file - rm -f $NETWORK_INI.eth -fi -bind=${bind[@]} -if [[ $1 == ip ]]; then +# include IP addresses? +if check && [[ $1 == ip ]]; then ip=() for net in $bind; do ip+=("$net#[$(show -4 dev $net)#$(show -6 dev $net)]") done bind=${ip[@]} fi + +# return list echo ${bind// /, } diff --git a/etc/rc.d/rc.avahidaemon b/etc/rc.d/rc.avahidaemon index 8486af637..6b3a9b327 100755 --- a/etc/rc.d/rc.avahidaemon +++ b/etc/rc.d/rc.avahidaemon @@ -1,5 +1,5 @@ #!/bin/bash - +# # This file is part of avahi. # # avahi is free software; you can redistribute it and/or modify it @@ -14,8 +14,7 @@ # # You should have received a copy of the GNU Lesser General Public # License along with avahi; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. +# 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 @@ -23,6 +22,7 @@ # Start/stop/restart the avahi daemon: +SCRIPT="avahi" PATH=/sbin:/bin:/usr/sbin:/usr/bin DESC="Avahi mDNS/DNS-SD Daemon" AVAHI="/usr/sbin/avahi-daemon" @@ -32,49 +32,8 @@ NETWORK_INI="/var/local/emhttp/network.ini" SYSTEM="/sys/class/net" EXTRA="/boot/config/network-extra.cfg" -IPv() { - type=${1//[^:]} - [[ ${#type} -le ${2:-0} ]] && echo 4 || echo 6 -} - -scan() { - grep -Pom1 "^$1=\"?\K[^\"]+" $2 -} - -link() { - grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth -} - -this() { - grep -Pom1 "^$1=\K.*" $CONF -} - -take() { - data=; - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 || ${1:0:7} == 169.254 || ${1:0:4} == fe80 ]] && data=$1 - done - echo $data -} - -good() { - [[ -n $1 && ${1:0:7} != 169.254 && ${1:0:4} != fe80 ]] && echo $1 -} - -show() { - case $# in - 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; - 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - esac -} - -remove() { - [[ $# -eq 0 ]] && return - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 ]] && unset 'bind[i]' - done -} +# library functions +. /etc/rc.d/rc.library.source allow() { sed -ri "s/^#?(allow-interfaces)=.*/\1=$*/" $CONF @@ -88,80 +47,6 @@ disable() { sed -ri "s/^#?(use-$1)=.*/\1=no/" $CONF } -extra() { - source <(/usr/bin/fromdos <$EXTRA) - for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, validate - [[ -n $(show dev $net) && -z $(take $net) ]] && bind+=($net) - else - # net is an IP address, convert to name - net=$(show $net) - [[ -n $net && -z $(take $net) ]] && bind+=($net) - fi - done - for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, remove - remove $net - else - # net is an IP address, convert to name and remove - remove $(show $net) - fi - done -} - -check() { - # quick check - [[ -n $bind ]] && return 0; - # preset return values - reply=1; bind=(); ipv4=no; ipv6=no; - if [[ -f $NETWORK_INI ]]; then - # get interface and vlan configurations - for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do - # main interface - if [[ -e $SYSTEM/$eth ]]; then - sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth - net=$eth - [[ $(link BONDING) == yes ]] && net=${eth/eth/bond} - [[ $(link BRIDGING) == yes ]] && net=${eth/eth/br} - net4=$(link IPADDR:0) - net6=$(link IPADDR6:0) - [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($net) - [[ -n $(good $net4) ]] && ipv4=yes - [[ -n $(good $net6) ]] && ipv6=yes - if [[ $(link TYPE) == trunk ]]; then - # vlan interface - for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do - net4=$(link IPADDR:$vlan) - net6=$(link IPADDR6:$vlan) - [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($net.$vlan) - [[ -n $(good $net4) ]] && ipv4=yes - [[ -n $(good $net6) ]] && ipv6=yes - done - fi - fi - done - # add active WG tunnels - for wg in $(wg show interfaces); do - net4=$(show -4 dev $wg) - net6=$(show -6 dev $wg) - [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($wg) - [[ -n $(good $net4) ]] && ipv4=yes - [[ -n $(good $net6) ]] && ipv6=yes - done - # add user defined interfaces - [[ -f $EXTRA ]] && extra - # convert array to string with commas - bind=${bind[@]} - bind=${bind// /,} - reply=0 - # remove temporary file - rm -f $NETWORK_INI.eth - fi - return $reply -} - avahid_start() { if [[ -f $NETWORK_INI ]]; then # bind avahi service diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source new file mode 100644 index 000000000..ac6b9f0c1 --- /dev/null +++ b/etc/rc.d/rc.library.source @@ -0,0 +1,202 @@ +# /etc/rc.d/rc.library +# used by nfsd, ntpd, rpc, samba, nginx, sshd, avahidaemon, show_interfaces + +this() { + case $SCRIPT in +'avahi') + grep -Pom1 "^$1=\K.*" $CONF + ;; +'samba') + grep -Pom1 "^$1 = \K.*" $CONF + ;; +'ntpd'|'sshd') + grep -Po "^$1 \K.*" $CONF|tr '\n' ' '|sed 's/ $//' + ;; +'nfsd') + grep -Pom1 "^RPC_NFSD_OPTS=\"$OPTIONS \K[^\"]+" $NFS + ;; +'rpc') + grep -Pom1 "^RPCBIND_OPTS=\"\K[^\"]+" $RPC + ;; +'nginx') + now=(); + for addr in $(awk '$1=="listen" && $2~/^[0-9]|\[/ && $0~/http2; #.*$/{print $2}' $SERVERS 2>/dev/null); do + # extract ipv4 / ipv6 address + [[ $(IPv $addr 1) == 4 ]] && addr=${addr%:*} || addr=${addr#*[} addr=${addr%]*} + now+=($addr) + done + # return addresses + echo ${now[@]} + ;; + esac +} + +IPv() { + type=${1//[^:]} + [[ ${#type} -le ${2:-0} ]] && echo 4 || echo 6 +} + +scan() { + grep -Pom1 "^$1=\"?\K[^\"]+" $2 +} + +link() { + grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth +} + +take() { + data=; + for i in ${!bind[@]}; do + [[ ${bind[$i]} == $1 || ${1:0:7} == 169.254 || ${1:0:4} == fe80 ]] && data=$1 + done + echo $data +} + +good() { + [[ -n $1 && ${1:0:7} != 169.254 && ${1:0:4} != fe80 ]] && echo $1 +} + +show() { + case $# in + 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; + 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; + 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; + esac +} + +remove() { + [[ $# -eq 0 ]] && return + for i in ${!bind[@]}; do + [[ ${bind[$i]} == $1 ]] && unset 'bind[i]' + done +} + +extra() { + source <(/usr/bin/fromdos <$EXTRA) + case $SCRIPT in + 'avahi'|'show') + for net in $include_interfaces; do + if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + # net is an interface name, validate + [[ -n $(show dev $net) && -z $(take $net) ]] && bind+=($net) + else + # net is an IP address, convert to name + net=$(show $net) + [[ -n $net && -z $(take $net) ]] && bind+=($net) + fi + done + for net in $exclude_interfaces; do + if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + # net is an interface name, remove + remove $net + else + # net is an IP address, convert to name and remove + remove $(show $net) + fi + done + ;; + *) + for net in $include_interfaces; do + if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + # net is an interface name, get IP addresses + net4=$(show -4 dev $net) + net6=$(show -6 dev $net) + else + # net is an IP address, validate + net4=$(show -4 to $net) + net6=$(show -6 to $net) + fi + [[ -n $net4 && -z $(take $net4) ]] && bind+=($net4) + [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) + done + for net in $exclude_interfaces; do + if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + # net is an interface name, get IP addresses + remove $(show -4 dev $net) + remove $(show -6 dev $net) + else + # net is an IP address + remove $(show to $net) + fi + done + ;; + esac +} + +check() { + # quick check + [[ -n $bind ]] && return 0; + # preset return values + reply=1; bind=(); ipv4=no; ipv6=no; + if [[ -f $NETWORK_INI ]]; then + # add interfaces and vlans + for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do + if [[ -e $SYSTEM/$eth ]]; then + # main interface + sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth + net4=$(link IPADDR:0) + net6=$(link IPADDR6:0) + if [[ $SCRIPT == avahi || $SCRIPT == show ]]; then + net=$eth + [[ $(link BONDING) == yes ]] && net=${eth/eth/bond} + [[ $(link BRIDGING) == yes ]] && net=${eth/eth/br} + [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($net) + [[ -n $(good $net4) ]] && ipv4=yes + [[ -n $(good $net6) ]] && ipv6=yes + else + [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) + [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($net6) + fi + if [[ $(link TYPE) == trunk ]]; then + # vlan interface + for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do + net4=$(link IPADDR:$vlan) + net6=$(link IPADDR6:$vlan) + if [[ $SCRIPT == avahi || $SCRIPT == show ]]; then + [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($net.$(link VLANID:$vlan)) + [[ -n $(good $net4) ]] && ipv4=yes + [[ -n $(good $net6) ]] && ipv6=yes + else + [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) + [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($net6) + fi + done + fi + fi + done + # add active WG tunnels + for wg in $(wg show interfaces); do + net4=$(show -4 dev $wg) + net6=$(show -6 dev $wg) + if [[ $SCRIPT == avahi || $SCRIPT == show ]]; then + [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($wg) + [[ -n $(good $net4) ]] && ipv4=yes + [[ -n $(good $net6) ]] && ipv6=yes + else + [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) + [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($net6) + fi + done + # add loopback interface + if [[ "nfsd ntpd rpc" =~ $SCRIPT ]]; then + [[ $ipv4 == yes ]] && bind+=(127.0.0.1) + [[ $ipv6 == yes ]] && bind+=(::1) + fi + # add user defined interfaces + [[ -f $EXTRA ]] && extra + if [[ $SCRIPT == sshd ]]; then + # bind stays array + bind=(${bind[@]}) + [[ $ipv4 == yes && $ipv6 == no ]] && family=inet + [[ $ipv6 == yes && $ipv4 == no ]] && family=inet6 + else + # convert array to string + bind=${bind[@]} + [[ $SCRIPT == avahi ]] && bind=${bind// /,} + fi + reply=0 + # remove temporary file + rm -f $NETWORK_INI.eth + fi + return $reply +} diff --git a/etc/rc.d/rc.nfsd b/etc/rc.d/rc.nfsd index 0aae73422..7f315ee12 100755 --- a/etc/rc.d/rc.nfsd +++ b/etc/rc.d/rc.nfsd @@ -9,6 +9,7 @@ # # bergware - added interface bind functionality +SCRIPT="nfsd" NFSD="/usr/sbin/rpc.nfsd" EXPORTFS="/usr/sbin/exportfs" RQUOTAD="/usr/sbin/rpc.rquotad" @@ -21,123 +22,8 @@ NETWORK_INI="/var/local/emhttp/network.ini" SYSTEM="/sys/class/net" EXTRA="/boot/config/network-extra.cfg" -IPv() { - type=${1//[^:]} - [[ ${#type} -le ${2:-0} ]] && echo 4 || echo 6 -} - -scan() { - grep -Pom1 "^$1=\"?\K[^\"]+" $2 -} - -link() { - grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth -} - -this() { - grep -Pom1 "^RPC_NFSD_OPTS=\"$OPTIONS \K[^\"]+" $NFS -} - -take() { - data=; - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 || ${1:0:7} == 169.254 || ${1:0:4} == fe80 ]] && data=$1 - done - echo $data -} - -good() { - [[ -n $1 && ${1:0:7} != 169.254 && ${1:0:4} != fe80 ]] && echo $1 -} - -show() { - case $# in - 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; - 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - esac -} - -remove() { - [[ $# -eq 0 ]] && return - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 ]] && unset 'bind[i]' - done -} - -extra() { - source <(/usr/bin/fromdos <$EXTRA) - for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - net4=$(show -4 dev $net) - net6=$(show -6 dev $net) - else - # net is an IP address, validate - net4=$(show -4 to $net) - net6=$(show -6 to $net) - fi - [[ -n $net4 && -z $(take $net4) ]] && bind+=($net4) - [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) - done - for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - remove $(show -4 dev $net) - remove $(show -6 dev $net) - else - # net is an IP address - remove $(show to $net) - fi - done -} - -check() { - # quick check - [[ -n $bind ]] && return 0; - # preset return values - reply=1; bind=(); - if [[ -f $NETWORK_INI ]]; then - # add interfaces and vlans - for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do - if [[ -e $SYSTEM/$eth ]]; then - # main interface - sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth - net4=$(link IPADDR:0) - net6=$(link IPADDR6:0) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - if [[ $(link TYPE) == trunk ]]; then - # vlan interface - for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do - net4=$(link IPADDR:$vlan) - net6=$(link IPADDR6:$vlan) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - done - fi - fi - done - # add active WG tunnels - for wg in $(wg show interfaces); do - net4=$(show -4 dev $wg) - net6=$(show -6 dev $wg) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - done - # add loopback interface - [[ $ipv4 == yes ]] && bind+=(127.0.0.1) - [[ $ipv6 == yes ]] && bind+=(::1) - # add user defined interfaces - [[ -f $EXTRA ]] && extra - # convert array to string - bind=${bind[@]} - reply=0 - # remove temporary file - rm -f $NETWORK_INI.eth - fi - return $reply -} +# library functions +. /etc/rc.d/rc.library.source # get bind addresses if check && [[ -n $bind ]]; then @@ -162,14 +48,12 @@ nfsd_start() { if [[ ! -r /proc/1/net/rpc/nfsd ]]; then /sbin/modprobe nfsd 2>/dev/null fi - # mount the nfsd filesystem: if awk '$NF == "nfsd"' /proc/filesystems | grep -q . ; then if ! awk '$3 == "nfsd" && $2 == "/proc/fs/nfs"' /proc/mounts | grep -q . ; then /sbin/mount -t nfsd nfsd /proc/fs/nfs 2>/dev/null fi fi - # if basic RPC services are not running, start them: if ! ps axc | grep -q rpc.statd; then if [[ -r /etc/rc.d/rc.rpc ]]; then @@ -181,27 +65,22 @@ nfsd_start() { exit 1 fi fi - echo "Starting NFS server daemons:" - if [[ -x $EXPORTFS ]]; then echo " $EXPORTFS -r" $EXPORTFS -r 2>/dev/null fi - if [[ -x $RQUOTAD ]]; then [[ -n $RPC_RQUOTAD_PORT ]] && RPC_RQUOTAD_OPTS="$RPC_RQUOTAD_OPTS -p $RPC_RQUOTAD_PORT" echo " $RQUOTAD $RPC_RQUOTAD_OPTS" $RQUOTAD $RPC_RQUOTAD_OPTS 2>/dev/null fi - # start nfsd servers - 8 if not set extrawise (an old Sun standard): if [[ -x $NFSD ]]; then [[ -z $RPC_NFSD_COUNT ]] && RPC_NFSD_COUNT=8 echo " $NFSD $RPC_NFSD_OPTS $RPC_NFSD_COUNT" $NFSD $RPC_NFSD_OPTS $RPC_NFSD_COUNT 2>/dev/null fi - if [[ -x $MOUNTD ]]; then [[ -n $RPC_MOUNTD_PORT ]] && RPC_MOUNTD_OPTS="$RPC_MOUNTD_OPTS -p $RPC_MOUNTD_PORT" echo " $MOUNTD $RPC_MOUNTD_OPTS" diff --git a/etc/rc.d/rc.nginx b/etc/rc.d/rc.nginx index 8b762cd86..5b90474b7 100755 --- a/etc/rc.d/rc.nginx +++ b/etc/rc.d/rc.nginx @@ -15,6 +15,7 @@ # WANFQDN 'www.hash.unraid.net' (legacy) # WG0FQDN 'wg0-ip.hash.myunraid.net' (wildcard cert) +SCRIPT="nginx" NGINX="/usr/sbin/nginx" PID="/var/run/nginx.pid" SSL="/boot/config/ssl" @@ -33,10 +34,8 @@ EXTRA="/boot/config/network-extra.cfg" # hold server names SERVER_NAMES=() -# read settings -if [[ -a $IDENT ]]; then - source <(/usr/bin/fromdos <$IDENT) -fi +# read Unraid settings +[[ -r $IDENT ]] && . <(/usr/bin/fromdos <$IDENT) # preset default values [[ -z $START_PAGE ]] && START_PAGE=Main @@ -54,132 +53,13 @@ if ! find /boot/config/*.key &>/dev/null; then START_PAGE="Tools/Registration" fi -IPv() { - type=${1//[^:]} - [[ ${#type} -le ${2:-0} ]] && echo 4 || echo 6 -} - -scan() { - grep -Pom1 "^$1=\"?\K[^\"]+" $2 -} - -link() { - grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth -} - -this() { - now=(); - for addr in $(awk '$1=="listen" && $2~/^[0-9]|\[/ && $0~/http2;$/{print $2}' $SERVERS 2>/dev/null); do - # extract ipv4 / ipv6 address - [[ $(IPv $addr 1) == 4 ]] && addr=${addr%:*} || addr=${addr#*[} addr=${addr%]*} - now+=($addr) - done - # return addresses - echo ${now[@]} -} - -take() { - data=; - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 || ${1:0:7} == 169.254 || ${1:0:4} == fe80 ]] && data=$1 - done - echo $data -} - -good() { - [[ -n $1 && ${1:0:7} != 169.254 && ${1:0:4} != fe80 ]] && echo $1 -} - -show() { - case $# in - 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; - 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - esac -} - -remove() { - [[ $# -eq 0 ]] && return - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 ]] && unset 'bind[i]' - done -} +# library functions +. /etc/rc.d/rc.library.source fqdn() { echo ${CERTNAME/'*'/${1//[.:]/-}} } -extra() { - source <(/usr/bin/fromdos <$EXTRA) - for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - net4=$(show -4 dev $net) - net6=$(show -6 dev $net) - else - # net is an IP address, validate - net4=$(show -4 to $net) - net6=$(show -6 to $net) - fi - [[ -n $net4 && -z $(take $net4) ]] && bind+=($net4) - [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) - done - for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - remove $(show -4 dev $net) - remove $(show -6 dev $net) - else - # net is an IP address - remove $(show to $net) - fi - done -} - -check() { - # quick check - [[ -n $bind ]] && return 0; - # preset return values - reply=1; bind=(); ipv4=no; ipv6=no; - if [[ -f $NETWORK_INI ]]; then - # add interfaces and vlans - for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do - if [[ -e $SYSTEM/$eth ]]; then - # main interface - sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth - net4=$(link IPADDR:0) - net6=$(link IPADDR6:0) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - if [[ $(link TYPE) == trunk ]]; then - # vlan interface - for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do - net4=$(link IPADDR:$vlan) - net6=$(link IPADDR6:$vlan) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - done - fi - fi - done - # add active WG tunnels - for wg in $(wg show interfaces); do - net4=$(show -4 dev $wg) - net6=$(show -6 dev $wg) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - done - # add user defined interfaces - [[ -f $EXTRA ]] && extra - # convert array to string - bind=${bind[@]} - reply=0 - # remove temporary file - rm -f $NETWORK_INI.eth - fi - return $reply -} - # create listening ports listen() { t=' ' diff --git a/etc/rc.d/rc.ntpd b/etc/rc.d/rc.ntpd index 32c45361f..9f95795fd 100755 --- a/etc/rc.d/rc.ntpd +++ b/etc/rc.d/rc.ntpd @@ -4,6 +4,7 @@ # limetech - modified to initialize ntp.conf file from config # bergware - added interface bind functionality +SCRIPT="ntpd" NTPD="/usr/sbin/ntpd" OPTIONS="-g -u ntp:ntp" CONF="/etc/ntp.conf" @@ -13,123 +14,8 @@ NETWORK_INI="/var/local/emhttp/network.ini" SYSTEM="/sys/class/net" EXTRA="/boot/config/network-extra.cfg" -IPv() { - type=${1//[^:]} - [[ ${#type} -le ${2:-0} ]] && echo 4 || echo 6 -} - -scan() { - grep -Pom1 "^$1=\"?\K[^\"]+" $2 -} - -link() { - grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth -} - -this() { - grep -Po "^$1 \K.*" $CONF|tr '\n' ' '|sed 's/ $//' -} - -take() { - data=; - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 || ${1:0:7} == 169.254 || ${1:0:4} == fe80 ]] && data=$1 - done - echo $data -} - -good() { - [[ -n $1 && ${1:0:7} != 169.254 && ${1:0:4} != fe80 ]] && echo $1 -} - -show() { - case $# in - 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; - 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - esac -} - -remove() { - [[ $# -eq 0 ]] && return - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 ]] && unset 'bind[i]' - done -} - -extra() { - source <(/usr/bin/fromdos <$EXTRA) - for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - net4=$(show -4 dev $net) - net6=$(show -6 dev $net) - else - # net is an IP address, validate - net4=$(show -4 to $net) - net6=$(show -6 to $net) - fi - [[ -n $net4 && -z $(take $net4) ]] && bind+=($net4) - [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) - done - for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - remove $(show -4 dev $net) - remove $(show -6 dev $net) - else - # net is an IP address - remove $(show to $net) - fi - done -} - -check() { - # quick check - [[ -n $bind ]] && return 0; - # preset return values - reply=1; bind=(); ipv4=no; ipv6=no; - if [[ -f $NETWORK_INI ]]; then - # get interface and vlan configurations - for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do - if [[ -e $SYSTEM/$eth ]]; then - # main interface - sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth - net4=$(link IPADDR:0) - net6=$(link IPADDR6:0) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - # vlan interface - if [[ $(link TYPE) == trunk ]]; then - for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do - net4=$(link IPADDR:$vlan) - net6=$(link IPADDR6:$vlan) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - done - fi - fi - done - # add active WG tunnels - for wg in $(wg show interfaces); do - net4=$(show -4 dev $wg) - net6=$(show -6 dev $wg) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - done - # add loopback interface - [[ $ipv4 == yes ]] && bind+=(127.0.0.1) - [[ $ipv6 == yes ]] && bind+=(::1) - # add user defined interfaces - [[ -f $EXTRA ]] && extra - # convert array to string - bind=${bind[@]} - reply=0 - # remove temporary file - rm -f $NETWORK_INI.eth - fi - return $reply -} +# library functions +. /etc/rc.d/rc.library.source build_ntp() { cp $CONF- $CONF @@ -159,12 +45,8 @@ ntpd_start() { echo "ntpd already running, not starting again" return fi - # if our config file not present, don't start ntp - if [[ ! -f $IDENT ]]; then - echo "Missing file: $IDENT" - return - fi - source <(/usr/bin/fromdos <$IDENT) + # read Unraid settings + [[ -r $IDENT ]] && . <(/usr/bin/fromdos <$IDENT) # if ntp not enabled, don't start ntp if [[ $USE_NTP != yes ]]; then echo "NTP not enabled" @@ -209,7 +91,7 @@ ntpd_status() { ntpd_reload() { killall -HUP -q ntpd - source <(/usr/bin/fromdos <$IDENT) + . <(/usr/bin/fromdos <$IDENT) build_ntp $NTPD $OPTIONS 2>/dev/null } diff --git a/etc/rc.d/rc.rpc b/etc/rc.d/rc.rpc index 236a3b7d5..10b1de765 100755 --- a/etc/rc.d/rc.rpc +++ b/etc/rc.d/rc.rpc @@ -12,6 +12,7 @@ # limetech - get rid of chatty '-l' rpcbind option # bergware - added interface bind functionality +SCRIPT="rpc" RPCBIND="/sbin/rpcbind" RPC="/etc/default/rpc" WIREGUARD="/etc/wireguard" @@ -19,123 +20,8 @@ NETWORK_INI="/var/local/emhttp/network.ini" SYSTEM="/sys/class/net" EXTRA="/boot/config/network-extra.cfg" -IPv() { - type=${1//[^:]} - [[ ${#type} -le ${2:-0} ]] && echo 4 || echo 6 -} - -scan() { - grep -Pom1 "^$1=\"?\K[^\"]+" $2 -} - -link() { - grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth -} - -this() { - grep -Pom1 "^RPCBIND_OPTS=\"\K[^\"]+" $RPC -} - -take() { - data=; - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 || ${1:0:7} == 169.254 || ${1:0:4} == fe80 ]] && data=$1 - done - echo $data -} - -good() { - [[ -n $1 && ${1:0:7} != 169.254 && ${1:0:4} != fe80 ]] && echo $1 -} - -show() { - case $# in - 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; - 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - esac -} - -remove() { - [[ $# -eq 0 ]] && return - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 ]] && unset 'bind[i]' - done -} - -extra() { - source <(/usr/bin/fromdos <$EXTRA) - for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - net4=$(show -4 dev $net) - net6=$(show -6 dev $net) - else - # net is an IP address, validate - net4=$(show -4 to $net) - net6=$(show -6 to $net) - fi - [[ -n $net4 && -z $(take $net4) ]] && bind+=($net4) - [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) - done - for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - remove $(show -4 dev $net) - remove $(show -6 dev $net) - else - # net is an IP address - remove $(show to $net) - fi - done -} - -check() { - # quick check - [[ -n $bind ]] && return 0; - # preset return values - reply=1; bind=(); - if [[ -f $NETWORK_INI ]]; then - # add interfaces and vlans - for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do - if [[ -e $SYSTEM/$eth ]]; then - # main interface - sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth - net4=$(link IPADDR:0) - net6=$(link IPADDR6:0) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - if [[ $(link TYPE) == trunk ]]; then - # vlan interface - for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do - net4=$(link IPADDR:$vlan) - net6=$(link IPADDR6:$vlan) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - done - fi - fi - done - # add active WG tunnels - for wg in $(wg show interfaces); do - net4=$(show -4 dev $wg) - net6=$(show -6 dev $wg) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - done - # add loopback interface - [[ $ipv4 == yes ]] && bind+=(127.0.0.1) - [[ $ipv6 == yes ]] && bind+=(::1) - # add user defined interfaces - [[ -f $EXTRA ]] && extra - # convert array to string - bind=${bind[@]} - reply=0 - # remove temporary file - rm -f $NETWORK_INI.eth - fi - return $reply -} +# library functions +. /etc/rc.d/rc.library.source # get bind addresses if check && [[ -n $bind ]]; then diff --git a/etc/rc.d/rc.samba b/etc/rc.d/rc.samba index 1c9284f3d..eecccf8b9 100644 --- a/etc/rc.d/rc.samba +++ b/etc/rc.d/rc.samba @@ -10,12 +10,14 @@ # limetech - modified to initialize smb-names.conf file from config # bergware - added interface bind functionality +SCRIPT="samba" SMBD="/usr/sbin/smbd" NMBD="/usr/sbin/nmbd" WINBINDD="/usr/sbin/winbindd" WSDD2="/usr/sbin/wsdd2" SMBCONF="/etc/samba/smb.conf" CONF="/etc/samba/smb-names.conf" +IDENT="/boot/config/ident.cfg" BOOT="/boot/config" PRIVATE="/var/lib/samba/private" WIREGUARD="/etc/wireguard" @@ -23,129 +25,15 @@ NETWORK_INI="/var/local/emhttp/network.ini" SYSTEM="/sys/class/net" EXTRA="/boot/config/network-extra.cfg" -IPv() { - type=${1//[^:]} - [[ ${#type} -le ${2:-0} ]] && echo 4 || echo 6 -} +# library functions +. /etc/rc.d/rc.library.source -scan() { - grep -Pom1 "^$1=\"?\K[^\"]+" $2 -} - -link() { - grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth -} - -this() { - grep -Pom1 "^$1 = \K.*" $CONF -} - -take() { - data=; - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 || ${1:0:7} == 169.254 || ${1:0:4} == fe80 ]] && data=$1 - done - echo $data -} - -good() { - [[ -n $1 && ${1:0:7} != 169.254 && ${1:0:4} != fe80 ]] && echo $1 -} - -show() { - case $# in - 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; - 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - esac -} - -remove() { - [[ $# -eq 0 ]] && return - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 ]] && unset 'bind[i]' - done -} - -extra() { - source <(/usr/bin/fromdos <$EXTRA) - for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - net4=$(show -4 dev $net) - net6=$(show -6 dev $net) - else - # net is an IP address, validate - net4=$(show -4 to $net) - net6=$(show -6 to $net) - fi - [[ -n $net4 && -z $(take $net4) ]] && bind+=($net4) - [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) - done - for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - remove $(show -4 dev $net) - remove $(show -6 dev $net) - else - # net is an IP address - remove $(show to $net) - fi - done -} - -check() { - # quick check - [[ -n $bind ]] && return 0; - # preset return values - reply=1; bind=(); ipv4=no; ipv6=no; - if [[ -f $NETWORK_INI ]]; then - # get interface and vlan configurations - for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do - # main interface - if [[ -e $SYSTEM/$eth ]]; then - sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth - net4=$(link IPADDR:0) - net6=$(link IPADDR6:0) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) && $USE_NETBIOS == no ]] && ipv6=yes bind+=($net6) - if [[ $(link TYPE) == trunk ]]; then - # vlan interface - for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do - net4=$(link IPADDR:$vlan) - net6=$(link IPADDR6:$vlan) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) && $USE_NETBIOS == no ]] && ipv6=yes bind+=($net6) - done - fi - fi - done - # add active WG tunnels - for wg in $(wg show interfaces); do - net4=$(show -4 dev $wg) - net6=$(show -6 dev $wg) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) && $USE_NETBIOS == no ]] && ipv6=yes bind+=($net6) - done - # add loopback interface - [[ $ipv4 == yes ]] && bind+=(127.0.0.1) - [[ $ipv6 == yes && $USE_NETBIOS == no ]] && bind+=(::1) - # add user defined interfaces - [[ -f $EXTRA ]] && extra - # convert array to string - bind=${bind[@]} - reply=0 - # remove temporary file - rm -f $NETWORK_INI.eth - fi - return $reply -} +# read Unraid settings +[[ -r $IDENT ]] && . <(/usr/bin/fromdos <$IDENT) +# disable ipv6 when netbios is used +[[ $USE_NETBIOS == yes ]] && deny6=1 samba_settings() { - # read Unraid settings - if [[ -e $BOOT/ident.cfg ]]; then - source <(/usr/bin/fromdos < $BOOT/ident.cfg) - fi [[ -z $COMMENT ]] && COMMENT="" [[ -z $SECURITY ]] && SECURITY="user" [[ -z $WORKGROUP ]] && WORKGROUP="WORKGROUP" @@ -161,7 +49,6 @@ samba_settings() { echo "hide dot files = $hideDotFiles" >>$CONF echo "server multi channel support = $serverMultiChannel" >>$CONF echo "max open files = $(ulimit -n)" >>$CONF - # fixme: samba can now auto-register with avahi but conflicts with emhttp, so disable for now echo "multicast dns register = No" >>$CONF @@ -178,7 +65,6 @@ samba_settings() { echo "disable netbios = yes" >>$CONF echo "server min protocol = SMB2" >>$CONF fi - if [[ $SECURITY == ads ]]; then echo "security = ADS" >>$CONF if [[ -z $DOMAIN_SHORT ]]; then @@ -210,7 +96,6 @@ samba_settings() { echo "create mask = 0777" >>$CONF echo "directory mask = 0777" >>$CONF fi - # bind samba service if check; then if [[ -n $bind ]]; then @@ -279,6 +164,7 @@ samba_update() { # no action required exit 1 else + echo "$(this interfaces) == $bind" # service update required exit 0 fi diff --git a/etc/rc.d/rc.sshd b/etc/rc.d/rc.sshd index e501b472e..3b52d16b0 100755 --- a/etc/rc.d/rc.sshd +++ b/etc/rc.d/rc.sshd @@ -2,6 +2,7 @@ # Start/stop/restart the secure shell server: # bergware - added interface bind functionality +SCRIPT="sshd" SSHD="/usr/sbin/sshd" CONF="/etc/ssh/sshd_config" PID="/var/run/sshd.pid" @@ -12,122 +13,8 @@ NETWORK_INI="/var/local/emhttp/network.ini" SYSTEM="/sys/class/net" EXTRA="/boot/config/network-extra.cfg" -IPv() { - type=${1//[^:]} - [[ ${#type} -le ${2:-0} ]] && echo 4 || echo 6 -} - -scan() { - grep -Pom1 "^$1=\"?\K[^\"]+" $2 -} - -link() { - grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth -} - -this() { - grep -Po "^$1 \K.*" $CONF|tr '\n' ' '|sed 's/ $//' -} - -take() { - data=; - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 || ${1:0:7} == 169.254 || ${1:0:4} == fe80 ]] && data=$1 - done - echo $data -} - -good() { - [[ -n $1 && ${1:0:7} != 169.254 && ${1:0:4} != fe80 ]] && echo $1 -} - -show() { - case $# in - 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; - 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - esac -} - -remove() { - [[ $# -eq 0 ]] && return - for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 ]] && unset 'bind[i]' - done -} - -extra() { - source <(/usr/bin/fromdos <$EXTRA) - for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - net4=$(show -4 dev $net) - net6=$(show -6 dev $net) - else - # net is an IP address, validate - net4=$(show -4 to $net) - net6=$(show -6 to $net) - fi - [[ -n $net4 && -z $(take $net4) ]] && bind+=($net4) - [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) - done - for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - remove $(show -4 dev $net) - remove $(show -6 dev $net) - else - # net is an IP address - remove $(show to $net) - fi - done -} - -check() { - # quick check - [[ -n $bind ]] && return 0; - # preset return values - reply=1; bind=(); ipv4=no; ipv6=no; family=any; - if [[ -f $NETWORK_INI ]]; then - # get interface and vlan configurations - for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do - if [[ -e $SYSTEM/$eth ]]; then - # main interface - sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth - net4=$(link IPADDR:0) - net6=$(link IPADDR6:0) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - if [[ $(link TYPE) == trunk ]]; then - # vlan interface - for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do - net4=$(link IPADDR:$vlan) - net6=$(link IPADDR6:$vlan) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - done - fi - fi - done - # add active WG tunnels - for wg in $(wg show interfaces); do - net4=$(show -4 dev $wg) - net6=$(show -6 dev $wg) - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) ]] && ipv6=yes bind+=($net6) - done - # add user defined interfaces - [[ -f $EXTRA ]] && extra - # bind stays array - bind=(${bind[@]}) - [[ $ipv4 == yes && $ipv6 == no ]] && family=inet - [[ $ipv6 == yes && $ipv4 == no ]] && family=inet6 - reply=0 - # remove temporary file - rm -f $NETWORK_INI.eth - fi - return $reply -} +# library functions +. /etc/rc.d/rc.library.source build_ssh() { if check && [[ -n $bind ]]; then @@ -144,18 +31,14 @@ build_ssh() { sshd_start() { # make sure ssh dir exists on flash mkdir -p $SSH_BOOT - # restore saved keys, config file, etc. (but not subdirs) cp $SSH_BOOT/* $SSH_ETC &>/dev/null chmod 600 $SSH_ETC/* &>/dev/null - # create host keys if needed and copy any newly generated key(s) back to flash ssh-keygen -A cp -n $SSH_ETC/ssh_host*_key* $SSH_BOOT/ - - # bind ssh service + # build configuration build_ssh - # start daemon $SSHD 2>/dev/null } From b3abc2359186524d70b15f690c0186bf55ed5a4c Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 06:59:45 +0200 Subject: [PATCH 002/239] rc scripts: use common library source --- etc/rc.d/rc.avahidaemon | 4 ---- etc/rc.d/rc.library.source | 5 +++++ etc/rc.d/rc.nfsd | 4 ---- etc/rc.d/rc.nginx | 4 ---- etc/rc.d/rc.ntpd | 4 ---- etc/rc.d/rc.rpc | 4 ---- etc/rc.d/rc.samba | 4 ---- etc/rc.d/rc.sshd | 4 ---- 8 files changed, 5 insertions(+), 28 deletions(-) diff --git a/etc/rc.d/rc.avahidaemon b/etc/rc.d/rc.avahidaemon index 6b3a9b327..7d1d1b557 100755 --- a/etc/rc.d/rc.avahidaemon +++ b/etc/rc.d/rc.avahidaemon @@ -27,10 +27,6 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin DESC="Avahi mDNS/DNS-SD Daemon" AVAHI="/usr/sbin/avahi-daemon" CONF="/etc/avahi/avahi-daemon.conf" -WIREGUARD="/etc/wireguard" -NETWORK_INI="/var/local/emhttp/network.ini" -SYSTEM="/sys/class/net" -EXTRA="/boot/config/network-extra.cfg" # library functions . /etc/rc.d/rc.library.source diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index ac6b9f0c1..1772e6c4f 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -1,6 +1,11 @@ # /etc/rc.d/rc.library # used by nfsd, ntpd, rpc, samba, nginx, sshd, avahidaemon, show_interfaces +WIREGUARD="/etc/wireguard" +NETWORK_INI="/var/local/emhttp/network.ini" +SYSTEM="/sys/class/net" +EXTRA="/boot/config/network-extra.cfg" + this() { case $SCRIPT in 'avahi') diff --git a/etc/rc.d/rc.nfsd b/etc/rc.d/rc.nfsd index 7f315ee12..5a8451e10 100755 --- a/etc/rc.d/rc.nfsd +++ b/etc/rc.d/rc.nfsd @@ -17,10 +17,6 @@ MOUNTD="/usr/sbin/rpc.mountd" OPTIONS="-u -s" RPC="/etc/default/rpc" NFS="/etc/default/nfs" -WIREGUARD="/etc/wireguard" -NETWORK_INI="/var/local/emhttp/network.ini" -SYSTEM="/sys/class/net" -EXTRA="/boot/config/network-extra.cfg" # library functions . /etc/rc.d/rc.library.source diff --git a/etc/rc.d/rc.nginx b/etc/rc.d/rc.nginx index 5b90474b7..ded7ee5e1 100755 --- a/etc/rc.d/rc.nginx +++ b/etc/rc.d/rc.nginx @@ -24,12 +24,8 @@ IDENT="/boot/config/ident.cfg" SERVERS="/etc/nginx/conf.d/servers.conf" LOCATIONS="/etc/nginx/conf.d/locations.conf" NEW="/var/local/emhttp/nginx.ini.new" -WIREGUARD="/etc/wireguard" CERTPATH="$SSL/certs/certificate_bundle.pem" MYSERVERS="/boot/config/plugins/dynamix.my.servers/myservers.cfg" -NETWORK_INI="/var/local/emhttp/network.ini" -SYSTEM="/sys/class/net" -EXTRA="/boot/config/network-extra.cfg" # hold server names SERVER_NAMES=() diff --git a/etc/rc.d/rc.ntpd b/etc/rc.d/rc.ntpd index 9f95795fd..7bf079bfb 100755 --- a/etc/rc.d/rc.ntpd +++ b/etc/rc.d/rc.ntpd @@ -9,10 +9,6 @@ NTPD="/usr/sbin/ntpd" OPTIONS="-g -u ntp:ntp" CONF="/etc/ntp.conf" IDENT="/boot/config/ident.cfg" -WIREGUARD="/etc/wireguard" -NETWORK_INI="/var/local/emhttp/network.ini" -SYSTEM="/sys/class/net" -EXTRA="/boot/config/network-extra.cfg" # library functions . /etc/rc.d/rc.library.source diff --git a/etc/rc.d/rc.rpc b/etc/rc.d/rc.rpc index 10b1de765..ce19e02e4 100755 --- a/etc/rc.d/rc.rpc +++ b/etc/rc.d/rc.rpc @@ -15,10 +15,6 @@ SCRIPT="rpc" RPCBIND="/sbin/rpcbind" RPC="/etc/default/rpc" -WIREGUARD="/etc/wireguard" -NETWORK_INI="/var/local/emhttp/network.ini" -SYSTEM="/sys/class/net" -EXTRA="/boot/config/network-extra.cfg" # library functions . /etc/rc.d/rc.library.source diff --git a/etc/rc.d/rc.samba b/etc/rc.d/rc.samba index eecccf8b9..bc8c4d5a8 100644 --- a/etc/rc.d/rc.samba +++ b/etc/rc.d/rc.samba @@ -20,10 +20,6 @@ CONF="/etc/samba/smb-names.conf" IDENT="/boot/config/ident.cfg" BOOT="/boot/config" PRIVATE="/var/lib/samba/private" -WIREGUARD="/etc/wireguard" -NETWORK_INI="/var/local/emhttp/network.ini" -SYSTEM="/sys/class/net" -EXTRA="/boot/config/network-extra.cfg" # library functions . /etc/rc.d/rc.library.source diff --git a/etc/rc.d/rc.sshd b/etc/rc.d/rc.sshd index 3b52d16b0..e1844f950 100755 --- a/etc/rc.d/rc.sshd +++ b/etc/rc.d/rc.sshd @@ -8,10 +8,6 @@ CONF="/etc/ssh/sshd_config" PID="/var/run/sshd.pid" SSH_BOOT="/boot/config/ssh" SSH_ETC="/etc/ssh" -WIREGUARD="/etc/wireguard" -NETWORK_INI="/var/local/emhttp/network.ini" -SYSTEM="/sys/class/net" -EXTRA="/boot/config/network-extra.cfg" # library functions . /etc/rc.d/rc.library.source From a2cce93f6632fc1f7f189b6607ffd33d04f84696 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 07:01:43 +0200 Subject: [PATCH 003/239] rc scripts: use common library source --- emhttp/plugins/dynamix/scripts/show_interfaces | 3 --- 1 file changed, 3 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/show_interfaces b/emhttp/plugins/dynamix/scripts/show_interfaces index a3eddafc1..1ef85e0a6 100755 --- a/emhttp/plugins/dynamix/scripts/show_interfaces +++ b/emhttp/plugins/dynamix/scripts/show_interfaces @@ -1,9 +1,6 @@ #!/bin/bash SCRIPT="show" -NETWORK_INI="/var/local/emhttp/network.ini" -SYSTEM="/sys/class/net" -EXTRA="/boot/config/network-extra.cfg" # library functions . /etc/rc.d/rc.library.source From 7ed9634d15549f2c55e7217558d081ae50b81eac Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 10:17:02 +0200 Subject: [PATCH 004/239] rc scripts: use common library source --- .../plugins/dynamix/scripts/show_interfaces | 2 +- etc/rc.d/rc.avahidaemon | 4 +- etc/rc.d/rc.library.source | 117 +++++++++--------- etc/rc.d/rc.nfsd | 2 +- etc/rc.d/rc.nginx | 2 +- etc/rc.d/rc.ntpd | 2 +- etc/rc.d/rc.rpc | 2 +- etc/rc.d/rc.samba | 2 +- etc/rc.d/rc.sshd | 4 +- 9 files changed, 71 insertions(+), 66 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/show_interfaces b/emhttp/plugins/dynamix/scripts/show_interfaces index 1ef85e0a6..b77b04f10 100755 --- a/emhttp/plugins/dynamix/scripts/show_interfaces +++ b/emhttp/plugins/dynamix/scripts/show_interfaces @@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT="show" +CALLER="show" # library functions . /etc/rc.d/rc.library.source diff --git a/etc/rc.d/rc.avahidaemon b/etc/rc.d/rc.avahidaemon index 7d1d1b557..e9c7c30b1 100755 --- a/etc/rc.d/rc.avahidaemon +++ b/etc/rc.d/rc.avahidaemon @@ -22,7 +22,7 @@ # Start/stop/restart the avahi daemon: -SCRIPT="avahi" +CALLER="avahi" PATH=/sbin:/bin:/usr/sbin:/usr/bin DESC="Avahi mDNS/DNS-SD Daemon" AVAHI="/usr/sbin/avahi-daemon" @@ -87,7 +87,7 @@ avahid_reload() { avahid_update() { if ! avahid_status; then exit 1; fi # not running - if check && [[ "$(this allow-interfaces)" == "$bind" && $(this use-ipv4) == $ipv4 && $(this use-ipv6) == $ipv6 ]]; then + if check && [[ "$(this allow-interfaces)" == "$bind" ]]; then # no action required exit 1 else diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 1772e6c4f..21e3d8887 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -7,7 +7,7 @@ SYSTEM="/sys/class/net" EXTRA="/boot/config/network-extra.cfg" this() { - case $SCRIPT in + case $CALLER in 'avahi') grep -Pom1 "^$1=\K.*" $CONF ;; @@ -76,63 +76,68 @@ remove() { done } +extra_name() { + for net in $include_interfaces; do + if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + # net is an interface name, validate + [[ -n $(show dev $net) && -z $(take $net) ]] && bind+=($net) + else + # net is an IP address, convert to name + net=$(show $net) + [[ -n $net && -z $(take $net) ]] && bind+=($net) + fi + done + for net in $exclude_interfaces; do + if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + # net is an interface name, remove + remove $net + else + # net is an IP address, convert to name and remove + remove $(show $net) + fi + done +} + +extra_addr() { + for net in $include_interfaces; do + if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + # net is an interface name, get IP addresses + net4=$(show -4 dev $net) + net6=$(show -6 dev $net) + else + # net is an IP address, validate + net4=$(show -4 to $net) + net6=$(show -6 to $net) + fi + [[ -n $net4 && -z $(take $net4) ]] && bind+=($net4) + [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) + done + for net in $exclude_interfaces; do + if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + # net is an interface name, get IP addresses + remove $(show -4 dev $net) + remove $(show -6 dev $net) + else + # net is an IP address + remove $(show to $net) + fi + done +} + extra() { source <(/usr/bin/fromdos <$EXTRA) - case $SCRIPT in - 'avahi'|'show') - for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, validate - [[ -n $(show dev $net) && -z $(take $net) ]] && bind+=($net) - else - # net is an IP address, convert to name - net=$(show $net) - [[ -n $net && -z $(take $net) ]] && bind+=($net) - fi - done - for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, remove - remove $net - else - # net is an IP address, convert to name and remove - remove $(show $net) - fi - done - ;; - *) - for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - net4=$(show -4 dev $net) - net6=$(show -6 dev $net) - else - # net is an IP address, validate - net4=$(show -4 to $net) - net6=$(show -6 to $net) - fi - [[ -n $net4 && -z $(take $net4) ]] && bind+=($net4) - [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) - done - for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then - # net is an interface name, get IP addresses - remove $(show -4 dev $net) - remove $(show -6 dev $net) - else - # net is an IP address - remove $(show to $net) - fi - done - ;; - esac + if [[ "avahi show" =~ $CALLER ]]; then + extra_name + else + extra_addr + fi } check() { # quick check [[ -n $bind ]] && return 0; # preset return values - reply=1; bind=(); ipv4=no; ipv6=no; + reply=1; bind=(); ipv4=no; ipv6=no; family=any; if [[ -f $NETWORK_INI ]]; then # add interfaces and vlans for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do @@ -141,7 +146,7 @@ check() { sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth net4=$(link IPADDR:0) net6=$(link IPADDR6:0) - if [[ $SCRIPT == avahi || $SCRIPT == show ]]; then + if [[ "avahi show" =~ $CALLER ]]; then net=$eth [[ $(link BONDING) == yes ]] && net=${eth/eth/bond} [[ $(link BRIDGING) == yes ]] && net=${eth/eth/br} @@ -157,7 +162,7 @@ check() { for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do net4=$(link IPADDR:$vlan) net6=$(link IPADDR6:$vlan) - if [[ $SCRIPT == avahi || $SCRIPT == show ]]; then + if [[ "avahi show" =~ $CALLER ]]; then [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($net.$(link VLANID:$vlan)) [[ -n $(good $net4) ]] && ipv4=yes [[ -n $(good $net6) ]] && ipv6=yes @@ -173,7 +178,7 @@ check() { for wg in $(wg show interfaces); do net4=$(show -4 dev $wg) net6=$(show -6 dev $wg) - if [[ $SCRIPT == avahi || $SCRIPT == show ]]; then + if [[ "avahi show" =~ $CALLER ]]; then [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($wg) [[ -n $(good $net4) ]] && ipv4=yes [[ -n $(good $net6) ]] && ipv6=yes @@ -183,13 +188,13 @@ check() { fi done # add loopback interface - if [[ "nfsd ntpd rpc" =~ $SCRIPT ]]; then + if [[ "nfsd ntpd rpc" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) [[ $ipv6 == yes ]] && bind+=(::1) fi # add user defined interfaces [[ -f $EXTRA ]] && extra - if [[ $SCRIPT == sshd ]]; then + if [[ $CALLER == sshd ]]; then # bind stays array bind=(${bind[@]}) [[ $ipv4 == yes && $ipv6 == no ]] && family=inet @@ -197,7 +202,7 @@ check() { else # convert array to string bind=${bind[@]} - [[ $SCRIPT == avahi ]] && bind=${bind// /,} + [[ $CALLER == avahi ]] && bind=${bind// /,} fi reply=0 # remove temporary file diff --git a/etc/rc.d/rc.nfsd b/etc/rc.d/rc.nfsd index 5a8451e10..92900b465 100755 --- a/etc/rc.d/rc.nfsd +++ b/etc/rc.d/rc.nfsd @@ -9,7 +9,7 @@ # # bergware - added interface bind functionality -SCRIPT="nfsd" +CALLER="nfsd" NFSD="/usr/sbin/rpc.nfsd" EXPORTFS="/usr/sbin/exportfs" RQUOTAD="/usr/sbin/rpc.rquotad" diff --git a/etc/rc.d/rc.nginx b/etc/rc.d/rc.nginx index ded7ee5e1..449399ca7 100755 --- a/etc/rc.d/rc.nginx +++ b/etc/rc.d/rc.nginx @@ -15,7 +15,7 @@ # WANFQDN 'www.hash.unraid.net' (legacy) # WG0FQDN 'wg0-ip.hash.myunraid.net' (wildcard cert) -SCRIPT="nginx" +CALLER="nginx" NGINX="/usr/sbin/nginx" PID="/var/run/nginx.pid" SSL="/boot/config/ssl" diff --git a/etc/rc.d/rc.ntpd b/etc/rc.d/rc.ntpd index 7bf079bfb..67d4fe9da 100755 --- a/etc/rc.d/rc.ntpd +++ b/etc/rc.d/rc.ntpd @@ -4,7 +4,7 @@ # limetech - modified to initialize ntp.conf file from config # bergware - added interface bind functionality -SCRIPT="ntpd" +CALLER="ntpd" NTPD="/usr/sbin/ntpd" OPTIONS="-g -u ntp:ntp" CONF="/etc/ntp.conf" diff --git a/etc/rc.d/rc.rpc b/etc/rc.d/rc.rpc index ce19e02e4..eca647a7a 100755 --- a/etc/rc.d/rc.rpc +++ b/etc/rc.d/rc.rpc @@ -12,7 +12,7 @@ # limetech - get rid of chatty '-l' rpcbind option # bergware - added interface bind functionality -SCRIPT="rpc" +CALLER="rpc" RPCBIND="/sbin/rpcbind" RPC="/etc/default/rpc" diff --git a/etc/rc.d/rc.samba b/etc/rc.d/rc.samba index bc8c4d5a8..663f54e1d 100644 --- a/etc/rc.d/rc.samba +++ b/etc/rc.d/rc.samba @@ -10,7 +10,7 @@ # limetech - modified to initialize smb-names.conf file from config # bergware - added interface bind functionality -SCRIPT="samba" +CALLER="samba" SMBD="/usr/sbin/smbd" NMBD="/usr/sbin/nmbd" WINBINDD="/usr/sbin/winbindd" diff --git a/etc/rc.d/rc.sshd b/etc/rc.d/rc.sshd index e1844f950..03affddb3 100755 --- a/etc/rc.d/rc.sshd +++ b/etc/rc.d/rc.sshd @@ -2,7 +2,7 @@ # Start/stop/restart the secure shell server: # bergware - added interface bind functionality -SCRIPT="sshd" +CALLER="sshd" SSHD="/usr/sbin/sshd" CONF="/etc/ssh/sshd_config" PID="/var/run/sshd.pid" @@ -72,7 +72,7 @@ sshd_reload() { sshd_update() { [[ $(pgrep -cf $SSHD) -eq 0 ]] && exit 1 # not running - if check && [[ "$(this ListenAddress)" == "${bind[@]}" && $(this AddressFamily) == $family ]]; then + if check && [[ "$(this ListenAddress)" == "${bind[@]}" ]]; then # no action required exit 1 else From 56acff7c7881f2e930f4cfd195699f59e7b362f5 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 10:34:05 +0200 Subject: [PATCH 005/239] rc scripts: use common library source --- etc/rc.d/rc.library.source | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 21e3d8887..83ecce925 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -126,11 +126,7 @@ extra_addr() { extra() { source <(/usr/bin/fromdos <$EXTRA) - if [[ "avahi show" =~ $CALLER ]]; then - extra_name - else - extra_addr - fi + [[ "avahi show" =~ $CALLER ]] && extra_name || extra_addr } check() { From f7107f0167004a89471466cb0e51873b65bf00a7 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 10:37:05 +0200 Subject: [PATCH 006/239] Revert "rc scripts: use common library source" This reverts commit 56acff7c7881f2e930f4cfd195699f59e7b362f5. --- etc/rc.d/rc.library.source | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 83ecce925..21e3d8887 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -126,7 +126,11 @@ extra_addr() { extra() { source <(/usr/bin/fromdos <$EXTRA) - [[ "avahi show" =~ $CALLER ]] && extra_name || extra_addr + if [[ "avahi show" =~ $CALLER ]]; then + extra_name + else + extra_addr + fi } check() { From a1080bfc08a9b57ac32b00418d4bb94f63d0f35b Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 10:49:20 +0200 Subject: [PATCH 007/239] rc scripts: use common library source --- etc/rc.d/rc.library.source | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 21e3d8887..118e44d08 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -76,9 +76,13 @@ remove() { done } +isname() { + [[ -z ${1//[^.:]} || ${1//[^.:]} == . ]] && return 0 || return 1 +} + extra_name() { for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + if $(isname $net); then # net is an interface name, validate [[ -n $(show dev $net) && -z $(take $net) ]] && bind+=($net) else @@ -88,7 +92,7 @@ extra_name() { fi done for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + if $(isname $net); then # net is an interface name, remove remove $net else @@ -100,7 +104,7 @@ extra_name() { extra_addr() { for net in $include_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + if $(isname $net); then # net is an interface name, get IP addresses net4=$(show -4 dev $net) net6=$(show -6 dev $net) @@ -113,7 +117,7 @@ extra_addr() { [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) done for net in $exclude_interfaces; do - if [[ -z ${net//[^.:]} || ${net//[^.:]} == . ]]; then + if $(isname $net); then # net is an interface name, get IP addresses remove $(show -4 dev $net) remove $(show -6 dev $net) From 61bf9180daa6c9e6606453b20f9eae43235e33f7 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 10:58:32 +0200 Subject: [PATCH 008/239] rc scripts: use common library source --- etc/rc.d/rc.library.source | 50 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 118e44d08..85adaf204 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -8,31 +8,31 @@ EXTRA="/boot/config/network-extra.cfg" this() { case $CALLER in -'avahi') - grep -Pom1 "^$1=\K.*" $CONF - ;; -'samba') - grep -Pom1 "^$1 = \K.*" $CONF - ;; -'ntpd'|'sshd') - grep -Po "^$1 \K.*" $CONF|tr '\n' ' '|sed 's/ $//' - ;; -'nfsd') - grep -Pom1 "^RPC_NFSD_OPTS=\"$OPTIONS \K[^\"]+" $NFS - ;; -'rpc') - grep -Pom1 "^RPCBIND_OPTS=\"\K[^\"]+" $RPC - ;; -'nginx') - now=(); - for addr in $(awk '$1=="listen" && $2~/^[0-9]|\[/ && $0~/http2; #.*$/{print $2}' $SERVERS 2>/dev/null); do - # extract ipv4 / ipv6 address - [[ $(IPv $addr 1) == 4 ]] && addr=${addr%:*} || addr=${addr#*[} addr=${addr%]*} - now+=($addr) - done - # return addresses - echo ${now[@]} - ;; + 'avahi') + grep -Pom1 "^$1=\K.*" $CONF + ;; + 'samba') + grep -Pom1 "^$1 = \K.*" $CONF + ;; + 'ntpd'|'sshd') + grep -Po "^$1 \K.*" $CONF|tr '\n' ' '|sed 's/ $//' + ;; + 'nfsd') + grep -Pom1 "^RPC_NFSD_OPTS=\"$OPTIONS \K[^\"]+" $NFS + ;; + 'rpc') + grep -Pom1 "^RPCBIND_OPTS=\"\K[^\"]+" $RPC + ;; + 'nginx') + now=(); + for addr in $(awk '$1=="listen" && $2~/^[0-9]|\[/ && $0~/http2; #.*$/{print $2}' $SERVERS 2>/dev/null); do + # extract ipv4 / ipv6 address + [[ $(IPv $addr 1) == 4 ]] && addr=${addr%:*} || addr=${addr#*[} addr=${addr%]*} + now+=($addr) + done + # return addresses + echo ${now[@]} + ;; esac } From 07c5d61c513629b281bf46b4762ad537de3088b1 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 11:01:31 +0200 Subject: [PATCH 009/239] rc scripts: use common library source --- etc/rc.d/rc.library.source | 4 ++-- etc/rc.d/rc.nfsd | 2 +- etc/rc.d/rc.ntpd | 2 +- etc/rc.d/rc.sshd | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 85adaf204..122483c87 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -14,10 +14,10 @@ this() { 'samba') grep -Pom1 "^$1 = \K.*" $CONF ;; - 'ntpd'|'sshd') + 'ntp'|'ssh') grep -Po "^$1 \K.*" $CONF|tr '\n' ' '|sed 's/ $//' ;; - 'nfsd') + 'nfs') grep -Pom1 "^RPC_NFSD_OPTS=\"$OPTIONS \K[^\"]+" $NFS ;; 'rpc') diff --git a/etc/rc.d/rc.nfsd b/etc/rc.d/rc.nfsd index 92900b465..964c5d44d 100755 --- a/etc/rc.d/rc.nfsd +++ b/etc/rc.d/rc.nfsd @@ -9,7 +9,7 @@ # # bergware - added interface bind functionality -CALLER="nfsd" +CALLER="nfs" NFSD="/usr/sbin/rpc.nfsd" EXPORTFS="/usr/sbin/exportfs" RQUOTAD="/usr/sbin/rpc.rquotad" diff --git a/etc/rc.d/rc.ntpd b/etc/rc.d/rc.ntpd index 67d4fe9da..02c91cede 100755 --- a/etc/rc.d/rc.ntpd +++ b/etc/rc.d/rc.ntpd @@ -4,7 +4,7 @@ # limetech - modified to initialize ntp.conf file from config # bergware - added interface bind functionality -CALLER="ntpd" +CALLER="ntp" NTPD="/usr/sbin/ntpd" OPTIONS="-g -u ntp:ntp" CONF="/etc/ntp.conf" diff --git a/etc/rc.d/rc.sshd b/etc/rc.d/rc.sshd index 03affddb3..b0a9e84d0 100755 --- a/etc/rc.d/rc.sshd +++ b/etc/rc.d/rc.sshd @@ -2,7 +2,7 @@ # Start/stop/restart the secure shell server: # bergware - added interface bind functionality -CALLER="sshd" +CALLER="ssh" SSHD="/usr/sbin/sshd" CONF="/etc/ssh/sshd_config" PID="/var/run/sshd.pid" From ec6dfdb2cc3d67fe9a78251d4bd002fb6df1e82a Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 11:03:11 +0200 Subject: [PATCH 010/239] rc scripts: use common library source --- etc/rc.d/rc.library.source | 2 +- etc/rc.d/rc.samba | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 122483c87..383cdc757 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -11,7 +11,7 @@ this() { 'avahi') grep -Pom1 "^$1=\K.*" $CONF ;; - 'samba') + 'smb') grep -Pom1 "^$1 = \K.*" $CONF ;; 'ntp'|'ssh') diff --git a/etc/rc.d/rc.samba b/etc/rc.d/rc.samba index 663f54e1d..234a72f03 100644 --- a/etc/rc.d/rc.samba +++ b/etc/rc.d/rc.samba @@ -10,7 +10,7 @@ # limetech - modified to initialize smb-names.conf file from config # bergware - added interface bind functionality -CALLER="samba" +CALLER="smb" SMBD="/usr/sbin/smbd" NMBD="/usr/sbin/nmbd" WINBINDD="/usr/sbin/winbindd" From 74afa9e33ecd0528dc69ccd1fad72f48fd72afaa Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 11:25:23 +0200 Subject: [PATCH 011/239] rc scripts: use common library source --- etc/rc.d/rc.library.source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 383cdc757..0833dfac6 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -1,5 +1,5 @@ -# /etc/rc.d/rc.library -# used by nfsd, ntpd, rpc, samba, nginx, sshd, avahidaemon, show_interfaces +# Library file: /etc/rc.d/rc.library.source +# Used by nfsd, ntpd, rpc, samba, nginx, sshd, avahidaemon, show_interfaces WIREGUARD="/etc/wireguard" NETWORK_INI="/var/local/emhttp/network.ini" From 30ad511b2599700df954cb0e73acea5c0d68b6b7 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 11:31:46 +0200 Subject: [PATCH 012/239] rc scripts: use common library source --- etc/rc.d/rc.rpc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/rc.rpc b/etc/rc.d/rc.rpc index eca647a7a..5a1008e58 100755 --- a/etc/rc.d/rc.rpc +++ b/etc/rc.d/rc.rpc @@ -14,6 +14,7 @@ CALLER="rpc" RPCBIND="/sbin/rpcbind" +STATD="/sbin/rpc.statd" RPC="/etc/default/rpc" # library functions @@ -31,7 +32,7 @@ sed -ri "s/^#?(RPCBIND_OPTS)=.*/\1=\"$RPCBIND_OPTS\"/" $RPC 2>/dev/null [[ -r $RPC ]] && . $RPC rpc_start() { - if [[ -x $RPCBIND && -x /sbin/rpc.statd ]]; then + if [[ -x $RPCBIND && -x $STATD ]]; then # Set up port for lockd: if [[ -n $LOCKD_TCP_PORT ]]; then /sbin/sysctl -w "fs.nfs.nlm_tcpport=$LOCKD_TCP_PORT" 2>/dev/null @@ -47,15 +48,15 @@ rpc_start() { [[ -n $RPC_STATD_HOSTNAME ]] && RPC_STATD_OPTS="$RPC_STATD_OPTS -n $RPC_STATD_HOSTNAME" [[ -n $RPC_STATD_PORT ]] && RPC_STATD_OPTS="$RPC_STATD_OPTS -p $RPC_STATD_PORT" [[ -n $RPC_STATD_OUTGOING_PORT ]] && RPC_STATD_OPTS="$RPC_STATD_OPTS -o $RPC_STATD_OUTGOING_PORT" - echo "Starting RPC NSM (Network Status Monitor): /sbin/rpc.statd $RPC_STATD_OPTS" - /sbin/rpc.statd $RPC_STATD_OPTS 2>/dev/null + echo "Starting RPC NSM (Network Status Monitor): $STATD $RPC_STATD_OPTS" + $STATD $RPC_STATD_OPTS 2>/dev/null fi else echo "WARNING: Cannot start RPC daemons needed for NFS. One or more of" echo " these required daemons is not executable or is not present" echo " on your system:" echo - echo " $RPCBIND or /sbin/rpc.statd" + echo " $RPCBIND or $STATD" echo fi } From 73c42baeccfe0060e8e6a4613229862a4e9a7082 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 11:34:53 +0200 Subject: [PATCH 013/239] rc scripts: use common library source --- etc/rc.d/rc.nginx | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/etc/rc.d/rc.nginx b/etc/rc.d/rc.nginx index 449399ca7..176bfa7ff 100755 --- a/etc/rc.d/rc.nginx +++ b/etc/rc.d/rc.nginx @@ -23,7 +23,7 @@ CONF="/etc/nginx/nginx.conf" IDENT="/boot/config/ident.cfg" SERVERS="/etc/nginx/conf.d/servers.conf" LOCATIONS="/etc/nginx/conf.d/locations.conf" -NEW="/var/local/emhttp/nginx.ini.new" +INI="/var/local/emhttp/nginx.ini.new" CERTPATH="$SSL/certs/certificate_bundle.pem" MYSERVERS="/boot/config/plugins/dynamix.my.servers/myservers.cfg" @@ -541,36 +541,36 @@ build_ssl() { DEFAULTURL="http://$LANMDNS$PORT_URL" fi - mkdir -p $(dirname "$NEW") + mkdir -p $(dirname "$INI") # always defined: - echo "NGINX_LANIP=\"$LANIP\"" >$NEW - echo "NGINX_LANIP6=\"$LANIP6\"" >>$NEW - echo "NGINX_LANNAME=\"$LANNAME\"" >>$NEW - echo "NGINX_LANMDNS=\"$LANMDNS\"" >>$NEW - echo "NGINX_CERTPATH=\"$CERTPATH\"" >>$NEW - echo "NGINX_USESSL=\"$USE_SSL\"" >>$NEW - echo "NGINX_PORT=\"$PORT\"" >>$NEW - echo "NGINX_PORTSSL=\"$PORTSSL\"" >>$NEW - echo "NGINX_DEFAULTURL=\"$DEFAULTURL\"" >>$NEW + echo "NGINX_LANIP=\"$LANIP\"" >$INI + echo "NGINX_LANIP6=\"$LANIP6\"" >>$INI + echo "NGINX_LANNAME=\"$LANNAME\"" >>$INI + echo "NGINX_LANMDNS=\"$LANMDNS\"" >>$INI + echo "NGINX_CERTPATH=\"$CERTPATH\"" >>$INI + echo "NGINX_USESSL=\"$USE_SSL\"" >>$INI + echo "NGINX_PORT=\"$PORT\"" >>$INI + echo "NGINX_PORTSSL=\"$PORTSSL\"" >>$INI + echo "NGINX_DEFAULTURL=\"$DEFAULTURL\"" >>$INI # defined if certificate_bundle.pem present: - echo "NGINX_CERTNAME=\"$CERTNAME\"" >>$NEW - echo "NGINX_LANFQDN=\"$LANFQDN\"" >>$NEW - echo "NGINX_LANFQDN6=\"$LANFQDN6\"" >>$NEW + echo "NGINX_CERTNAME=\"$CERTNAME\"" >>$INI + echo "NGINX_LANFQDN=\"$LANFQDN\"" >>$INI + echo "NGINX_LANFQDN6=\"$LANFQDN6\"" >>$INI # defined if remote access enabled: - echo "NGINX_WANACCESS=\"$WANACCESS\"" >>$NEW - echo "NGINX_WANIP=\"$WANIP\"" >>$NEW - echo "NGINX_WANIP6=\"$WANIP6\"" >>$NEW - echo "NGINX_WANFQDN=\"$WANFQDN\"" >>$NEW - echo "NGINX_WANFQDN6=\"$WANFQDN6\"" >>$NEW + echo "NGINX_WANACCESS=\"$WANACCESS\"" >>$INI + echo "NGINX_WANIP=\"$WANIP\"" >>$INI + echo "NGINX_WANIP6=\"$WANIP6\"" >>$INI + echo "NGINX_WANFQDN=\"$WANFQDN\"" >>$INI + echo "NGINX_WANFQDN6=\"$WANFQDN6\"" >>$INI # add included interfaces for NET in ${!NET_FQDN[@]}; do - echo "NGINX_${NET^^}FQDN=\"${NET_FQDN[$NET]}\"" >>$NEW + echo "NGINX_${NET^^}FQDN=\"${NET_FQDN[$NET]}\"" >>$INI done for NET in ${!NET_FQDN6[@]}; do - echo "NGINX_${NET^^}FQDN6=\"${NET_FQDN6[$NET]}\"" >>$NEW + echo "NGINX_${NET^^}FQDN6=\"${NET_FQDN6[$NET]}\"" >>$INI done # atomically update file - /usr/bin/mv $NEW ${NEW%.*} + /usr/bin/mv $INI ${INI%.*} } nginx_status() { From b99077e48737540bb973b06ee75c2aade1ca4d3f Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 11:42:03 +0200 Subject: [PATCH 014/239] rc.inet1 suppress error messages --- etc/rc.d/rc.inet1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.inet1 b/etc/rc.d/rc.inet1 index 127766cf0..6cd2e3bbf 100755 --- a/etc/rc.d/rc.inet1 +++ b/etc/rc.d/rc.inet1 @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # /etc/rc.d/rc.inet1 # This script is used to bring up the various network interfaces. # @@ -45,13 +45,14 @@ # Adapted by Bergware for use in unRAID - May 2023 # - added iptables and ip6tables and arp-tables inclusion to bridge interfaces # - fixed ipv4 and ipv6 DNS assignment +# - suppress errors ############################ # READ NETWORK CONFIG FILE # ############################ # get the configuration information from rc.inet1.conf -source /etc/rc.d/rc.inet1.conf +. /etc/rc.d/rc.inet1.conf # system network reference SYSTEM=/sys/class/net @@ -69,7 +70,7 @@ alias log=run run(){ # log command in /var/log/syslog and execute logger -t rc.inet1 "$*" - [[ -n $2 ]] && $* + [[ -n $2 ]] && $* 2>/dev/null } ############################ From 8b2b107e4a21fc9ddf00c4faf122fa00865d7097 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 11:45:49 +0200 Subject: [PATCH 015/239] apcupsd: shebang --- etc/rc.d/rc.apcupsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.apcupsd b/etc/rc.d/rc.apcupsd index 391695fcf..1765fcf8d 100755 --- a/etc/rc.d/rc.apcupsd +++ b/etc/rc.d/rc.apcupsd @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # # apcupsd This shell script takes care of starting and stopping # the apcupsd UPS monitoring daemon. From a74c08aa1f5b36cb221ab21680a124ff83f2c312 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 11:46:01 +0200 Subject: [PATCH 016/239] php-fpm: shebang --- etc/rc.d/rc.php-fpm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.php-fpm b/etc/rc.d/rc.php-fpm index fbe12f572..48949abee 100755 --- a/etc/rc.d/rc.php-fpm +++ b/etc/rc.d/rc.php-fpm @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh ### BEGIN INIT INFO # Provides: php-fpm From 8d3ca2347ebe8ab9f6cdb8e0352fa70893f3cf34 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 11:55:27 +0200 Subject: [PATCH 017/239] rc scripts: use common library source --- etc/rc.d/rc.library.source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 0833dfac6..03d07ba8c 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -192,13 +192,13 @@ check() { fi done # add loopback interface - if [[ "nfsd ntpd rpc" =~ $CALLER ]]; then + if [[ "nfs ntp rpc" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) [[ $ipv6 == yes ]] && bind+=(::1) fi # add user defined interfaces [[ -f $EXTRA ]] && extra - if [[ $CALLER == sshd ]]; then + if [[ $CALLER == ssh ]]; then # bind stays array bind=(${bind[@]}) [[ $ipv4 == yes && $ipv6 == no ]] && family=inet From af4cc5b89d26e24af70b659b6b1f25c1e6092b3d Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 12:04:37 +0200 Subject: [PATCH 018/239] rc scripts: use common library source --- etc/rc.d/rc.avahidaemon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.avahidaemon b/etc/rc.d/rc.avahidaemon index e9c7c30b1..e29d48123 100755 --- a/etc/rc.d/rc.avahidaemon +++ b/etc/rc.d/rc.avahidaemon @@ -47,7 +47,7 @@ avahid_start() { if [[ -f $NETWORK_INI ]]; then # bind avahi service if check; then - [[ -n $bind ]] && allow $bind + [[ -n $bind ]] && allow $bind || allow br0 [[ $ipv4 == yes ]] && enable ipv4 || disable ipv4 [[ $ipv6 == yes ]] && enable ipv6 || disable ipv6 fi From f2960f16300a484c868c2bf6daaa1ad08e6207c5 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 12:13:12 +0200 Subject: [PATCH 019/239] rc scripts: use common library source --- etc/rc.d/rc.avahidaemon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/rc.avahidaemon b/etc/rc.d/rc.avahidaemon index e29d48123..1d73c8cf2 100755 --- a/etc/rc.d/rc.avahidaemon +++ b/etc/rc.d/rc.avahidaemon @@ -48,8 +48,8 @@ avahid_start() { # bind avahi service if check; then [[ -n $bind ]] && allow $bind || allow br0 - [[ $ipv4 == yes ]] && enable ipv4 || disable ipv4 - [[ $ipv6 == yes ]] && enable ipv6 || disable ipv6 + [[ $ipv4 == no ]] && disable ipv4 || enable ipv4 + [[ $ipv6 == no ]] && disable ipv6 || enable ipv6 fi else # default interface with no configuration From 5cf79417d4fe43ff8f7c54d7032ac9a2c6ea407a Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 15:21:26 +0200 Subject: [PATCH 020/239] rc scripts: use common library source --- etc/rc.d/rc.library.source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 03d07ba8c..ecbf4980d 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -129,7 +129,7 @@ extra_addr() { } extra() { - source <(/usr/bin/fromdos <$EXTRA) + . <(/usr/bin/fromdos <$EXTRA) if [[ "avahi show" =~ $CALLER ]]; then extra_name else From d16b17942f5321f9f20f4fc2e6dfab4c6cb0895d Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Jun 2023 16:03:14 +0200 Subject: [PATCH 021/239] rc scripts: use common library source --- etc/rc.d/rc.nginx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/rc.nginx b/etc/rc.d/rc.nginx index 176bfa7ff..2af7b4863 100755 --- a/etc/rc.d/rc.nginx +++ b/etc/rc.d/rc.nginx @@ -61,9 +61,9 @@ listen() { t=' ' if [[ $1 == lo ]]; then echo "${t}listen 127.0.0.1:$PORT; # lo" - [[ $USE_SSL != no ]] && echo "${t}listen 127.0.0.1:$PORTSSL; # lo" + echo "${t}listen 127.0.0.1:$PORTSSL; # lo" echo "${t}listen [::1]:$PORT; # lo" - [[ $USE_SSL != no ]] && echo "${t}listen [::1]:$PORTSSL; # lo" + echo "${t}listen [::1]:$PORTSSL; # lo" elif check && [[ -n $bind ]]; then for addr in $bind; do [[ $(IPv $addr) == 4 ]] && echo "${t}listen $addr:$*; # $(show $addr)" From cafba206fb57f4dd8f8640de0e4837cef1d05e3d Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 4 Jun 2023 10:09:36 +0200 Subject: [PATCH 022/239] Helpers: fix PHP error in my_scale function --- emhttp/plugins/dynamix/include/Helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/Helpers.php b/emhttp/plugins/dynamix/include/Helpers.php index 778132a22..7bb757674 100644 --- a/emhttp/plugins/dynamix/include/Helpers.php +++ b/emhttp/plugins/dynamix/include/Helpers.php @@ -26,7 +26,7 @@ function my_scale($value, &$unit, $decimals=NULL, $scale=NULL, $kilo=1000) { $decimals = 0; $unit = ''; } else { - $base = $value ? floor(log($value, $kilo)) : 0; + $base = $value ? intval(floor(log($value, $kilo))) : 0; if ($scale>0 && $base>$scale) $base = $scale; if ($base>$size) $base = $size-1; $value /= pow($kilo, $base); From 3e4d550e1f2b420ab72fafd8f3fd402e8f56e8fb Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 4 Jun 2023 10:10:14 +0200 Subject: [PATCH 023/239] rc.samba: remove debug code --- etc/rc.d/rc.samba | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/rc.d/rc.samba b/etc/rc.d/rc.samba index 234a72f03..b244f6403 100644 --- a/etc/rc.d/rc.samba +++ b/etc/rc.d/rc.samba @@ -160,7 +160,6 @@ samba_update() { # no action required exit 1 else - echo "$(this interfaces) == $bind" # service update required exit 0 fi From e1b7edc389c3a938b0a48f4ff4041a1cad6f6346 Mon Sep 17 00:00:00 2001 From: Florian Bach Date: Sun, 4 Jun 2023 12:33:01 +0200 Subject: [PATCH 024/239] rc.docker: Fix multiple fixed IPs --- etc/rc.d/rc.docker | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 0231842ab..bccffb28b 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -196,7 +196,7 @@ start_network(){ THIS_IP= while read_dom; do [[ $ENTITY == Network ]] && THIS_NETWORK=$CONTENT - [[ $ENTITY == MyIP ]] && THIS_IP=${CONTENT// /} && THIS_IP=${THIS_IP//,/;} + [[ $ENTITY == MyIP ]] && THIS_IP=${CONTENT// /,} && THIS_IP=$(echo "${THIS_IP}" | tr -s "," ";") done <$XMLFILE # only restore valid networks if [[ -n $THIS_NETWORK ]]; then @@ -367,7 +367,7 @@ start_network(){ THIS_TT=${CONNECT#*,} THIS_IP= for IP in ${THIS_TT//;/ }; do - [[ $IP =~ '.' ]] && THIS_IP="$THIS_IP --ip $IP" || THIS_IP="$THIS_IP --ip6 $IP" + [[ $IP =~ ':' ]] && THIS_IP="$THIS_IP --ip6 $IP" || THIS_IP="$THIS_IP --ip $IP" done docker network connect $THIS_IP $NETWORK $THIS_ID >/dev/null done From 42ab3ef58e46e769684d6a9fde37219850abdfdd Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 4 Jun 2023 16:37:25 +0100 Subject: [PATCH 025/239] Fix page load issue Fix issues with VM page loads if users have removed vcpu pinning. --- emhttp/plugins/dynamix.vm.manager/VMMachines.page | 4 ++-- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 4 ++-- emhttp/plugins/dynamix/include/CPUset.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/VMMachines.page b/emhttp/plugins/dynamix.vm.manager/VMMachines.page index e53dbacea..dceeed474 100644 --- a/emhttp/plugins/dynamix.vm.manager/VMMachines.page +++ b/emhttp/plugins/dynamix.vm.manager/VMMachines.page @@ -34,12 +34,12 @@ function showCPUs($uuid) { foreach ($cpus as $pair) { unset($cpu1,$cpu2); [$cpu1, $cpu2] = my_preg_split('/[,-]/',$pair); - $check = in_array($cpu1, $vcpu) ? 'fa-circle orange-text':'fa-circle-o'; + $check = ($vcpu && in_array($cpu1, $vcpu)) ? 'fa-circle orange-text':'fa-circle-o'; if (!$cpu2) { echo ""; } else { echo ""; - $check = in_array($cpu2, $vcpu) ? 'fa-circle orange-text':'fa-circle-o'; + $check = ($vcpu && in_array($cpu2, $vcpu)) ? 'fa-circle orange-text':'fa-circle-o'; echo ""; } } diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 6d4fcca41..011d82724 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -346,12 +346,12 @@ foreach ($cpus as $pair) { unset($cpu1,$cpu2); [$cpu1, $cpu2] = my_preg_split('/[,-]/',$pair); - $extra = in_array($cpu1, $arrConfig['domain']['vcpu']) ? ($arrConfig['domain']['vcpus'] > 1 ? 'checked' : 'checked disabled') : ''; + $extra = ($arrConfig['domain']['vcpu'] && in_array($cpu1, $arrConfig['domain']['vcpu'])) ? ($arrConfig['domain']['vcpus'] > 1 ? 'checked' : 'checked disabled') : ''; if (!$cpu2) { echo ""; } else { echo ""; - $extra = in_array($cpu2, $arrConfig['domain']['vcpu']) ? ($arrConfig['domain']['vcpus'] > 1 ? 'checked' : 'checked disabled') : ''; + $extra = ($arrConfig['domain']['vcpu'] && in_array($cpu2, $arrConfig['domain']['vcpu'])) ? ($arrConfig['domain']['vcpus'] > 1 ? 'checked' : 'checked disabled') : ''; echo ""; } } diff --git a/emhttp/plugins/dynamix/include/CPUset.php b/emhttp/plugins/dynamix/include/CPUset.php index 1a7a8cdea..68e156491 100644 --- a/emhttp/plugins/dynamix/include/CPUset.php +++ b/emhttp/plugins/dynamix/include/CPUset.php @@ -39,8 +39,8 @@ function create($id, $name, $vcpu) { for ($n = 0; $n < $max; $n++) { unset($cpu1,$cpu2); [$cpu1, $cpu2] = my_preg_split('/[,-]/',$cpus[$c*32+$n]); - $check1 = in_array($cpu1, $vcpu) ? 'checked':''; - $check2 = $cpu2 ? (in_array($cpu2, $vcpu) ? 'checked':''):''; + $check1 = ($vcpu && in_array($cpu1, $vcpu)) ? 'checked':''; + $check2 = $cpu2 ? ($vcpu && (in_array($cpu2, $vcpu)) ? 'checked':''):''; if (empty($text[$n])) $text[$n] = ''; $text[$n] .="
"; if ($cpu2) $text[$n] .= "
"; From 32e413d747d382d60b07cdbb142b392125a9edec Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 5 Jun 2023 23:02:37 +0200 Subject: [PATCH 026/239] rc.samba: all loopback as listening interface --- etc/rc.d/rc.library.source | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index ecbf4980d..505f86bcc 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -1,5 +1,7 @@ # Library file: /etc/rc.d/rc.library.source # Used by nfsd, ntpd, rpc, samba, nginx, sshd, avahidaemon, show_interfaces +# +# bergware - updated for Unraid, June 2023 WIREGUARD="/etc/wireguard" NETWORK_INI="/var/local/emhttp/network.ini" @@ -192,7 +194,7 @@ check() { fi done # add loopback interface - if [[ "nfs ntp rpc" =~ $CALLER ]]; then + if [[ "smb nfs ntp rpc" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) [[ $ipv6 == yes ]] && bind+=(::1) fi From 2e70232c4e046bf0a6b668ea769441594f54d5e2 Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 7 Jun 2023 12:59:34 +0200 Subject: [PATCH 027/239] Fix smb bind when using wireguard/tailscale tunnel --- etc/rc.d/rc.library.source | 60 +++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 505f86bcc..d2ca926f1 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -39,8 +39,8 @@ this() { } IPv() { - type=${1//[^:]} - [[ ${#type} -le ${2:-0} ]] && echo 4 || echo 6 + t=${1//[^:]} + [[ ${#t} -le 1 ]] && echo 4 || echo 6 } scan() { @@ -66,11 +66,21 @@ good() { show() { case $# in 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; - 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; - 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^\/]+';; + 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^ ]+';; + 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^ ]+';; esac } +fuse() { + if [[ $CALLER == smb && -z $deny6 ]]; then + # replace netmask + [[ $(IPv $1) == 4 ]] && echo ${1/\/32/\/24} || echo ${1/\/128/\/64} + else + # remove netmask + echo ${1/\/*} + fi +} + remove() { [[ $# -eq 0 ]] && return for i in ${!bind[@]}; do @@ -115,8 +125,8 @@ extra_addr() { net4=$(show -4 to $net) net6=$(show -6 to $net) fi - [[ -n $net4 && -z $(take $net4) ]] && bind+=($net4) - [[ -n $net6 && -z $(take $net6) ]] && bind+=($net6) + [[ -n $net4 && -z $(take $net4) ]] && bind+=($(fuse $net4)) + [[ -n $net6 && -z $(take $net6) ]] && bind+=($(fuse $net6)) done for net in $exclude_interfaces; do if $(isname $net); then @@ -130,15 +140,6 @@ extra_addr() { done } -extra() { - . <(/usr/bin/fromdos <$EXTRA) - if [[ "avahi show" =~ $CALLER ]]; then - extra_name - else - extra_addr - fi -} - check() { # quick check [[ -n $bind ]] && return 0; @@ -150,8 +151,8 @@ check() { if [[ -e $SYSTEM/$eth ]]; then # main interface sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth - net4=$(link IPADDR:0) - net6=$(link IPADDR6:0) + net4=$(show -4 to $(link IPADDR:0)) + net6=$(show -6 to $(link IPADDR6:0)) if [[ "avahi show" =~ $CALLER ]]; then net=$eth [[ $(link BONDING) == yes ]] && net=${eth/eth/bond} @@ -160,21 +161,21 @@ check() { [[ -n $(good $net4) ]] && ipv4=yes [[ -n $(good $net6) ]] && ipv6=yes else - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($net6) + [[ -n $(good $net4) ]] && ipv4=yes bind+=($(fuse $net4)) + [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(fuse $net6)) fi if [[ $(link TYPE) == trunk ]]; then # vlan interface for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do - net4=$(link IPADDR:$vlan) - net6=$(link IPADDR6:$vlan) + net4=$(show -4 to $(link IPADDR:$vlan)) + net6=$(show -6 to $(link IPADDR6:$vlan)) if [[ "avahi show" =~ $CALLER ]]; then [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($net.$(link VLANID:$vlan)) [[ -n $(good $net4) ]] && ipv4=yes [[ -n $(good $net6) ]] && ipv6=yes else - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($net6) + [[ -n $(good $net4) ]] && ipv4=yes bind+=($(fuse $net4)) + [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(fuse $net6)) fi done fi @@ -189,8 +190,8 @@ check() { [[ -n $(good $net4) ]] && ipv4=yes [[ -n $(good $net6) ]] && ipv6=yes else - [[ -n $(good $net4) ]] && ipv4=yes bind+=($net4) - [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($net6) + [[ -n $(good $net4) ]] && ipv4=yes bind+=($(fuse $net4)) + [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(fuse $net6)) fi done # add loopback interface @@ -199,7 +200,14 @@ check() { [[ $ipv6 == yes ]] && bind+=(::1) fi # add user defined interfaces - [[ -f $EXTRA ]] && extra + if [[ -f $EXTRA ]]; then + . <(/usr/bin/fromdos <$EXTRA) + if [[ "avahi show" =~ $CALLER ]]; then + extra_name + else + extra_addr + fi + fi if [[ $CALLER == ssh ]]; then # bind stays array bind=(${bind[@]}) From 21b0545882dca59cfa8ef55f6e6c4e4b0c484220 Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 7 Jun 2023 13:48:35 +0200 Subject: [PATCH 028/239] Fix smb bind when using wireguard/tailscale tunnel --- etc/rc.d/rc.library.source | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index d2ca926f1..a7a3e9b70 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -109,7 +109,7 @@ extra_name() { remove $net else # net is an IP address, convert to name and remove - remove $(show $net) + remove $(fuse $(show $net)) fi done } @@ -131,11 +131,11 @@ extra_addr() { for net in $exclude_interfaces; do if $(isname $net); then # net is an interface name, get IP addresses - remove $(show -4 dev $net) - remove $(show -6 dev $net) + remove $(fuse $(show -4 dev $net)) + remove $(fuse $(show -6 dev $net)) else # net is an IP address - remove $(show to $net) + remove $(fuse $(show to $net)) fi done } From 2d65dcee05ab6d0a9cf21bf68a6ab9f23dd1e47b Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 7 Jun 2023 21:26:24 +0200 Subject: [PATCH 029/239] Remove LO from rc.rpc, it is already included --- etc/rc.d/rc.library.source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index a7a3e9b70..1b18e6e9f 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -195,7 +195,7 @@ check() { fi done # add loopback interface - if [[ "smb nfs ntp rpc" =~ $CALLER ]]; then + if [[ "smb nfs ntp" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) [[ $ipv6 == yes ]] && bind+=(::1) fi From c69f31b8fe2a7a1831069602c70997c678395855 Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 7 Jun 2023 22:12:42 +0200 Subject: [PATCH 030/239] Fix regression error in disk utilization and disk temperature thresholds --- emhttp/plugins/dynamix/include/Helpers.php | 4 ++-- emhttp/plugins/dynamix/nchan/update_2 | 8 ++++---- emhttp/plugins/dynamix/scripts/monitor | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/emhttp/plugins/dynamix/include/Helpers.php b/emhttp/plugins/dynamix/include/Helpers.php index 7bb757674..80cb3e887 100644 --- a/emhttp/plugins/dynamix/include/Helpers.php +++ b/emhttp/plugins/dynamix/include/Helpers.php @@ -117,8 +117,8 @@ function my_usage() { function usage_color(&$disk, $limit, $free) { global $display; if (_var($display,'text',0)==1 || intval(_var($display,'text',0)/10)==1) return ''; - $critical = _var($disk,'critical') ? $disk['critical'] : (_var($display,'critical') ? $display['critical'] : 0); - $warning = _var($disk,'warning') ? $disk['warning'] : (_var($display,'warning') ? $display['warning'] : 0); + $critical = _var($disk,'critical')>=0 ? $disk['critical'] : (_var($display,'critical')>=0 ? $display['critical'] : 0); + $warning = _var($disk,'warning')>=0 ? $disk['warning'] : (_var($display,'warning')>=0 ? $display['warning'] : 0); if (!$free) { if ($critical>0 && $limit>=$critical) return 'redbar'; if ($warning>0 && $limit>=$warning) return 'orangebar'; diff --git a/emhttp/plugins/dynamix/nchan/update_2 b/emhttp/plugins/dynamix/nchan/update_2 index 429a5b0b0..82926588a 100755 --- a/emhttp/plugins/dynamix/nchan/update_2 +++ b/emhttp/plugins/dynamix/nchan/update_2 @@ -159,8 +159,8 @@ function device_temp(&$disk, &$red, &$orange) { global $display; $spin = strpos(_var($disk,'color'),'blink')===false; $temp = _var($disk,'temp','*'); - $max = _var($disk,'maxTemp') ? $disk['maxTemp'] : (_var($display,'max') ? $display['max'] : 0); - $hot = _var($disk,'hotTemp') ? $disk['hotTemp'] : (_var($display,'hot') ? $display['hot'] : 0); + $max = _var($disk,'maxTemp')>=0 ? $disk['maxTemp'] : (_var($display,'max')>=0 ? $display['max'] : 0); + $hot = _var($disk,'hotTemp')>=0 ? $disk['hotTemp'] : (_var($display,'hot')>=0 ? $display['hot'] : 0); $top = $display['top'] ?? 120; $heat = false; $color = 'green'; if (exceed($temp,$max,$top)) { @@ -208,8 +208,8 @@ function device_usage(&$disk, &$full, &$high) { if ($used) { if ($text==2 || $text==21) { $load = substr($used,0,-1); - $critical = _var($disk,'critical') ? $disk['critical'] : (_var($display,'critical') ? $display['critical'] : 0); - $warning = _var($disk,'warning') ? $disk['warning'] : (_var($display,'warning') ? $display['warning'] : 0); + $critical = _var($disk,'critical')>=0 ? $disk['critical'] : (_var($display,'critical')>=0 ? $display['critical'] : 0); + $warning = _var($disk,'warning')>=0 ? $disk['warning'] : (_var($display,'warning')>=0 ? $display['warning'] : 0); if ($critical>0 && $load>=$critical) {$class = 'redbar'; $full++;} elseif ($warning>0 && $load>=$warning) {$class = 'orangebar'; $high++;} else $class = 'greenbar'; diff --git a/emhttp/plugins/dynamix/scripts/monitor b/emhttp/plugins/dynamix/scripts/monitor index 023255110..767a18f73 100755 --- a/emhttp/plugins/dynamix/scripts/monitor +++ b/emhttp/plugins/dynamix/scripts/monitor @@ -46,8 +46,8 @@ function check_temp(&$disk,$text,$info) { global $notify,$saved,$server,$display,$top; $name = _var($disk,'name'); $temp = _var($disk,'temp','*'); - $max = _var($disk,'maxTemp') ? $disk['maxTemp'] : (_var($display,'max') ? $display['max'] : 0); - $hot = _var($disk,'hotTemp') ? $disk['hotTemp'] : (_var($display,'hot') ? $display['hot'] : 0); + $max = _var($disk,'maxTemp')>=0 ? $disk['maxTemp'] : (_var($display,'max')>=0 ? $display['max'] : 0); + $hot = _var($disk,'hotTemp')>=0 ? $disk['hotTemp'] : (_var($display,'hot')>=0 ? $display['hot'] : 0); $warn = exceed($temp,$max,$top) ? 'alert' : (exceed($temp,$hot,$top) ? 'warning' : false); $item = 'temp'; $last = $saved[$item][$name] ?? 0; @@ -123,8 +123,8 @@ function check_usage(&$disk,$used,$text,$info) { global $notify,$saved,$server,$display; if ($used == -1) return; $name = _var($disk,'name'); - $critical = _var($disk,'critical') ? $disk['critical'] : (_var($display,'critical') ? $display['critical'] : 0); - $warning = _var($disk,'warning') ? $disk['warning'] : (_var($display,'warning') ? $display['warning'] : 0); + $critical = _var($disk,'critical')>=0 ? $disk['critical'] : (_var($display,'critical')>=0 ? $display['critical'] : 0); + $warning = _var($disk,'warning')>=0 ? $disk['warning'] : (_var($display,'warning')>=0 ? $display['warning'] : 0); $warn = exceed($used,$critical) ? 'alert' : (exceed($used,$warning) ? 'warning' : false); $item = 'used'; $last = $saved[$item][$name] ?? 0; From 7181d89c64865699987c5528f11268655f5e1ebb Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 8 Jun 2023 09:45:04 +0200 Subject: [PATCH 031/239] Fix smb bind when using wireguard/tailscale tunnel --- etc/rc.d/rc.library.source | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 1b18e6e9f..f0489846c 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -125,8 +125,8 @@ extra_addr() { net4=$(show -4 to $net) net6=$(show -6 to $net) fi - [[ -n $net4 && -z $(take $net4) ]] && bind+=($(fuse $net4)) - [[ -n $net6 && -z $(take $net6) ]] && bind+=($(fuse $net6)) + [[ -n $net4 && -z $(take $(fuse $net4)) ]] && bind+=($(fuse $net4)) + [[ -n $net6 && -z $(take $(fuse $net6)) ]] && bind+=($(fuse $net6)) done for net in $exclude_interfaces; do if $(isname $net); then @@ -195,7 +195,7 @@ check() { fi done # add loopback interface - if [[ "smb nfs ntp" =~ $CALLER ]]; then + if [[ "smb nfs ntp rpc" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) [[ $ipv6 == yes ]] && bind+=(::1) fi From f5af4ff0c6fa9db5ecdf041704e23322c63490bb Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 8 Jun 2023 09:55:41 +0200 Subject: [PATCH 032/239] Fix smb bind when using wireguard/tailscale tunnel --- etc/rc.d/rc.library.source | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index f0489846c..ed981e323 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -71,7 +71,7 @@ show() { esac } -fuse() { +sub() { if [[ $CALLER == smb && -z $deny6 ]]; then # replace netmask [[ $(IPv $1) == 4 ]] && echo ${1/\/32/\/24} || echo ${1/\/128/\/64} @@ -109,7 +109,7 @@ extra_name() { remove $net else # net is an IP address, convert to name and remove - remove $(fuse $(show $net)) + remove $(sub $(show $net)) fi done } @@ -125,17 +125,17 @@ extra_addr() { net4=$(show -4 to $net) net6=$(show -6 to $net) fi - [[ -n $net4 && -z $(take $(fuse $net4)) ]] && bind+=($(fuse $net4)) - [[ -n $net6 && -z $(take $(fuse $net6)) ]] && bind+=($(fuse $net6)) + [[ -n $net4 && -z $(take $(sub $net4)) ]] && bind+=($(sub $net4)) + [[ -n $net6 && -z $(take $(sub $net6)) ]] && bind+=($(sub $net6)) done for net in $exclude_interfaces; do if $(isname $net); then # net is an interface name, get IP addresses - remove $(fuse $(show -4 dev $net)) - remove $(fuse $(show -6 dev $net)) + remove $(sub $(show -4 dev $net)) + remove $(sub $(show -6 dev $net)) else # net is an IP address - remove $(fuse $(show to $net)) + remove $(sub $(show to $net)) fi done } @@ -161,8 +161,8 @@ check() { [[ -n $(good $net4) ]] && ipv4=yes [[ -n $(good $net6) ]] && ipv6=yes else - [[ -n $(good $net4) ]] && ipv4=yes bind+=($(fuse $net4)) - [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(fuse $net6)) + [[ -n $(good $net4) ]] && ipv4=yes bind+=($(sub $net4)) + [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(sub $net6)) fi if [[ $(link TYPE) == trunk ]]; then # vlan interface @@ -174,8 +174,8 @@ check() { [[ -n $(good $net4) ]] && ipv4=yes [[ -n $(good $net6) ]] && ipv6=yes else - [[ -n $(good $net4) ]] && ipv4=yes bind+=($(fuse $net4)) - [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(fuse $net6)) + [[ -n $(good $net4) ]] && ipv4=yes bind+=($(sub $net4)) + [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(sub $net6)) fi done fi @@ -190,8 +190,8 @@ check() { [[ -n $(good $net4) ]] && ipv4=yes [[ -n $(good $net6) ]] && ipv6=yes else - [[ -n $(good $net4) ]] && ipv4=yes bind+=($(fuse $net4)) - [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(fuse $net6)) + [[ -n $(good $net4) ]] && ipv4=yes bind+=($(sub $net4)) + [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(sub $net6)) fi done # add loopback interface From 1a9466e87459c7360641cf0addfbe60dd7acb39d Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 9 Jun 2023 22:51:40 +0200 Subject: [PATCH 033/239] Remove LO from rc.rpc, it is already included (regression) --- etc/rc.d/rc.library.source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index ed981e323..61bbb2ca0 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -195,7 +195,7 @@ check() { fi done # add loopback interface - if [[ "smb nfs ntp rpc" =~ $CALLER ]]; then + if [[ "smb nfs ntp" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) [[ $ipv6 == yes ]] && bind+=(::1) fi From bf720c488abbc84a8d900318a7b89557564baa03 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 10 Jun 2023 03:57:59 +0200 Subject: [PATCH 034/239] Minor code refactoring --- etc/rc.d/rc.library.source | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 61bbb2ca0..dbb403730 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -8,6 +8,11 @@ NETWORK_INI="/var/local/emhttp/network.ini" SYSTEM="/sys/class/net" EXTRA="/boot/config/network-extra.cfg" +IPv() { + t=${1//[^:]} + [[ ${#t} -le 1 ]] && echo 4 || echo 6 +} + this() { case $CALLER in 'avahi') @@ -29,7 +34,7 @@ this() { now=(); for addr in $(awk '$1=="listen" && $2~/^[0-9]|\[/ && $0~/http2; #.*$/{print $2}' $SERVERS 2>/dev/null); do # extract ipv4 / ipv6 address - [[ $(IPv $addr 1) == 4 ]] && addr=${addr%:*} || addr=${addr#*[} addr=${addr%]*} + [[ $(IPv $addr) == 4 ]] && addr=${addr%:*} || addr=${addr#*[} addr=${addr%]*} now+=($addr) done # return addresses @@ -38,11 +43,6 @@ this() { esac } -IPv() { - t=${1//[^:]} - [[ ${#t} -le 1 ]] && echo 4 || echo 6 -} - scan() { grep -Pom1 "^$1=\"?\K[^\"]+" $2 } From a8cf94d7b3408c587a64c10a2c1c6d42fa8baaf1 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 10 Jun 2023 11:26:07 +0200 Subject: [PATCH 035/239] DeviceInfo: fix incorrect floor size entries --- emhttp/plugins/dynamix/DeviceInfo.page | 1 + 1 file changed, 1 insertion(+) diff --git a/emhttp/plugins/dynamix/DeviceInfo.page b/emhttp/plugins/dynamix/DeviceInfo.page index 1641cf727..933fe6141 100644 --- a/emhttp/plugins/dynamix/DeviceInfo.page +++ b/emhttp/plugins/dynamix/DeviceInfo.page @@ -31,6 +31,7 @@ function sanitize(&$val) { $data = explode('.',str_replace([' ',','],['','.'],$val)); $last = array_pop($data); $val = count($data) ? implode($data).".$last" : $last; + $val = preg_replace('/[^0-9.]/','',$val); } function presetSpace($val) { global $disk,$display; From 9b9674b66663a7cbb10137c6855aff5a20efd4c1 Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 11 Jun 2023 17:54:33 +0200 Subject: [PATCH 036/239] StatusCheck: fixed: temperature thresholds --- emhttp/plugins/dynamix/scripts/statuscheck | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/statuscheck b/emhttp/plugins/dynamix/scripts/statuscheck index 13ae901aa..482096e05 100755 --- a/emhttp/plugins/dynamix/scripts/statuscheck +++ b/emhttp/plugins/dynamix/scripts/statuscheck @@ -93,10 +93,10 @@ function my_clock($time) { function my_array(&$disk) { global $data,$display,$error0,$error1,$error2,$error3; $name = _var($disk,'name'); - $max = $disk['maxTemp'] ?? $display['max'] ?? 0; - $hot = $disk['hotTemp'] ?? $display['hot'] ?? 0; + $max = _var($disk,'maxTemp')>=0 ? $disk['maxTemp'] : (_var($display,'max')>=0 ? $display['max'] : 0); + $hot = _var($disk,'hotTemp')>=0 ? $disk['hotTemp'] : (_var($display,'hot')>=0 ? $display['hot'] : 0); if (strpos(_var($disk,'status'),'_NP')!==false) return false; - $temp = _var($disk,'temp','*'); + $temp = _var($disk,'temp'); if ($max>0 && $temp>=$max) { $fail = ' (disk is overheated'; $error0++; From 081a87381e5314e19619008b2226396cb466ea7b Mon Sep 17 00:00:00 2001 From: Tom Mortensen Date: Tue, 13 Jun 2023 14:02:07 -0700 Subject: [PATCH 037/239] rc.docker: give dockerd 30 sec instead of 15 to start up --- etc/rc.d/rc.docker | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index bccffb28b..3235fe2b0 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -91,9 +91,9 @@ is_docker_running(){ [[ $(docker info 2>&1) =~ "Cannot connect to the Docker daemon" ]] && return 1 || return 0 } -# Wait max 15s to daemon start +# Wait max 30s to daemon start wait_daemon(){ - for n in {1..15}; do + for n in {1..30}; do if is_docker_running; then return 0; else sleep 1; fi done return 1 From fafb8716ed50068c1c10784afb9cfe68e835bd66 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 15 Jun 2023 21:37:42 +0200 Subject: [PATCH 038/239] UPS: PHP8 support --- emhttp/plugins/dynamix.apcupsd/include/UPSstatus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix.apcupsd/include/UPSstatus.php b/emhttp/plugins/dynamix.apcupsd/include/UPSstatus.php index 7b6cec80d..69ed7c9f8 100644 --- a/emhttp/plugins/dynamix.apcupsd/include/UPSstatus.php +++ b/emhttp/plugins/dynamix.apcupsd/include/UPSstatus.php @@ -87,7 +87,7 @@ if (file_exists("/var/run/apcupsd.pid")) { if (count($rows)%2==1) $result[] = ""; if ($power && isset($load)) $status[5] = ($load<90 ? "" : "").round($power*$load/100)." W (".$status[5].")"; elseif (isset($load)) $status[5] = ($load<90 ? "" : "").$status[5].""; - $status[6] = $output ? ((!$volt || ($minv<$output && $output<$maxv) ? "" : "").$status[6].($freq ? " ~ $freq Hz" : "")."") : $status[6]; + $status[6] = isset($output) ? ((!$volt || ($minv<$output && $output<$maxv) ? "" : "").$status[6].($freq ? " ~ $freq Hz" : "")."") : $status[6]; } if (empty($rows)) $result[] = ""._('No information available').""; From 89e60c6c998f266c06acc410636387d725d91d2c Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 04:31:39 +0200 Subject: [PATCH 039/239] rc.library: read IP addresses directly from interfaces instead of file --- etc/rc.d/rc.library.source | 134 +++++++++++++------------------------ 1 file changed, 46 insertions(+), 88 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index dbb403730..3d885a45f 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -3,9 +3,6 @@ # # bergware - updated for Unraid, June 2023 -WIREGUARD="/etc/wireguard" -NETWORK_INI="/var/local/emhttp/network.ini" -SYSTEM="/sys/class/net" EXTRA="/boot/config/network-extra.cfg" IPv() { @@ -51,7 +48,7 @@ link() { grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth } -take() { +good() { data=; for i in ${!bind[@]}; do [[ ${bind[$i]} == $1 || ${1:0:7} == 169.254 || ${1:0:4} == fe80 ]] && data=$1 @@ -59,10 +56,6 @@ take() { echo $data } -good() { - [[ -n $1 && ${1:0:7} != 169.254 && ${1:0:4} != fe80 ]] && echo $1 -} - show() { case $# in 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; @@ -96,11 +89,11 @@ extra_name() { for net in $include_interfaces; do if $(isname $net); then # net is an interface name, validate - [[ -n $(show dev $net) && -z $(take $net) ]] && bind+=($net) + [[ -n $(show dev $net) && -z $(good $net) ]] && bind+=($net) else # net is an IP address, convert to name net=$(show $net) - [[ -n $net && -z $(take $net) ]] && bind+=($net) + [[ -n $net && -z $(good $net) ]] && bind+=($net) fi done for net in $exclude_interfaces; do @@ -125,8 +118,8 @@ extra_addr() { net4=$(show -4 to $net) net6=$(show -6 to $net) fi - [[ -n $net4 && -z $(take $(sub $net4)) ]] && bind+=($(sub $net4)) - [[ -n $net6 && -z $(take $(sub $net6)) ]] && bind+=($(sub $net6)) + [[ -n $net4 && -z $(good $(sub $net4)) ]] && bind+=($(sub $net4)) + [[ -n $net6 && -z $(good $(sub $net6)) ]] && bind+=($(sub $net6)) done for net in $exclude_interfaces; do if $(isname $net); then @@ -144,83 +137,48 @@ check() { # quick check [[ -n $bind ]] && return 0; # preset return values - reply=1; bind=(); ipv4=no; ipv6=no; family=any; - if [[ -f $NETWORK_INI ]]; then - # add interfaces and vlans - for eth in $(grep -Po '^\[\K[^\]]+' $NETWORK_INI); do - if [[ -e $SYSTEM/$eth ]]; then - # main interface - sed -n "/^\[$eth\]/,/^\[eth/p" $NETWORK_INI >$NETWORK_INI.eth - net4=$(show -4 to $(link IPADDR:0)) - net6=$(show -6 to $(link IPADDR6:0)) - if [[ "avahi show" =~ $CALLER ]]; then - net=$eth - [[ $(link BONDING) == yes ]] && net=${eth/eth/bond} - [[ $(link BRIDGING) == yes ]] && net=${eth/eth/br} - [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($net) - [[ -n $(good $net4) ]] && ipv4=yes - [[ -n $(good $net6) ]] && ipv6=yes - else - [[ -n $(good $net4) ]] && ipv4=yes bind+=($(sub $net4)) - [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(sub $net6)) - fi - if [[ $(link TYPE) == trunk ]]; then - # vlan interface - for vlan in $(grep -Po '^VLANID:\K\d+' $NETWORK_INI.eth); do - net4=$(show -4 to $(link IPADDR:$vlan)) - net6=$(show -6 to $(link IPADDR6:$vlan)) - if [[ "avahi show" =~ $CALLER ]]; then - [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($net.$(link VLANID:$vlan)) - [[ -n $(good $net4) ]] && ipv4=yes - [[ -n $(good $net6) ]] && ipv6=yes - else - [[ -n $(good $net4) ]] && ipv4=yes bind+=($(sub $net4)) - [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(sub $net6)) - fi - done - fi - fi - done - # add active WG tunnels - for wg in $(wg show interfaces); do - net4=$(show -4 dev $wg) - net6=$(show -6 dev $wg) - if [[ "avahi show" =~ $CALLER ]]; then - [[ -n $(good $net4) || -n $(good $net6) ]] && bind+=($wg) - [[ -n $(good $net4) ]] && ipv4=yes - [[ -n $(good $net6) ]] && ipv6=yes - else - [[ -n $(good $net4) ]] && ipv4=yes bind+=($(sub $net4)) - [[ -n $(good $net6) && -z $deny6 ]] && ipv6=yes bind+=($(sub $net6)) - fi - done - # add loopback interface - if [[ "smb nfs ntp" =~ $CALLER ]]; then - [[ $ipv4 == yes ]] && bind+=(127.0.0.1) - [[ $ipv6 == yes ]] && bind+=(::1) - fi - # add user defined interfaces - if [[ -f $EXTRA ]]; then - . <(/usr/bin/fromdos <$EXTRA) - if [[ "avahi show" =~ $CALLER ]]; then - extra_name - else - extra_addr - fi - fi - if [[ $CALLER == ssh ]]; then - # bind stays array - bind=(${bind[@]}) - [[ $ipv4 == yes && $ipv6 == no ]] && family=inet - [[ $ipv6 == yes && $ipv4 == no ]] && family=inet6 + bind=(); ipv4=no; ipv6=no; family=any; + # active ipv4 interfaces (including wireguard) + while IFS='\n' read -r net; do + net=($net) + if [[ "avahi show" =~ $CALLER ]]; then + [[ -n $net ]] && bind+=($net) else - # convert array to string - bind=${bind[@]} - [[ $CALLER == avahi ]] && bind=${bind// /,} + [[ -n ${net[1]} ]] && ipv4=yes bind+=($(sub ${net[1]})) fi - reply=0 - # remove temporary file - rm -f $NETWORK_INI.eth + done <<< $(ip -4 addr|awk '/^ +inet/ && $2 !~ "169.254" {print $NF,$2}'|grep -P '^(br|bond|eth|wg)\d+(\.\d+)? ') + # active ipv6 interfaces (including wireguard) + while IFS='\n' read -r net; do + net=($net) + if [[ "avahi show" =~ $CALLER ]]; then + [[ -n $net && -z $(good $net) ]] && bind+=($net) + else + [[ -n ${net[1]} ]] && ipv6=yes bind+=($(sub ${net[1]})) + fi + done <<< $(ip -6 addr|awk '/^[0-9]+:|^ +inet6/ && $2 !~ "fe80" {print $2}'|sed ':a;N;$!ba;s/:\n/ /g'|awk '{print $(NF-1),$NF}'|grep -P '^(br|bond|eth|wg)\d+(\.\d+)? ') + # add loopback interface + if [[ "smb nfs ntp" =~ $CALLER ]]; then + [[ $ipv4 == yes ]] && bind+=(127.0.0.1) + [[ $ipv6 == yes ]] && bind+=(::1) fi - return $reply + # add user defined interfaces + if [[ -f $EXTRA ]]; then + . <(/usr/bin/fromdos <$EXTRA) + if [[ "avahi show" =~ $CALLER ]]; then + extra_name + else + extra_addr + fi + fi + if [[ $CALLER == ssh ]]; then + # bind stays array + bind=(${bind[@]}) + [[ $ipv4 == yes && $ipv6 == no ]] && family=inet + [[ $ipv6 == yes && $ipv4 == no ]] && family=inet6 + else + # convert array to string + bind=${bind[@]} + [[ $CALLER == avahi ]] && bind=${bind// /,} + fi + return 0 } From 7f59557dc35d6df75031c9ecc271887d2b9006bc Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 05:01:15 +0200 Subject: [PATCH 040/239] rc.library: read IP addresses directly from interfaces instead of file --- etc/rc.d/rc.library.source | 4 ---- 1 file changed, 4 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 3d885a45f..fd3200f18 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -44,10 +44,6 @@ scan() { grep -Pom1 "^$1=\"?\K[^\"]+" $2 } -link() { - grep -Pom1 "^$1=\"\K[^\"]+" $NETWORK_INI.eth -} - good() { data=; for i in ${!bind[@]}; do From c7d53c34d67a434df67327be37fae5074e933044 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 05:09:45 +0200 Subject: [PATCH 041/239] rc.library: read IP addresses directly from interfaces instead of file --- etc/rc.d/rc.library.source | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index fd3200f18..96d0e29b9 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -3,6 +3,8 @@ # # bergware - updated for Unraid, June 2023 +WIREGUARD="/etc/wireguard" +NETWORK_INI="/var/local/emhttp/network.ini" EXTRA="/boot/config/network-extra.cfg" IPv() { From 02985e163da58c168a0a0e99c5faab7e4cfdd168 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 05:53:50 +0200 Subject: [PATCH 042/239] rc.library: add ippv4/ipv6 selection to extra interfaces --- etc/rc.d/rc.library.source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 96d0e29b9..b07dae9be 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -116,8 +116,8 @@ extra_addr() { net4=$(show -4 to $net) net6=$(show -6 to $net) fi - [[ -n $net4 && -z $(good $(sub $net4)) ]] && bind+=($(sub $net4)) - [[ -n $net6 && -z $(good $(sub $net6)) ]] && bind+=($(sub $net6)) + [[ -n $net4 && -z $(good $(sub $net4)) ]] && ipv4=yes bind+=($(sub $net4)) + [[ -n $net6 && -z $(good $(sub $net6)) ]] && ipv6=yes bind+=($(sub $net6)) done for net in $exclude_interfaces; do if $(isname $net); then From 0344ee0482fc9d207be12c925f08bef27849d5d9 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 06:02:41 +0200 Subject: [PATCH 043/239] Add REPLY6 event for IPv6 assignments --- sbin/create_network_ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/create_network_ini b/sbin/create_network_ini index 6d605decc..403b6be04 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -7,7 +7,7 @@ # update files on DHCP events 'BOUND[6] IPV4LL ROUTERADVERT' # update services listening interfaces / addresses -[[ (-z $reason && -z $1) || (-n $reason && ! "BOUND6 IPV4LL ROUTERADVERT" =~ $reason) ]] && exit 0 +[[ (-z $reason && -z $1) || (-n $reason && ! "BOUND6 REPLY6 IPV4LL ROUTERADVERT" =~ $reason) ]] && exit 0 ini=/var/local/emhttp/network.ini.new cfg=/boot/config/network.cfg From 5aa7ecbadfa31640bbf935860519188640e47309 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 06:13:20 +0200 Subject: [PATCH 044/239] Add REPLY6 event for IPv6 assignments --- sbin/create_network_ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/create_network_ini b/sbin/create_network_ini index 403b6be04..fb5b9bf77 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -4,7 +4,7 @@ # # create initial network.ini file on system start # create system welcome message -# update files on DHCP events 'BOUND[6] IPV4LL ROUTERADVERT' +# update files on DHCP events 'BOUND[6] REPLY[6] IPV4LL ROUTERADVERT' # update services listening interfaces / addresses [[ (-z $reason && -z $1) || (-n $reason && ! "BOUND6 REPLY6 IPV4LL ROUTERADVERT" =~ $reason) ]] && exit 0 From 05d65de8f0a5213146045e24380b8fccec5f87a5 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 06:31:20 +0200 Subject: [PATCH 045/239] rc.library: remove unnecessary function --- etc/rc.d/rc.library.source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index b07dae9be..147ff1ff5 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -100,7 +100,7 @@ extra_name() { remove $net else # net is an IP address, convert to name and remove - remove $(sub $(show $net)) + remove $(show $net) fi done } From c695317b304d5f63fde5930ffcdae76285c017d6 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 07:16:03 +0200 Subject: [PATCH 046/239] smb service: force listening interfaces upon reload --- etc/rc.d/rc.samba | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/etc/rc.d/rc.samba b/etc/rc.d/rc.samba index b244f6403..f0f53b9b2 100644 --- a/etc/rc.d/rc.samba +++ b/etc/rc.d/rc.samba @@ -110,7 +110,7 @@ samba_start() { # restore previously stored samba 'secrets' file (for better AD integration) if [[ -e $BOOT/secrets.tdb ]]; then - mv $BOOT/secrets.tdb $PRIVATE + cp -f $BOOT/secrets.tdb $PRIVATE fi # create settings @@ -135,7 +135,7 @@ samba_stop() { killall smbd nmbd wsdd2 winbindd >/dev/null 2>&1 # save samba 'secrets' file if [[ -e $PRIVATE/secrets.tdb ]]; then - cp $PRIVATE/secrets.tdb $BOOT + cp -f $PRIVATE/secrets.tdb $BOOT fi } @@ -146,12 +146,14 @@ samba_restart() { } samba_reload() { + killall smbd nmbd wsdd2 winbindd >/dev/null 2>&1 # update settings samba_settings # restart services - /usr/bin/smbcontrol smbd reload-config - [[ $USE_NETBIOS == yes ]] && /usr/bin/smbcontrol nmbd reload-config - /usr/bin/smbcontrol winbindd reload-config + $SMBD -D 2>/dev/null + [[ $USE_NETBIOS == yes ]] && $NMBD -D 2>/dev/null + [[ $USE_WSD == yes ]] && $WSDD2 -d ${WSD2_OPT## } 2>/dev/null + $WINBINDD -D 2>/dev/null } samba_update() { From 44bdb432c5ebeaea5df436e5feedbe346f680781 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 11:52:14 +0200 Subject: [PATCH 047/239] Dashboard fixes and enhancements - Remove unnecessary title popups - Add size view when hovering over memory fields --- emhttp/plugins/dynamix/DashStats.page | 32 +++++++++++-------- .../plugins/dynamix/include/DashboardApps.php | 11 +++++++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index 3c3efd02d..fe53ffc18 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -218,7 +218,8 @@ i[class^="icon-u-"]{font-size:inherit} i#mycase[class^="case-"]{font-size:128px} i#mycase[class^="fa "]{font-size:96px} a.cpu_close,span.hand{cursor:pointer;z-index:1001} -tr#zfs,tr#cpu_chart,.cpu_open{display:none} +tr#var1,tr#var4,tr#cpu_chart,.cpu_open{display:none} +tr#var0,tr#var1,tr#var2,tr#var3,tr#var4{cursor:alias} td.none{text-align:center;padding-top:12px} input[value=Edit]{margin:12px 0 0 0;padding:5px 10px} .share1,.share3,.user1,.user3,.view1,.view2,.view3,.view4{display:none} @@ -312,13 +313,11 @@ foreach ($cpus as $pair) { _(Usable size)_: _(Maximum size)_: -_(RAM)_0%
-_(ZFS)_0%
-_(Flash)_0%
-_(Log)_0%
- -_(Docker)_0%
- +_(RAM)_0%
+_(ZFS)_0%
+_(Flash)_0%
+_(Log)_0%
+_(Docker)_0%
@@ -1052,11 +1051,21 @@ function sortTables() { }); } function addProperties() { - $('tbody.system').addClass('sortable').attr('sort','_system_information_'); - $('tbody').not('.system').each(function(){ + $('div.frame tbody.system').addClass('sortable').attr('sort','_system_information_'); + $('div.frame tbody').not('.system').each(function(){ $(this).addClass('sortable').attr('sort',$(this).attr('title').marker()); $(this).find('td:first').prepend(""); }); + $('div.frame tr').attr('title',''); + $('tr#var0').hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:0},function(val){$('.sys0').text(val);})}); + + $('tr#var1').show().hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:1},function(val){$('.sys1').text(val);})}); + + $('tr#var2').hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:2},function(val){$('.sys2').text(val);})}); + $('tr#var3').hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:3},function(val){$('.sys3').text(val);})}); + + $('tr#var4').show().hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:4},function(val){$('.sys4').text(val);})}); + } function showContent() { var count = {'db-box1':$('table#db-box1 tbody').length, 'db-box2':$('table#db-box2 tbody').length, 'db-box3':$('table#db-box3 tbody').length} @@ -1311,9 +1320,6 @@ $(function() { cpuchart.render(); netchart.render(); addProperties(); - - $('tr#zfs').show(); - dropdown('enter_share'); diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php index 3fc8d8706..61b6cc00f 100644 --- a/emhttp/plugins/dynamix/include/DashboardApps.php +++ b/emhttp/plugins/dynamix/include/DashboardApps.php @@ -20,6 +20,17 @@ require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php"; require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php"; require_once "$docroot/webGui/include/Helpers.php"; +if (isset($_POST['sys'])) { + extract(parse_plugin_cfg('dynamix',true)); + switch ($_POST['sys']) { + case 0: die(my_scale(exec("awk '/^MemTotal/{t=$2}/^MemAvailable/{a=$2}END{print (t-a)*1024}' /proc/meminfo 2>/dev/null"),$unit,null,-1,1024)." $unit"); + case 1: die(my_scale(exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null")?:0,$unit,null,-1,1024)." $unit"); + case 2: die(my_scale(exec("df --output=used /boot 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"),$unit,null,-1,1024)." $unit"); + case 3: die(my_scale(exec("df --output=used /var/log 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"),$unit,null,-1,1024)." $unit"); + case 4: die(my_scale(exec("df --output=used /var/lib/docker 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"),$unit,null,-1,1024)." $unit"); + } +} + $display = $_POST['display']; if ($_POST['docker'] && ($display=='icons' || $display=='docker')) { From 6f49e66a1acbd4349d5a565fb92b25a9d7773665 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 11:54:31 +0200 Subject: [PATCH 048/239] Dashboard fixes and enhancements --- emhttp/plugins/dynamix/include/DashboardApps.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php index 61b6cc00f..7d601bb85 100644 --- a/emhttp/plugins/dynamix/include/DashboardApps.php +++ b/emhttp/plugins/dynamix/include/DashboardApps.php @@ -44,7 +44,7 @@ if ($_POST['docker'] && ($display=='icons' || $display=='docker')) { foreach ($containers as $ct) $sort[] = array_search($ct['Name'],$prefs) ?? 999; array_multisort($sort,SORT_NUMERIC,$containers); } - echo ""; + echo ""; foreach ($containers as $ct) { $name = $ct['Name']; $id = $ct['Id']; @@ -85,7 +85,7 @@ if ($_POST['vms'] && ($display=='icons' || $display=='vms')) { } else { natcasesort($vms); } - echo ""; + echo ""; foreach ($vms as $vm) { $res = $lv->get_domain_by_name($vm); $uuid = libvirt_domain_get_uuid_string($res); From 504eb0a7413df79b8c06f27b69e79ed8c996cd19 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 11:55:47 +0200 Subject: [PATCH 049/239] Revert "Dashboard fixes and enhancements" This reverts commit 6f49e66a1acbd4349d5a565fb92b25a9d7773665. --- emhttp/plugins/dynamix/include/DashboardApps.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php index 7d601bb85..61b6cc00f 100644 --- a/emhttp/plugins/dynamix/include/DashboardApps.php +++ b/emhttp/plugins/dynamix/include/DashboardApps.php @@ -44,7 +44,7 @@ if ($_POST['docker'] && ($display=='icons' || $display=='docker')) { foreach ($containers as $ct) $sort[] = array_search($ct['Name'],$prefs) ?? 999; array_multisort($sort,SORT_NUMERIC,$containers); } - echo ""; + echo ""; foreach ($containers as $ct) { $name = $ct['Name']; $id = $ct['Id']; @@ -85,7 +85,7 @@ if ($_POST['vms'] && ($display=='icons' || $display=='vms')) { } else { natcasesort($vms); } - echo ""; + echo ""; foreach ($vms as $vm) { $res = $lv->get_domain_by_name($vm); $uuid = libvirt_domain_get_uuid_string($res); From 3d30b5d34fc04f2f7454afd4cddbfca481e61711 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 12:04:02 +0200 Subject: [PATCH 050/239] Dashboard fixes and enhancements --- emhttp/plugins/dynamix/DashStats.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index fe53ffc18..e1a4fcd60 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -1319,7 +1319,6 @@ $(function() { initCharts(); cpuchart.render(); netchart.render(); - addProperties(); dropdown('enter_share'); @@ -1346,5 +1345,6 @@ $(function() { data.txd = txd.tail(netline); $.post('/webGui/include/InitCharts.php',{cmd:'set',data:JSON.stringify(data)}); }); + setTimeout(addProperties,100); }); From 0f653bb31507be5cd42ab9e8fc7b3d23950e3ec4 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 12:06:17 +0200 Subject: [PATCH 051/239] Revert "Dashboard fixes and enhancements" This reverts commit 3d30b5d34fc04f2f7454afd4cddbfca481e61711. --- emhttp/plugins/dynamix/DashStats.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index e1a4fcd60..fe53ffc18 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -1319,6 +1319,7 @@ $(function() { initCharts(); cpuchart.render(); netchart.render(); + addProperties(); dropdown('enter_share'); @@ -1345,6 +1346,5 @@ $(function() { data.txd = txd.tail(netline); $.post('/webGui/include/InitCharts.php',{cmd:'set',data:JSON.stringify(data)}); }); - setTimeout(addProperties,100); }); From 05c70b64f66c583c67029b70615bf70c987227d4 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 12:07:41 +0200 Subject: [PATCH 052/239] Dashboard fixes and enhancements --- emhttp/plugins/dynamix/include/DashboardApps.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php index 61b6cc00f..7d601bb85 100644 --- a/emhttp/plugins/dynamix/include/DashboardApps.php +++ b/emhttp/plugins/dynamix/include/DashboardApps.php @@ -44,7 +44,7 @@ if ($_POST['docker'] && ($display=='icons' || $display=='docker')) { foreach ($containers as $ct) $sort[] = array_search($ct['Name'],$prefs) ?? 999; array_multisort($sort,SORT_NUMERIC,$containers); } - echo ""; + echo ""; foreach ($containers as $ct) { $name = $ct['Name']; $id = $ct['Id']; @@ -85,7 +85,7 @@ if ($_POST['vms'] && ($display=='icons' || $display=='vms')) { } else { natcasesort($vms); } - echo ""; + echo ""; foreach ($vms as $vm) { $res = $lv->get_domain_by_name($vm); $uuid = libvirt_domain_get_uuid_string($res); From 679b4bd48744935477ac5ca77dcd929e5998172b Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 12:22:58 +0200 Subject: [PATCH 053/239] Dashboard fixes and enhancements --- emhttp/plugins/dynamix/include/DashboardApps.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php index 7d601bb85..deec7f103 100644 --- a/emhttp/plugins/dynamix/include/DashboardApps.php +++ b/emhttp/plugins/dynamix/include/DashboardApps.php @@ -21,14 +21,16 @@ require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php"; require_once "$docroot/webGui/include/Helpers.php"; if (isset($_POST['sys'])) { - extract(parse_plugin_cfg('dynamix',true)); switch ($_POST['sys']) { - case 0: die(my_scale(exec("awk '/^MemTotal/{t=$2}/^MemAvailable/{a=$2}END{print (t-a)*1024}' /proc/meminfo 2>/dev/null"),$unit,null,-1,1024)." $unit"); - case 1: die(my_scale(exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null")?:0,$unit,null,-1,1024)." $unit"); - case 2: die(my_scale(exec("df --output=used /boot 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"),$unit,null,-1,1024)." $unit"); - case 3: die(my_scale(exec("df --output=used /var/log 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"),$unit,null,-1,1024)." $unit"); - case 4: die(my_scale(exec("df --output=used /var/lib/docker 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"),$unit,null,-1,1024)." $unit"); + case 0: $size = exec("awk '/^MemTotal/{t=$2}/^MemAvailable/{a=$2}END{print (t-a)*1024}' /proc/meminfo 2>/dev/null"); break; + case 1: $size = exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null")?:0; break; + case 2: $size = exec("df --output=used /boot 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; + case 3: $size = exec("df --output=used /var/log 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; + case 4: $size = exec("df --output=used /var/lib/docker 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; + default: $size = 0; } + extract(parse_plugin_cfg('dynamix',true)); + die(my_scale($size,$unit,null,-1,1024)." $unit"); } $display = $_POST['display']; From 35f4d1bb91ef952bf4eab3067dcb5b2112ca216c Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 12:26:00 +0200 Subject: [PATCH 054/239] Dashboard fixes and enhancements --- emhttp/plugins/dynamix/include/DashboardApps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php index deec7f103..8f9bc08aa 100644 --- a/emhttp/plugins/dynamix/include/DashboardApps.php +++ b/emhttp/plugins/dynamix/include/DashboardApps.php @@ -23,7 +23,7 @@ require_once "$docroot/webGui/include/Helpers.php"; if (isset($_POST['sys'])) { switch ($_POST['sys']) { case 0: $size = exec("awk '/^MemTotal/{t=$2}/^MemAvailable/{a=$2}END{print (t-a)*1024}' /proc/meminfo 2>/dev/null"); break; - case 1: $size = exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null")?:0; break; + case 1: $size = exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null"); break; case 2: $size = exec("df --output=used /boot 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; case 3: $size = exec("df --output=used /var/log 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; case 4: $size = exec("df --output=used /var/lib/docker 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; From 472d21ff168d5715e63a7742b25fa4947f7a5c90 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 19:44:44 +0200 Subject: [PATCH 055/239] rc.library.source smarter ip address listing --- etc/rc.d/rc.library.source | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 147ff1ff5..0ae187aee 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -56,9 +56,9 @@ good() { show() { case $# in - 1) ip addr show to $1 2>/dev/null|grep -Pom1 '^\d+: \K[^:]+';; - 2) ip addr show $1 $2 2>/dev/null|grep -Pom1 'inet6? \K[^ ]+';; - 3) ip $1 addr show $2 $3 2>/dev/null|grep -Pom1 'inet6? \K[^ ]+';; + 1) ip -br addr show to $1 2>/dev/null|awk '{print $1;exit}';; + 2) ip -br addr show $1 $2 2>/dev/null|awk '{print $3;exit}';; + 3) ip -br $1 addr show $2 $3 2>/dev/null|awk '{print $3;exit}';; esac } @@ -144,7 +144,7 @@ check() { else [[ -n ${net[1]} ]] && ipv4=yes bind+=($(sub ${net[1]})) fi - done <<< $(ip -4 addr|awk '/^ +inet/ && $2 !~ "169.254" {print $NF,$2}'|grep -P '^(br|bond|eth|wg)\d+(\.\d+)? ') + done <<< $(ip -br -4 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "169.254" {print $1,$3}') # active ipv6 interfaces (including wireguard) while IFS='\n' read -r net; do net=($net) @@ -153,7 +153,7 @@ check() { else [[ -n ${net[1]} ]] && ipv6=yes bind+=($(sub ${net[1]})) fi - done <<< $(ip -6 addr|awk '/^[0-9]+:|^ +inet6/ && $2 !~ "fe80" {print $2}'|sed ':a;N;$!ba;s/:\n/ /g'|awk '{print $(NF-1),$NF}'|grep -P '^(br|bond|eth|wg)\d+(\.\d+)? ') + done <<< $(ip -br -6 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "fe80" {print $1,$3}') # add loopback interface if [[ "smb nfs ntp" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) From 89d499a801755958e91ab0e8cef5fb3e588cd33a Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 20:04:40 +0200 Subject: [PATCH 056/239] rc.library.source smarter ip address listing --- etc/rc.d/rc.library.source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 0ae187aee..a665c128a 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -57,8 +57,8 @@ good() { show() { case $# in 1) ip -br addr show to $1 2>/dev/null|awk '{print $1;exit}';; - 2) ip -br addr show $1 $2 2>/dev/null|awk '{print $3;exit}';; - 3) ip -br $1 addr show $2 $3 2>/dev/null|awk '{print $3;exit}';; + 2) ip -br addr show $1 $2 2>/dev/null|awk '$3 !~ "169.254" && $3 !~ "fe80" {print $3;exit}';; + 3) ip -br $1 addr show $2 $3 2>/dev/null|awk '$3 !~ "169.254" && $3 !~ "fe80" {print $3;exit}';; esac } From d5a3292b882d53b90d1dcb51545392763c0d88da Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 20:09:11 +0200 Subject: [PATCH 057/239] rc.library.source smarter ip address listing --- etc/rc.d/rc.library.source | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index a665c128a..361f5b448 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -57,8 +57,8 @@ good() { show() { case $# in 1) ip -br addr show to $1 2>/dev/null|awk '{print $1;exit}';; - 2) ip -br addr show $1 $2 2>/dev/null|awk '$3 !~ "169.254" && $3 !~ "fe80" {print $3;exit}';; - 3) ip -br $1 addr show $2 $3 2>/dev/null|awk '$3 !~ "169.254" && $3 !~ "fe80" {print $3;exit}';; + 2) ip -br addr show $1 $2 2>/dev/null|awk '$3 !~ "^169.254" && $3 !~ "^fe80" {print $3;exit}';; + 3) ip -br $1 addr show $2 $3 2>/dev/null|awk '$3 !~ "^169.254" && $3 !~ "^fe80" {print $3;exit}';; esac } @@ -144,7 +144,7 @@ check() { else [[ -n ${net[1]} ]] && ipv4=yes bind+=($(sub ${net[1]})) fi - done <<< $(ip -br -4 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "169.254" {print $1,$3}') + done <<< $(ip -br -4 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^169.254" {print $1,$3}') # active ipv6 interfaces (including wireguard) while IFS='\n' read -r net; do net=($net) @@ -153,7 +153,7 @@ check() { else [[ -n ${net[1]} ]] && ipv6=yes bind+=($(sub ${net[1]})) fi - done <<< $(ip -br -6 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "fe80" {print $1,$3}') + done <<< $(ip -br -6 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^fe80" {print $1,$3}') # add loopback interface if [[ "smb nfs ntp" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) From c9b74705993b84041f537fb49c198b5daa2d5259 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 20:53:28 +0200 Subject: [PATCH 058/239] rc.avahi update --- etc/rc.d/rc.avahidaemon | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/etc/rc.d/rc.avahidaemon b/etc/rc.d/rc.avahidaemon index 1d73c8cf2..786685a09 100755 --- a/etc/rc.d/rc.avahidaemon +++ b/etc/rc.d/rc.avahidaemon @@ -44,13 +44,11 @@ disable() { } avahid_start() { - if [[ -f $NETWORK_INI ]]; then + if check && [[ -n $bind ]]; then # bind avahi service - if check; then - [[ -n $bind ]] && allow $bind || allow br0 - [[ $ipv4 == no ]] && disable ipv4 || enable ipv4 - [[ $ipv6 == no ]] && disable ipv6 || enable ipv6 - fi + [[ -n $bind ]] && allow $bind || allow br0 + [[ $ipv4 == no ]] && disable ipv4 || enable ipv4 + [[ $ipv6 == no ]] && disable ipv6 || enable ipv6 else # default interface with no configuration allow br0 From 4b040466235ca7d42d1583efba40c4e9cba80ae0 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 17 Jun 2023 20:53:48 +0200 Subject: [PATCH 059/239] rc.library correction for avahi service --- etc/rc.d/rc.library.source | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 361f5b448..f2e5eed8e 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -141,6 +141,7 @@ check() { net=($net) if [[ "avahi show" =~ $CALLER ]]; then [[ -n $net ]] && bind+=($net) + [[ -n ${net[1]} ]] && ipv4=yes else [[ -n ${net[1]} ]] && ipv4=yes bind+=($(sub ${net[1]})) fi @@ -150,6 +151,7 @@ check() { net=($net) if [[ "avahi show" =~ $CALLER ]]; then [[ -n $net && -z $(good $net) ]] && bind+=($net) + [[ -n ${net[1]} ]] && ipv6=yes else [[ -n ${net[1]} ]] && ipv6=yes bind+=($(sub ${net[1]})) fi From f2fa1b2f1955c8710bf44bfd3cadd34bee598008 Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 18 Jun 2023 01:28:07 +0200 Subject: [PATCH 060/239] Fix nfsd update --- etc/rc.d/rc.nfsd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/rc.nfsd b/etc/rc.d/rc.nfsd index 964c5d44d..1e28c4ed2 100755 --- a/etc/rc.d/rc.nfsd +++ b/etc/rc.d/rc.nfsd @@ -26,12 +26,8 @@ if check && [[ -n $bind ]]; then RPC_NFSD_OPTS="$OPTIONS -H ${bind// / -H }" fi -# update default settings -sed -ri "s/^(RPC_NFSD_OPTS)=.*/\1=\"$RPC_NFSD_OPTS\"/" $NFS 2>/dev/null - # source default settings: [[ -r $RPC ]] && . $RPC -[[ -r $NFS ]] && . $NFS nfsd_start() { # There used to be "sanity checks" here to exit without starting if various @@ -71,6 +67,9 @@ nfsd_start() { echo " $RQUOTAD $RPC_RQUOTAD_OPTS" $RQUOTAD $RPC_RQUOTAD_OPTS 2>/dev/null fi + # update default settings + sed -ri "s/^(RPC_NFSD_OPTS)=.*/\1=\"$RPC_NFSD_OPTS\"/" $NFS 2>/dev/null + [[ -r $NFS ]] && . $NFS # start nfsd servers - 8 if not set extrawise (an old Sun standard): if [[ -x $NFSD ]]; then [[ -z $RPC_NFSD_COUNT ]] && RPC_NFSD_COUNT=8 @@ -103,6 +102,9 @@ nfsd_reload() { killall -9 nfsd 2>/dev/null sleep 1 [[ -z $RPC_NFSD_COUNT ]] && RPC_NFSD_COUNT=8 + # update default settings + sed -ri "s/^(RPC_NFSD_OPTS)=.*/\1=\"$RPC_NFSD_OPTS\"/" $NFS 2>/dev/null + [[ -r $NFS ]] && . $NFS $NFSD $RPC_NFSD_OPTS $RPC_NFSD_COUNT 2>/dev/null } From 9965273d2124c82157cb6dd29b3c037571b6ed3d Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 18 Jun 2023 01:28:17 +0200 Subject: [PATCH 061/239] Fix prc update --- etc/rc.d/rc.rpc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/etc/rc.d/rc.rpc b/etc/rc.d/rc.rpc index 5a1008e58..84dc72fb5 100755 --- a/etc/rc.d/rc.rpc +++ b/etc/rc.d/rc.rpc @@ -25,14 +25,11 @@ if check && [[ -n $bind ]]; then RPCBIND_OPTS="-h ${bind// / -h }" fi -# update default settings -sed -ri "s/^#?(RPCBIND_OPTS)=.*/\1=\"$RPCBIND_OPTS\"/" $RPC 2>/dev/null - -# source default settings: -[[ -r $RPC ]] && . $RPC - rpc_start() { if [[ -x $RPCBIND && -x $STATD ]]; then + # update default settings + sed -ri "s/^#?(RPCBIND_OPTS)=.*/\1=\"$RPCBIND_OPTS\"/" $RPC 2>/dev/null + [[ -r $RPC ]] && . $RPC # Set up port for lockd: if [[ -n $LOCKD_TCP_PORT ]]; then /sbin/sysctl -w "fs.nfs.nlm_tcpport=$LOCKD_TCP_PORT" 2>/dev/null @@ -80,6 +77,9 @@ rpc_restart() { rpc_reload() { killall -9 rpcbind 2>/dev/null sleep 1 + # update default settings + sed -ri "s/^#?(RPCBIND_OPTS)=.*/\1=\"$RPCBIND_OPTS\"/" $RPC 2>/dev/null + [[ -r $RPC ]] && . $RPC $RPCBIND -w $RPCBIND_OPTS 2>/dev/null } From 0e14320c9624c9babaf51f6e9394890b154e5f6d Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 18 Jun 2023 01:44:47 +0200 Subject: [PATCH 062/239] Dashboard: remove enhancements Only fixes are included --- emhttp/plugins/dynamix/DashStats.page | 8 ++------ emhttp/plugins/dynamix/include/DashboardApps.php | 13 ------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index fe53ffc18..9e26fd6a6 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -219,7 +219,6 @@ i#mycase[class^="case-"]{font-size:128px} i#mycase[class^="fa "]{font-size:96px} a.cpu_close,span.hand{cursor:pointer;z-index:1001} tr#var1,tr#var4,tr#cpu_chart,.cpu_open{display:none} -tr#var0,tr#var1,tr#var2,tr#var3,tr#var4{cursor:alias} td.none{text-align:center;padding-top:12px} input[value=Edit]{margin:12px 0 0 0;padding:5px 10px} .share1,.share3,.user1,.user3,.view1,.view2,.view3,.view4{display:none} @@ -1057,14 +1056,11 @@ function addProperties() { $(this).find('td:first').prepend(""); }); $('div.frame tr').attr('title',''); - $('tr#var0').hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:0},function(val){$('.sys0').text(val);})}); - $('tr#var1').show().hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:1},function(val){$('.sys1').text(val);})}); + $('tr#var1').show(); - $('tr#var2').hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:2},function(val){$('.sys2').text(val);})}); - $('tr#var3').hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:3},function(val){$('.sys3').text(val);})}); - $('tr#var4').show().hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:4},function(val){$('.sys4').text(val);})}); + $('tr#var4').show(); } function showContent() { diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php index 8f9bc08aa..c9f47105e 100644 --- a/emhttp/plugins/dynamix/include/DashboardApps.php +++ b/emhttp/plugins/dynamix/include/DashboardApps.php @@ -20,19 +20,6 @@ require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php"; require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php"; require_once "$docroot/webGui/include/Helpers.php"; -if (isset($_POST['sys'])) { - switch ($_POST['sys']) { - case 0: $size = exec("awk '/^MemTotal/{t=$2}/^MemAvailable/{a=$2}END{print (t-a)*1024}' /proc/meminfo 2>/dev/null"); break; - case 1: $size = exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null"); break; - case 2: $size = exec("df --output=used /boot 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; - case 3: $size = exec("df --output=used /var/log 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; - case 4: $size = exec("df --output=used /var/lib/docker 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; - default: $size = 0; - } - extract(parse_plugin_cfg('dynamix',true)); - die(my_scale($size,$unit,null,-1,1024)." $unit"); -} - $display = $_POST['display']; if ($_POST['docker'] && ($display=='icons' || $display=='docker')) { From 384fa10575682a3a6b24d529b78203fd422c23c1 Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 18 Jun 2023 01:55:51 +0200 Subject: [PATCH 063/239] Revised service reload functionality This approach ensures the services are only reloaded once and not multiple times as happened before --- .../plugins/dynamix/scripts/reload_services | 5 +++-- sbin/create_network_ini | 22 +++---------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index ad65270fc..4823f94f7 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -1,10 +1,11 @@ #!/bin/bash SERVICES="sshd avahidaemon samba rpc nfsd ntpd nginx" +[[ -n $1 && -e /tmp/atjob.tmp ]] && exit 0 for cmd in $SERVICES; do - [[ $cmd == $1 ]] && option=renew || option=reload if /etc/rc.d/rc.$cmd update; then - /etc/rc.d/rc.$cmd $option >/dev/null 2>&1 + /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 fi done +touch /tmp/atjob.tmp exit 0 diff --git a/sbin/create_network_ini b/sbin/create_network_ini index fb5b9bf77..a00de00b6 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -44,13 +44,6 @@ fi echo -n >$ini # clear update information data= -dhcp= -# get interface name -if [[ -n $1 ]]; then - tag=$1 -else - tag=$interface -fi # loop thru all defined interfaces (=1 in case of legacy) for ((i=0;i<${SYSNICS:-1};i++)); do @@ -123,7 +116,6 @@ for ((i=0;i<${SYSNICS:-1};i++)); do echo "DESCRIPTION:0=\"${DESCRIPTION[$i]}\"" >>$ini echo "PROTOCOL:0=\"${PROTOCOL[$i]}\"" >>$ini echo "USE_DHCP:0=\"${USE_DHCP[$i]}\"" >>$ini - flag= if [[ ${USE_DHCP[$i]} == yes ]]; then # get dhcp assigned ipv4 address & mask NET=($(ip -4 addr show $IFACE|awk '/inet /{sub("/"," ",$2);print $2;exit}')) @@ -140,7 +132,6 @@ for ((i=0;i<${SYSNICS:-1};i++)); do ((x++)) done fi - [[ "${PROTOCOL[$i]}" == *"ipv4"* ]] && flag=1 else # get static assigned ipv4 address & mask echo "IPADDR:0=\"${IPADDR[$i]}\"" >>$ini @@ -166,7 +157,6 @@ for ((i=0;i<${SYSNICS:-1};i++)); do ((x++)) done fi - [[ "${PROTOCOL[$i]}" == *"ipv6"* ]] && flag=1 else # get static assigned ipv6 address & prefix echo "IPADDR6:0=\"${IPADDR6[$i]}\"" >>$ini @@ -175,7 +165,6 @@ for ((i=0;i<${SYSNICS:-1};i++)); do echo "METRIC6:0=\"${METRIC6[$i]}\"" >>$ini echo "PRIVACY6:0=\"\"" >>$ini fi - [[ -n $flag && ($tag == $IFACE || $tag == init) ]] && dhcp=1 echo "MTU=\"${MTU[$i]}\"" >>$ini if [[ -n ${VLANS[$i]} ]]; then # process VLAN interfaces @@ -185,7 +174,6 @@ for ((i=0;i<${SYSNICS:-1};i++)); do echo "DESCRIPTION:$j=\"${DESCRIPTION[$i,$j]}\"" >>$ini echo "PROTOCOL:$j=\"${PROTOCOL[$i,$j]}\"" >>$ini echo "USE_DHCP:$j=\"${USE_DHCP[$i,$j]}\"" >>$ini - flag= if [[ ${USE_DHCP[$i,$j]} == yes ]]; then DEV=$IFACE.${VLANID[$i,$j]} # get dhcp assigned ipv4 address & mask @@ -196,7 +184,6 @@ for ((i=0;i<${SYSNICS:-1};i++)); do echo "GATEWAY:$j=\"$GW\"" >>$ini echo "METRIC:$j=\"${METRIC[$i,$j]}\"" >>$ini data="${data}${ETH}_I_IPADDR:$j=${NET[0]} ${ETH}_S_NETMASK:$j=$(mask ${NET[1]}) ${ETH}_I_GATEWAY:$j=$GW " - [[ "${PROTOCOL[$i,$j]}" == *"ipv4"* ]] && flag=1 else # get static assigned ipv4 address & mask echo "IPADDR:$j=\"${IPADDR[$i,$j]}\"" >>$ini @@ -216,7 +203,6 @@ for ((i=0;i<${SYSNICS:-1};i++)); do echo "METRIC6:$j=\"${METRIC6[$i,$j]}\"" >>$ini echo "PRIVACY6:$j=\"${PRIVACY6[$i,$j]}\"" >>$ini data="${data}${ETH}_I_IPADDR6:$j=${NET6[0]} ${ETH}_I_NETMASK6:$j=${NET6[1]} ${ETH}_I_GATEWAY6:$j=$GW6 " - [[ "${PROTOCOL[$i,$j]}" == *"ipv6"* ]] && flag=1 else # get static assigned ipv6 address & prefix echo "IPADDR6:$j=\"${IPADDR6[$i,$j]}\"" >>$ini @@ -225,7 +211,6 @@ for ((i=0;i<${SYSNICS:-1};i++)); do echo "METRIC6:$j=\"${METRIC6[$i,$j]}\"" >>$ini echo "PRIVACY6:$j=\"\"" >>$ini fi - [[ -n $flag && ($tag == $IFACE || $tag == init) ]] && dhcp=1 done else # interface without VLANs @@ -235,10 +220,9 @@ done # atomically update file /usr/bin/mv $ini ${ini%.*} -# the following section is executed on static only or on dhcp hook -if [[ (-n $1 && -z $dhcp) || (-z $1 && -n $dhcp) ]]; then - $reload >/dev/null 2>&1 & -fi +# delayed execution +rm -f /tmp/atjob.tmp +echo "sleep 40;$reload job"|at -M now 2>/dev/null # send update information if [[ -n $interface && -n $data && -e /var/run/nginx.socket ]]; then From c2065a3d936dc69a24b7646ace11324526059123 Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 18 Jun 2023 03:45:26 +0200 Subject: [PATCH 064/239] Revised service reload functionality --- emhttp/plugins/dynamix/scripts/reload_services | 5 +++-- sbin/create_network_ini | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index 4823f94f7..05fc9e836 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -1,11 +1,12 @@ #!/bin/bash SERVICES="sshd avahidaemon samba rpc nfsd ntpd nginx" +job=/tmp/atjob.tmp -[[ -n $1 && -e /tmp/atjob.tmp ]] && exit 0 +[[ -n $1 && -e $job ]] && exit 0 for cmd in $SERVICES; do if /etc/rc.d/rc.$cmd update; then /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 fi done -touch /tmp/atjob.tmp +touch $job exit 0 diff --git a/sbin/create_network_ini b/sbin/create_network_ini index a00de00b6..8072f0ac2 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -11,6 +11,7 @@ ini=/var/local/emhttp/network.ini.new cfg=/boot/config/network.cfg +job=/tmp/atjob.tmp reload=/usr/local/emhttp/webGui/scripts/reload_services declare -A VLANID USE_DHCP IPADDR NETMASK GATEWAY METRIC USE_DHCP6 IPADDR6 NETMASK6 GATEWAY6 PRIVACY6 METRIC6 DESCRIPTION PROTOCOL @@ -221,8 +222,8 @@ done /usr/bin/mv $ini ${ini%.*} # delayed execution -rm -f /tmp/atjob.tmp -echo "sleep 40;$reload job"|at -M now 2>/dev/null +rm -f $job +echo "sleep 35;$reload job"|at -M now 2>/dev/null # send update information if [[ -n $interface && -n $data && -e /var/run/nginx.socket ]]; then From 29dd4db86776c2c2d99e645c522221d23b738be3 Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 18 Jun 2023 04:09:28 +0200 Subject: [PATCH 065/239] Revised service reload functionality --- emhttp/plugins/dynamix/scripts/reload_services | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index 05fc9e836..2d91748b4 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -3,10 +3,10 @@ SERVICES="sshd avahidaemon samba rpc nfsd ntpd nginx" job=/tmp/atjob.tmp [[ -n $1 && -e $job ]] && exit 0 +touch $job for cmd in $SERVICES; do if /etc/rc.d/rc.$cmd update; then /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 fi done -touch $job exit 0 From fa3532e46f2e858e7396a03b2fc12a7ff67e9637 Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 18 Jun 2023 17:23:14 +0200 Subject: [PATCH 066/239] Revised service reload functionality --- emhttp/plugins/dynamix/scripts/reload_services | 3 +-- sbin/create_network_ini | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index 2d91748b4..41ebc59bb 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -2,11 +2,10 @@ SERVICES="sshd avahidaemon samba rpc nfsd ntpd nginx" job=/tmp/atjob.tmp -[[ -n $1 && -e $job ]] && exit 0 -touch $job for cmd in $SERVICES; do if /etc/rc.d/rc.$cmd update; then /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 fi done +rm -f $job exit 0 diff --git a/sbin/create_network_ini b/sbin/create_network_ini index 8072f0ac2..f90d84bf3 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -222,8 +222,10 @@ done /usr/bin/mv $ini ${ini%.*} # delayed execution -rm -f $job -echo "sleep 35;$reload job"|at -M now 2>/dev/null +if [[ ! -f $job ]]; then + echo "sleep 35;$reload"|at -M now 2>/dev/null + touch $job +fi # send update information if [[ -n $interface && -n $data && -e /var/run/nginx.socket ]]; then From 64c5690b068c9c3561a9d8c8ea56e6063db2a9d7 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 06:45:49 +0200 Subject: [PATCH 067/239] Revert "Revised service reload functionality" This reverts commit fa3532e46f2e858e7396a03b2fc12a7ff67e9637. --- emhttp/plugins/dynamix/scripts/reload_services | 3 ++- sbin/create_network_ini | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index 41ebc59bb..2d91748b4 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -2,10 +2,11 @@ SERVICES="sshd avahidaemon samba rpc nfsd ntpd nginx" job=/tmp/atjob.tmp +[[ -n $1 && -e $job ]] && exit 0 +touch $job for cmd in $SERVICES; do if /etc/rc.d/rc.$cmd update; then /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 fi done -rm -f $job exit 0 diff --git a/sbin/create_network_ini b/sbin/create_network_ini index f90d84bf3..8072f0ac2 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -222,10 +222,8 @@ done /usr/bin/mv $ini ${ini%.*} # delayed execution -if [[ ! -f $job ]]; then - echo "sleep 35;$reload"|at -M now 2>/dev/null - touch $job -fi +rm -f $job +echo "sleep 35;$reload job"|at -M now 2>/dev/null # send update information if [[ -n $interface && -n $data && -e /var/run/nginx.socket ]]; then From bb3c0c0b9a299adb8fe2c1d0a8293f5fa51ac781 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 08:48:08 +0200 Subject: [PATCH 068/239] NTP: fix listening interfaces --- etc/rc.d/rc.library.source | 2 +- etc/rc.d/rc.ntpd | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index f2e5eed8e..6bbb5dc8a 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -157,7 +157,7 @@ check() { fi done <<< $(ip -br -6 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^fe80" {print $1,$3}') # add loopback interface - if [[ "smb nfs ntp" =~ $CALLER ]]; then + if [[ "smb nfs" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) [[ $ipv6 == yes ]] && bind+=(::1) fi diff --git a/etc/rc.d/rc.ntpd b/etc/rc.d/rc.ntpd index 02c91cede..f9319ae41 100755 --- a/etc/rc.d/rc.ntpd +++ b/etc/rc.d/rc.ntpd @@ -21,12 +21,10 @@ build_ntp() { # ignore unused protocol [[ $ipv4 == no ]] && echo "interface ignore ipv4" >>$CONF [[ $ipv6 == no ]] && echo "interface ignore ipv6" >>$CONF - # for now do not bind interfaces - # it is not clear why NTP is started several times and fails to bind on occasion # add listen interfaces - #for net in $bind; do - # echo "interface listen $net" >>$CONF - #done + for net in $bind; do + echo "interface listen $net" >>$CONF + done fi # add configured NTP servers [[ -n $NTP_SERVER1 ]] && echo "server $NTP_SERVER1 iburst" >>$CONF From 1070b46d3e8689c403dd4d51b551ca4edacf92e0 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 09:32:34 +0200 Subject: [PATCH 069/239] NTP: fix listening interfaces --- etc/rc.d/rc.ntpd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.ntpd b/etc/rc.d/rc.ntpd index f9319ae41..71c6d38c8 100755 --- a/etc/rc.d/rc.ntpd +++ b/etc/rc.d/rc.ntpd @@ -92,7 +92,7 @@ ntpd_reload() { ntpd_update() { [[ $(pgrep -cf $NTPD) -eq 0 ]] && exit 1 # not running - if check && [[ -z "$(this 'interface listen')" || "$(this 'interface listen')" == "$bind" ]]; then + if check && [[ "$(this 'interface listen')" == "$bind" ]]; then # no action required exit 1 else From cbbdc001e268429167bb5ae464dfa08bb7065511 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 09:35:45 +0200 Subject: [PATCH 070/239] Dashboard: show ZFS percentage based on c_max value --- emhttp/plugins/dynamix/nchan/update_1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix/nchan/update_1 b/emhttp/plugins/dynamix/nchan/update_1 index 429a33e96..dc1a416bb 100755 --- a/emhttp/plugins/dynamix/nchan/update_1 +++ b/emhttp/plugins/dynamix/nchan/update_1 @@ -17,16 +17,15 @@ $varroot = '/var/local/emhttp'; require_once "$docroot/webGui/include/publish.php"; while (true) { - unset($memory,$sys,$rpms,$lsof); + unset($memory,$sys,$zfs,$rpms,$lsof); exec("grep -Po '^Mem(Total|Available):\s+\K\d+' /proc/meminfo",$memory); exec("df /boot /var/log /var/lib/docker|grep -Po '\d+%'",$sys); exec("sensors -uA 2>/dev/null|grep -Po 'fan\d_input: \K\d+'",$rpms); + exec("awk '/^c_max|^size/{print \$3}' /proc/spl/kstat/zfs/arcstats 2>/dev/null",$zfs); [$total,$free] = $memory; $used = $total-$free; - $zfs = (exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null")?:0)/1024; - $info = max(round(100*(1-$free/$total)),0)."%\0".round(100*$zfs/$used)."%\0".implode("\0",$sys); + $info = max(round(100*(1-$free/$total)),0)."%\0".round(100*($zfs[1]?:0)/($zfs[0]?:1))."%\0".implode("\0",$sys); $rpms = count($rpms) ? implode(" RPM\0",$rpms).' RPM' : ''; - $names = array_keys((array)parse_ini_file("$varroot/shares.ini")); exec("LANG='en_US.UTF8' lsof -Owl /mnt/disk[0-9]* 2>/dev/null|awk '/^shfs/ && \$0!~/\.AppleD(B|ouble)/ && \$5==\"REG\"'|awk -F/ '{print \$4}'",$lsof); $counts = array_count_values($lsof); $count = []; From 002327476bcba7c2a57608edf15b028a1b6fe55a Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 09:41:33 +0200 Subject: [PATCH 071/239] Dashboard: show ZFS percentage based on c_max value --- emhttp/plugins/dynamix/nchan/update_1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/nchan/update_1 b/emhttp/plugins/dynamix/nchan/update_1 index dc1a416bb..3937a3830 100755 --- a/emhttp/plugins/dynamix/nchan/update_1 +++ b/emhttp/plugins/dynamix/nchan/update_1 @@ -24,7 +24,7 @@ while (true) { exec("awk '/^c_max|^size/{print \$3}' /proc/spl/kstat/zfs/arcstats 2>/dev/null",$zfs); [$total,$free] = $memory; $used = $total-$free; - $info = max(round(100*(1-$free/$total)),0)."%\0".round(100*($zfs[1]?:0)/($zfs[0]?:1))."%\0".implode("\0",$sys); + $info = max(round(100*(1-$free/$total)),0)."%\0".round(100*($zfs[1]??0)/($zfs[0]??1))."%\0".implode("\0",$sys); $rpms = count($rpms) ? implode(" RPM\0",$rpms).' RPM' : ''; $names = array_keys((array)parse_ini_file("$varroot/shares.ini")); exec("LANG='en_US.UTF8' lsof -Owl /mnt/disk[0-9]* 2>/dev/null|awk '/^shfs/ && \$0!~/\.AppleD(B|ouble)/ && \$5==\"REG\"'|awk -F/ '{print \$4}'",$lsof); From 87475a8f47fdd0b952e4767511a2d8a217801dc1 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 19:54:09 +0200 Subject: [PATCH 072/239] rc updates NTP: exclude WG tunnels and user defined interfaces NTP: add interface name in config SSH: add interface name in config --- etc/rc.d/rc.library.source | 19 +++++++++++++------ etc/rc.d/rc.ntpd | 2 +- etc/rc.d/rc.sshd | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 6bbb5dc8a..8db332b46 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -21,7 +21,7 @@ this() { grep -Pom1 "^$1 = \K.*" $CONF ;; 'ntp'|'ssh') - grep -Po "^$1 \K.*" $CONF|tr '\n' ' '|sed 's/ $//' + grep -Po "^$1 \K\S+" $CONF|tr '\n' ' '|sed 's/ $//' ;; 'nfs') grep -Pom1 "^RPC_NFSD_OPTS=\"$OPTIONS \K[^\"]+" $NFS @@ -87,7 +87,7 @@ extra_name() { for net in $include_interfaces; do if $(isname $net); then # net is an interface name, validate - [[ -n $(show dev $net) && -z $(good $net) ]] && bind+=($net) + [[ $CALLER != ntp && -n $(show dev $net) && -z $(good $net) ]] && bind+=($net) else # net is an IP address, convert to name net=$(show $net) @@ -116,8 +116,8 @@ extra_addr() { net4=$(show -4 to $net) net6=$(show -6 to $net) fi - [[ -n $net4 && -z $(good $(sub $net4)) ]] && ipv4=yes bind+=($(sub $net4)) - [[ -n $net6 && -z $(good $(sub $net6)) ]] && ipv6=yes bind+=($(sub $net6)) + [[ $CALLER != ntp && -n $net4 && -z $(good $(sub $net4)) ]] && ipv4=yes bind+=($(sub $net4)) + [[ $CALLER != ntp && -n $net6 && -z $(good $(sub $net6)) ]] && ipv6=yes bind+=($(sub $net6)) done for net in $exclude_interfaces; do if $(isname $net); then @@ -143,7 +143,10 @@ check() { [[ -n $net ]] && bind+=($net) [[ -n ${net[1]} ]] && ipv4=yes else - [[ -n ${net[1]} ]] && ipv4=yes bind+=($(sub ${net[1]})) + # exclude wireguard tunnels for ntp + [[ $CALLER == ntp ]] && name=$(show ${net[1]}) || name= + [[ ${name:0:2} == wg ]] && wg=no || wg=yes + [[ $wg == yes && -n ${net[1]} ]] && ipv4=yes bind+=($(sub ${net[1]})) fi done <<< $(ip -br -4 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^169.254" {print $1,$3}') # active ipv6 interfaces (including wireguard) @@ -153,7 +156,11 @@ check() { [[ -n $net && -z $(good $net) ]] && bind+=($net) [[ -n ${net[1]} ]] && ipv6=yes else - [[ -n ${net[1]} ]] && ipv6=yes bind+=($(sub ${net[1]})) + name=$(show ${net[1]}) + # exclude wireguard tunnels for ntp + [[ $CALLER == ntp ]] && name=$(show ${net[1]}) || name= + [[ ${name:0:2} == wg ]] && wg=no || wg=yes + [[ $wg == yes && -n ${net[1]} ]] && ipv6=yes bind+=($(sub ${net[1]})) fi done <<< $(ip -br -6 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^fe80" {print $1,$3}') # add loopback interface diff --git a/etc/rc.d/rc.ntpd b/etc/rc.d/rc.ntpd index 71c6d38c8..aec0cd440 100755 --- a/etc/rc.d/rc.ntpd +++ b/etc/rc.d/rc.ntpd @@ -23,7 +23,7 @@ build_ntp() { [[ $ipv6 == no ]] && echo "interface ignore ipv6" >>$CONF # add listen interfaces for net in $bind; do - echo "interface listen $net" >>$CONF + echo "interface listen $net # $(show $net)" >>$CONF done fi # add configured NTP servers diff --git a/etc/rc.d/rc.sshd b/etc/rc.d/rc.sshd index b0a9e84d0..f3c4ca8c3 100755 --- a/etc/rc.d/rc.sshd +++ b/etc/rc.d/rc.sshd @@ -18,7 +18,7 @@ build_ssh() { sed -ri '/^#?(ListenAddress|AddressFamily) /d' $CONF # create new entries (in reverse order) for i in $(seq $((${#bind[@]}-1)) -1 0); do - sed -ri "/^#?Port /a ListenAddress ${bind[$i]}" $CONF + sed -ri "/^#?Port /a ListenAddress ${bind[$i]} # $(show ${bind[$i]})" $CONF done sed -ri "/^#?Port /a AddressFamily $family" $CONF fi From 09431bf07d20ea9ec611384fb82c510003af975a Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 19:57:29 +0200 Subject: [PATCH 073/239] Update rc.library.source --- etc/rc.d/rc.library.source | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 8db332b46..c0bb831a6 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -156,7 +156,6 @@ check() { [[ -n $net && -z $(good $net) ]] && bind+=($net) [[ -n ${net[1]} ]] && ipv6=yes else - name=$(show ${net[1]}) # exclude wireguard tunnels for ntp [[ $CALLER == ntp ]] && name=$(show ${net[1]}) || name= [[ ${name:0:2} == wg ]] && wg=no || wg=yes From 3c28f34b95fe4f705dcb8ee4d17c063202dc8059 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 20:03:16 +0200 Subject: [PATCH 074/239] Update rc.library.source --- etc/rc.d/rc.library.source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index c0bb831a6..7ea33e6be 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -91,7 +91,7 @@ extra_name() { else # net is an IP address, convert to name net=$(show $net) - [[ -n $net && -z $(good $net) ]] && bind+=($net) + [[ $CALLER != ntp && -n $net && -z $(good $net) ]] && bind+=($net) fi done for net in $exclude_interfaces; do From a40e38af45abbbca23ff1ab037cbbc35de2d9caa Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 20:11:55 +0200 Subject: [PATCH 075/239] Update rc.library.source --- etc/rc.d/rc.library.source | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 7ea33e6be..9008ac3c2 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -145,8 +145,7 @@ check() { else # exclude wireguard tunnels for ntp [[ $CALLER == ntp ]] && name=$(show ${net[1]}) || name= - [[ ${name:0:2} == wg ]] && wg=no || wg=yes - [[ $wg == yes && -n ${net[1]} ]] && ipv4=yes bind+=($(sub ${net[1]})) + [[ ${name:0:2} != wg && -n ${net[1]} ]] && ipv4=yes bind+=($(sub ${net[1]})) fi done <<< $(ip -br -4 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^169.254" {print $1,$3}') # active ipv6 interfaces (including wireguard) @@ -158,8 +157,7 @@ check() { else # exclude wireguard tunnels for ntp [[ $CALLER == ntp ]] && name=$(show ${net[1]}) || name= - [[ ${name:0:2} == wg ]] && wg=no || wg=yes - [[ $wg == yes && -n ${net[1]} ]] && ipv6=yes bind+=($(sub ${net[1]})) + [[ ${name:0:2} != wg && -n ${net[1]} ]] && ipv6=yes bind+=($(sub ${net[1]})) fi done <<< $(ip -br -6 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^fe80" {print $1,$3}') # add loopback interface From 9ee4b20225e914e0300d45c15451a896de70e6a0 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 19 Jun 2023 23:31:07 +0200 Subject: [PATCH 076/239] Dashboard: suppress coloring of ZFS utilization bar --- emhttp/plugins/dynamix/DashStats.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index 9e26fd6a6..abaa83c92 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -1200,7 +1200,7 @@ dashboard.on('message',function(msg,meta) { // memory & disk load $.each(part[0].split('\0'),function(k,v) { var load = v.slice(0,-1); - var color = setColor(load,,); + var color = k==1 ? '' : setColor(load,,); $('.sys'+k).text(v); $('#sys'+k).finish().animate({width:v},{step:function(){$('#sys'+k).css('overflow','visible').removeClass().addClass(color);}}); }); From 9e2d24460a414d65913b23a2b473d0cd94e3b5e2 Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 21 Jun 2023 18:04:29 +0200 Subject: [PATCH 077/239] RC services update 1. NFS - fix service reload 2. RPC - fix service reload 3. NGINX - remove HTTPS port in FQDN redirect when default 443 4. All services - register IPv4 Link local assignment (169.254.xxx.xxx) 5. All services - make lock file programmable --- emhttp/plugins/dynamix/scripts/reload_services | 6 +++--- etc/rc.d/rc.library.source | 8 ++++---- etc/rc.d/rc.nfsd | 9 ++------- etc/rc.d/rc.nginx | 2 +- etc/rc.d/rc.rpc | 8 ++------ sbin/create_network_ini | 2 +- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index 2d91748b4..36361190e 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -1,9 +1,9 @@ #!/bin/bash SERVICES="sshd avahidaemon samba rpc nfsd ntpd nginx" -job=/tmp/atjob.tmp -[[ -n $1 && -e $job ]] && exit 0 -touch $job +if [[ -n $1 ]]; then + [[ ! -e $1 ]] && touch $1 || exit 0 +fi for cmd in $SERVICES; do if /etc/rc.d/rc.$cmd update; then /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 9008ac3c2..3e071f204 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -49,7 +49,7 @@ scan() { good() { data=; for i in ${!bind[@]}; do - [[ ${bind[$i]} == $1 || ${1:0:7} == 169.254 || ${1:0:4} == fe80 ]] && data=$1 + [[ ${bind[$i]} == $1 || ${1:0:4} == fe80 ]] && data=$1 done echo $data } @@ -57,8 +57,8 @@ good() { show() { case $# in 1) ip -br addr show to $1 2>/dev/null|awk '{print $1;exit}';; - 2) ip -br addr show $1 $2 2>/dev/null|awk '$3 !~ "^169.254" && $3 !~ "^fe80" {print $3;exit}';; - 3) ip -br $1 addr show $2 $3 2>/dev/null|awk '$3 !~ "^169.254" && $3 !~ "^fe80" {print $3;exit}';; + 2) ip -br addr show $1 $2 2>/dev/null|awk '$3 !~ "^fe80" {print $3;exit}';; + 3) ip -br $1 addr show $2 $3 2>/dev/null|awk '$3 !~ "^fe80" {print $3;exit}';; esac } @@ -147,7 +147,7 @@ check() { [[ $CALLER == ntp ]] && name=$(show ${net[1]}) || name= [[ ${name:0:2} != wg && -n ${net[1]} ]] && ipv4=yes bind+=($(sub ${net[1]})) fi - done <<< $(ip -br -4 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^169.254" {print $1,$3}') + done <<< $(ip -br -4 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ {print $1,$3}') # active ipv6 interfaces (including wireguard) while IFS='\n' read -r net; do net=($net) diff --git a/etc/rc.d/rc.nfsd b/etc/rc.d/rc.nfsd index 1e28c4ed2..7eb9bf129 100755 --- a/etc/rc.d/rc.nfsd +++ b/etc/rc.d/rc.nfsd @@ -99,13 +99,8 @@ nfsd_restart() { } nfsd_reload() { - killall -9 nfsd 2>/dev/null - sleep 1 - [[ -z $RPC_NFSD_COUNT ]] && RPC_NFSD_COUNT=8 - # update default settings - sed -ri "s/^(RPC_NFSD_OPTS)=.*/\1=\"$RPC_NFSD_OPTS\"/" $NFS 2>/dev/null - [[ -r $NFS ]] && . $NFS - $NFSD $RPC_NFSD_OPTS $RPC_NFSD_COUNT 2>/dev/null + # restart without info + nfsd_restart 1>/dev/null 2>&1 } nfsd_update() { diff --git a/etc/rc.d/rc.nginx b/etc/rc.d/rc.nginx index 2af7b4863..f246ddf25 100755 --- a/etc/rc.d/rc.nginx +++ b/etc/rc.d/rc.nginx @@ -103,7 +103,7 @@ redirect() { if [[ -n $host ]]; then echo "server {" echo "${t}listen $host:$*; # $(show $addr)" - echo "${t}return 302 https://$(fqdn $addr):$PORTSSL\$request_uri;" + echo "${t}return 302 https://$(fqdn $addr)$PORTSSL_URL\$request_uri;" echo "}" fi done diff --git a/etc/rc.d/rc.rpc b/etc/rc.d/rc.rpc index 84dc72fb5..74c77ce37 100755 --- a/etc/rc.d/rc.rpc +++ b/etc/rc.d/rc.rpc @@ -75,12 +75,8 @@ rpc_restart() { } rpc_reload() { - killall -9 rpcbind 2>/dev/null - sleep 1 - # update default settings - sed -ri "s/^#?(RPCBIND_OPTS)=.*/\1=\"$RPCBIND_OPTS\"/" $RPC 2>/dev/null - [[ -r $RPC ]] && . $RPC - $RPCBIND -w $RPCBIND_OPTS 2>/dev/null + # restart without info + rpc_restart 1>/dev/null 2>&1 } rpc_update() { diff --git a/sbin/create_network_ini b/sbin/create_network_ini index 8072f0ac2..4aa865f3d 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -223,7 +223,7 @@ done # delayed execution rm -f $job -echo "sleep 35;$reload job"|at -M now 2>/dev/null +echo "sleep 35;$reload $job"|at -M now 2>/dev/null # send update information if [[ -n $interface && -n $data && -e /var/run/nginx.socket ]]; then From 1f0e326f8166d29c88a8281328131ae0f9756f15 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 22 Jun 2023 21:13:38 +0200 Subject: [PATCH 078/239] Dashboard updates - Re-introduce show/hide tile content - Add new icon function to show/hide all content at once - Reduce gap between columns --- emhttp/plugins/dynamix/DashStats.page | 295 ++++++++++++++---- .../plugins/dynamix/include/DashboardApps.php | 13 + 2 files changed, 242 insertions(+), 66 deletions(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index abaa83c92..b9b6fdf7e 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -174,20 +174,21 @@ switch ($display['theme']) { "> @@ -237,8 +241,9 @@ input[value=Edit]{margin:12px 0 0 0;padding:5px 10px}
- - - - + @@ -308,7 +313,7 @@ foreach ($cpus as $pair) { - @@ -319,7 +324,7 @@ foreach ($cpus as $pair) { - + - @@ -386,7 +391,7 @@ foreach ($ports as $port) { @@ -400,7 +405,7 @@ foreach ($ports as $port) { -"; - - + - - + - - class="mixed"> +"; +
+ +
+ - - class="mixed"> + - + + - @@ -598,8 +621,9 @@ if (!$group) { - @@ -608,7 +632,10 @@ if (!$group) { - + @@ -675,18 +702,61 @@ function hideShow() { Number.prototype.pad = function(size){var s=String(this);while(s.length<(size||2)){s='0'+s;}return s;} Array.prototype.tail = function(t){return this.slice(-t).map(function(o){return o.y;}).join(';');} String.prototype.build = function(){return this.replace(/\n()\n/g,'');} -String.prototype.marker = function(){return this.substr(0,12).replace(/ /g,'').toLowerCase();} +String.prototype.md5 = function() { + // Original copyright (c) Paul Johnston & Greg Holt. + var hc = '0123456789abcdef'; + function rh(n){var j,s='';for(j=0;j<=3;j++) s+=hc.charAt((n>>(j*8+4))&0x0F)+hc.charAt((n>>(j*8))&0x0F);return s;} + function ad(x,y){var l=(x&0xFFFF)+(y&0xFFFF);var m=(x>>16)+(y>>16)+(l>>16);return (m<<16)|(l&0xFFFF);} + function rl(n,c){return (n<>>(32-c));} + function cm(q,a,b,x,s,t){return ad(rl(ad(ad(a,q),ad(x,t)),s),b);} + function ff(a,b,c,d,x,s,t){return cm((b&c)|((~b)&d),a,b,x,s,t);} + function gg(a,b,c,d,x,s,t){return cm((b&d)|(c&(~d)),a,b,x,s,t);} + function hh(a,b,c,d,x,s,t){return cm(b^c^d,a,b,x,s,t);} + function ii(a,b,c,d,x,s,t){return cm(c^(b|(~d)),a,b,x,s,t);} + function sb(x) { + var i;var nblk=((x.length+8)>>6)+1;var blks=new Array(nblk*16);for(i=0;i>2]|=x.charCodeAt(i)<<((i%4)*8); + blks[i>>2]|=0x80<<((i%4)*8);blks[nblk*16-2]=x.length*8;return blks; + } + var i,x=sb(''+this),a=1732584193,b=-271733879,c=-1732584194,d=271733878,olda,oldb,oldc,oldd; + for(i=0;i]; -var cpu = []; -var rxd = []; -var txd = []; -var cputime = 0; -var nettime = 0; -var cpuline = $.cookie('cpuline')||30; -var netline = $.cookie('netline')||30; -var update2 = true; -var box = null; +var ports = []; +var cpu = []; +var rxd = []; +var txd = []; +var cputime = 0; +var nettime = 0; +var cpuline = $.cookie('cpuline')||30; +var netline = $.cookie('netline')||30; +var update2 = true; +var box = null; +var startup = true; var options_cpu = { series:[{name:'load', data:cpu.slice()}], @@ -805,8 +875,8 @@ function noVMs() { } function loadlist(init) { if (init) { - $('#apps').switchButton({labels_placement:'left', off_label:"_(All Apps)_", on_label:"_(Started only)_", checked:$.cookie('my_apps')=='startedOnly'}); - $('#vms').switchButton({labels_placement:'left', off_label:"_(All VMs)_", on_label:"_(Started only)_", checked:$.cookie('my_vms')=='startedOnly'}); + $('#apps').switchButton({labels_placement:'right', off_label:"_(All Apps)_", on_label:"_(Started only)_", checked:$.cookie('my_apps')=='startedOnly'}); + $('#vms').switchButton({labels_placement:'right', off_label:"_(All VMs)_", on_label:"_(Started only)_", checked:$.cookie('my_vms')=='startedOnly'}); $('#apps').change(function(){ $('span.outer.apps.stopped').finish().toggle('fast',function(){noApps();}) $('#apps').is(':checked') ? $.cookie('my_apps','startedOnly',{expires:3650}) : $.removeCookie('my_apps'); @@ -820,8 +890,10 @@ function loadlist(init) { var data = d.split('\0'); $('#docker_view tr.updated').remove(); $('#docker_view').append(data[0]); + hideMe($('#docker_view')); $('#vm_view tr.updated').remove(); $('#vm_view').append(data[1]); + hideMe($('#vm_view')); if ($.cookie('my_apps')!=null) $('span.apps.stopped').hide(0,noApps()); if ($.cookie('my_vms')!=null) $('span.vms.stopped').hide(0,noVMs()); }); @@ -841,13 +913,22 @@ function getCase() { function changeMode(item) { if (item==0) $.removeCookie('enter_share'); else $.cookie('enter_share',item,{expires:3650}); - if (item==0) $('.smb.user1').show(); else $('.smb.user1').hide(); - if (item==0) $('.smb.share1').show(); else $('.smb.share1').hide(); + if (startup || $('.smb.share1').parent().find('tr:eq(1)').is(':visible')) { + if (item==0) $('.smb.share1').show(); else $('.smb.share1').hide(); + } + if (startup || $('.smb.user1').parent().find('tr:eq(1)').is(':visible')) { + if (item==0) $('.smb.user1').show(); else $('.smb.user1').hide(); + } - if (item==2) $('.nfs.user3').show(); else $('.nfs.user3').hide(); - if (item==2) $('.nfs.share3').show(); else $('.nfs.share3').hide(); + if ($('.nfs.share3').parent().find('tr:eq(1)').is(':visible')) { + if (item==2) $('.nfs.share3').show(); else $('.nfs.share3').hide(); + } + if ($('.nfs.user3').parent().find('tr:eq(1)').is(':visible')) { + if (item==2) $('.nfs.user3').show(); else $('.nfs.user3').hide(); + } + $('select[name="enter_user"]').val(item); } function changeView(item) { if (item==0) $.removeCookie('enter_view'); else $.cookie('enter_view',item,{expires:3650}); @@ -942,7 +1023,7 @@ function dropdown(menu) { var select = 'select[name="'+menu+'"]'; var size = $(select+' option').length; var option = $.cookie(menu)||0; - if (option >= size) option = size - 1; + if (option >= size) option = 0; $(select+' option')[option].selected = true; $(select).change(); } @@ -962,8 +1043,15 @@ function toggleChart(init) { $('#cpu_main').removeClass('last'); $('.cpu_open:last').removeClass('last'); if ($.cookie('cpu-chart')==null) { - $('#cpu_chart').show(); - $('#cpuline').show(); + var hidden = $.cookie('hidden_content'); + hidden = hidden==null ? [] : hidden.split(';'); + if (hidden.indexOf($('#cpu_main').parent().attr('sort'))==-1) { + $('#cpu_chart').show(); + $('#cpuline').show(); + } else { + $('#cpu_chart').hide(); + $('#cpuline').hide(); + } } else { $('#cpu_chart').hide(); $('#cpuline').hide(); @@ -1050,17 +1138,24 @@ function sortTables() { }); } function addProperties() { - $('div.frame tbody.system').addClass('sortable').attr('sort','_system_information_'); + $('div.frame tbody.system').addClass('sortable').attr('sort','_system_information_'.md5()); + $('div.frame tbody.system').find('td:first').prepend(""); + $('div.frame tbody').each(function(){ + $(this).find('td:first').prepend(""); + }); $('div.frame tbody').not('.system').each(function(){ - $(this).addClass('sortable').attr('sort',$(this).attr('title').marker()); + $(this).addClass('sortable').attr('sort',$(this).attr('title').md5()); $(this).find('td:first').prepend(""); }); $('div.frame tr').attr('title',''); + $('tr#var0').hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:0},function(val){$('.sys0').text(val);})}); - $('tr#var1').show(); + $('tr#var1').show().hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:1},function(val){$('.sys1').text(val);})}); + $('tr#var2').hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:2},function(val){$('.sys2').text(val);})}); + $('tr#var3').hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:3},function(val){$('.sys3').text(val);})}); - $('tr#var4').show(); + $('tr#var4').show().hover(function(){$.post('/webGui/include/DashboardApps.php',{sys:4},function(val){$('.sys4').text(val);})}); } function showContent() { @@ -1068,13 +1163,22 @@ function showContent() { var inactive = $.cookie('inactive_content'); if (inactive) { inactive = inactive.split(';'); - for (var n=0,x; x=inactive[n]; n++) { - var tbody = $('table.dashboard tbody[sort="'+x+'"]'); + for (var n=0,md5; md5=inactive[n]; n++) { + var tbody = $('table.dashboard tbody[sort="'+md5+'"]'); var id = tbody.parent().prop('id'); count[id]--; tbody.hide(); } } + var hidden = $.cookie('hidden_content'); + if (hidden) { + hidden = hidden.split(';'); + for (var n=0,md5; md5=hidden[n]; n++) { + var tbody = $('div.frame tbody[sort="'+md5+'"]'); + tbody.find('.openclose').removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-down'); + tbody.find('tr:gt(0)').hide(); + } + } if (count['db-box1']>0) $('div#tile1').show(); if (count['db-box2']>0) $('div#tile2').show(); if (count['db-box3']>0) $('div#tile3').show(); @@ -1085,8 +1189,62 @@ function setColor(l, t1, t2) { case (t2 > 0 && l >= t2): return 'orangebar'; default: return '';} } -function dismiss(close) { - var tbody = close.closest('tbody'); +function hideMe(tbody) { + var hidden = $.cookie('hidden_content'); + hidden = hidden==null ? [] : hidden.split(';'); + if (hidden.indexOf(tbody.attr('sort'))>=0) tbody.find('tr:gt(0)').hide(); +} +function mixed(tbody) { + if (tbody.attr('data')) { + setTimeout(tbody.attr('data')); + } + if (tbody.hasClass('mixed')) { + var select = tbody.find('select[name^="enter"]'); + select = parseInt(select.val())+1; + tbody.find('tr:gt(0)').each(function(){ + var names = ($(this).attr('class')||'').split(' '); + for (var n=0,name; name=names[n]; n++) if (/[0-9]/.test(name.slice(-1)) && name.slice(-1)!=select) $(this).hide(); + }); + } +} +function openClose(button) { + var hidden = $.cookie('hidden_content'); + hidden = hidden==null ? [] : hidden.split(';'); + if (button) { + // show/hide single tile content + var tbody = button.closest('tbody'); + if (button.hasClass('fa-chevron-up')) { + button.removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-down'); + tbody.find('tr:gt(0)').hide(); + hidden.push(tbody.attr('sort')); + } else { + button.removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-up'); + tbody.find('tr:gt(0)').show(); + mixed(tbody); + hidden.splice(hidden.indexOf(tbody.attr('sort')),1); + } + $.cookie('hidden_content',hidden.join(';'),{expires:3650}); + } else { + // show/hide all tiles content + if (hidden.length==0) { + $('div.frame tbody').each(function(){ + $(this).find('.openclose').removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-down'); + $(this).find('tr:gt(0)').hide(); + hidden.push($(this).attr('sort')); + }); + $.cookie('hidden_content',hidden.join(';'),{expires:3650}); + } else { + $('div.frame tbody').each(function(){ + $(this).find('.openclose').removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-up'); + $(this).find('tr:gt(0)').show(); + mixed($(this)); + }); + $.removeCookie('hidden_content'); + } + } +} +function dismiss(button) { + var tbody = button.closest('tbody'); var table = tbody.parent(); var tile = table.parent(); var inactive = $.cookie('inactive_content'); @@ -1100,7 +1258,7 @@ function contentMgmt() { box = $("#iframe-popup"); box.html($("#templateContentMgmt").html().build()); box.dialog({ - title: "_(Content Management)_", + title: "_(Tile Management)_", height: 350, width: 900, resizable: false, @@ -1113,8 +1271,9 @@ function contentMgmt() { $.removeCookie('db-box2'); $.removeCookie('db-box3'); $.removeCookie('inactive_content'); + $.removeCookie('hidden_content'); box.dialog('close'); - refresh(); + location.reload(); }, "_(All)_": function(){ $('input.checker').each(function(){$(this).prop('checked',true);}); @@ -1222,6 +1381,7 @@ dashboard.on('message',function(msg,meta) { // array devices $('#array_list tr.updated').remove(); $('#array_list').append(data[0]); + hideMe($('#array_list')); $('#array_info').parent().css('display',info?'':'none'); $('#array_info').html(info); smartMenu('#array_list'); @@ -1232,6 +1392,7 @@ dashboard.on('message',function(msg,meta) { var info = moreInfo(data,"_(Pool)_"); $('#pool_list'+i+' tr.updated').remove(); $('#pool_list'+i).append(t); + hideMe($('#pool_list'+i)); $('#pool_info'+i).parent().css('display',info?'':'none'); $('#pool_info'+i).html(info); smartMenu('#pool_list'+i); @@ -1242,12 +1403,13 @@ dashboard.on('message',function(msg,meta) { var info = moreInfo(data,"_(Unassigned)_"); $('#devs_list tr.updated').remove(); $('#devs_list').append(data[0]); + hideMe($('#devs_list')); $('#devs_info').parent().css('display',info?'':'none'); $('#devs_info').html(info); smartMenu('#devs_list'); // parity status - $('span.info.title').html(part[3]); + $('span.parity').html(part[3]); // parity schedule var data = part[4].split('\0'); $('#parity').html(data[0]); @@ -1320,6 +1482,7 @@ $(function() { dropdown('enter_share'); dropdown('enter_view'); + startup = false; dashboard.start(); apcups.start(); diff --git a/emhttp/plugins/dynamix/include/DashboardApps.php b/emhttp/plugins/dynamix/include/DashboardApps.php index c9f47105e..8f9bc08aa 100644 --- a/emhttp/plugins/dynamix/include/DashboardApps.php +++ b/emhttp/plugins/dynamix/include/DashboardApps.php @@ -20,6 +20,19 @@ require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php"; require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php"; require_once "$docroot/webGui/include/Helpers.php"; +if (isset($_POST['sys'])) { + switch ($_POST['sys']) { + case 0: $size = exec("awk '/^MemTotal/{t=$2}/^MemAvailable/{a=$2}END{print (t-a)*1024}' /proc/meminfo 2>/dev/null"); break; + case 1: $size = exec("awk '/^size/{print \$3;exit}' /proc/spl/kstat/zfs/arcstats 2>/dev/null"); break; + case 2: $size = exec("df --output=used /boot 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; + case 3: $size = exec("df --output=used /var/log 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; + case 4: $size = exec("df --output=used /var/lib/docker 2>/dev/null|awk '$1!=\"Used\" {print $1*1024}'"); break; + default: $size = 0; + } + extract(parse_plugin_cfg('dynamix',true)); + die(my_scale($size,$unit,null,-1,1024)." $unit"); +} + $display = $_POST['display']; if ($_POST['docker'] && ($display=='icons' || $display=='docker')) { From 2e8ffa7dadbf0b8742f09bec33832db8d54d26f9 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 22 Jun 2023 21:14:56 +0200 Subject: [PATCH 079/239] OS update: add checkbox to confirm reading release notes before upgrading --- .../dynamix.plugin.manager/include/PluginHelpers.php | 8 ++++++-- .../dynamix.plugin.manager/include/ShowPlugins.php | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/emhttp/plugins/dynamix.plugin.manager/include/PluginHelpers.php b/emhttp/plugins/dynamix.plugin.manager/include/PluginHelpers.php index bfa918912..fdbc1a029 100644 --- a/emhttp/plugins/dynamix.plugin.manager/include/PluginHelpers.php +++ b/emhttp/plugins/dynamix.plugin.manager/include/PluginHelpers.php @@ -1,6 +1,6 @@ " : ""; $disabled = $check ? ' disabled' : ''; + if ($method == 'update' && $extra) { + $disabled = 'disabled'; + $id = $extra; + } if ($method == 'delete') { $cmd = "plugin_rm $arg"; $func = "refresh"; diff --git a/emhttp/plugins/dynamix.plugin.manager/include/ShowPlugins.php b/emhttp/plugins/dynamix.plugin.manager/include/ShowPlugins.php index 601412e56..60a81355d 100644 --- a/emhttp/plugins/dynamix.plugin.manager/include/ShowPlugins.php +++ b/emhttp/plugins/dynamix.plugin.manager/include/ShowPlugins.php @@ -163,12 +163,16 @@ foreach (glob($plugins,GLOB_NOSORT) as $plugin_link) { } else { $latest = plugin('version',$filename); if ($os ? version_compare($latest,$version,'>') : strcmp($latest,$version) > 0) { - $version .= "
$latest"; + if ($os) { + $version = ""._('I have read the release notes')."
$latest"; + } else { + $version .= "
$latest"; + } $error = null; - if ( ! $os && (version_compare(plugin("min",$filename,$error) ?: "1.0",$Unraid['version'],">") || version_compare(plugin("max",$filename,$error) ?: "999.9.9",$Unraid['version'],"<") ) ) { + if (!$os && (version_compare(plugin("min",$filename,$error) ?: "1.0",$Unraid['version'],">") || version_compare(plugin("max",$filename,$error) ?: "999.9.9",$Unraid['version'],"<"))) { $status = " "._("Update Incompatible").""; } else { - $status = make_link("update",basename($plugin_file)); + $status = make_link("update",basename($plugin_file),$os?'cmdUpdate':''); } $changes_file = $filename; if (!$os) $updates++; From 37563023dfa7693b7cbdc6fb43a25808ba1d1a27 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 22 Jun 2023 21:15:23 +0200 Subject: [PATCH 080/239] Minor code optimization to generate the welcome message --- sbin/create_network_ini | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sbin/create_network_ini b/sbin/create_network_ini index 4aa865f3d..1b9cc2fd3 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -232,17 +232,15 @@ fi # generate our welcome text (management interface only) if [[ -z $interface || "eth0 br0 bond0" =~ $interface ]]; then - source /etc/unraid-version + . /etc/unraid-version echo -e "unRAID Server OS version: $version" >/etc/issue # find management interface - ETH=eth0 - [[ -e /sys/class/net/bond0 ]] && ETH=bond0 - [[ -e /sys/class/net/br0 ]] && ETH=br0 - IPv4=$(ip -4 addr show $ETH|awk '/inet /{print $2;exit}') - IPv6=$(ip -6 addr show $ETH noprefixroute|awk '/inet6 /{print $2;exit}') - [[ -z $IPv6 ]] && IPv6=$(ip -6 addr show $ETH scope global permanent|awk '/inet6 /{print $2;exit}') - [[ -n $IPv4 ]] && echo " IPv4 address: ${IPv4%%/*}">>/etc/issue || echo " IPv4 address: not set">>/etc/issue - [[ -n $IPv6 ]] && echo " IPv6 address: ${IPv6%%/*}">>/etc/issue || echo " IPv6 address: not set">>/etc/issue + [[ -e /sys/class/net/bond0 ]] && dev=bond0 || dev=eth0 + [[ -e /sys/class/net/br0 ]] && dev=br0 + IPv4=$(ip -br -4 addr show $dev|awk '{print $3}') + IPv6=$(ip -br -6 addr show $dev|awk '$3 !~ "^fe80" {print $3}') + [[ -n $IPv4 ]] && echo " IPv4 address: ${IPv4%/*}">>/etc/issue || echo " IPv4 address: not set">>/etc/issue + [[ -n $IPv6 ]] && echo " IPv6 address: ${IPv6%/*}">>/etc/issue || echo " IPv6 address: not set">>/etc/issue echo >>/etc/issue fi exit 0 From 22ec726111074ea89f7d379f1466344c55736a51 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 23 Jun 2023 11:26:09 +0200 Subject: [PATCH 081/239] Dashboard: use prototype function This makes it easier for 3rd party developers to automatically hide dynamic content --- emhttp/plugins/dynamix/DashStats.page | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index b9b6fdf7e..24c518768 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -745,6 +745,11 @@ String.prototype.md5 = function() { } return rh(a)+rh(b)+rh(c)+rh(d); } +jQuery.prototype.hideMe = function() { + var hidden = $.cookie('hidden_content'); + hidden = hidden==null ? [] : hidden.split(';'); + if (hidden.indexOf(this.attr('sort'))>=0) this.find('tr:gt(0)').hide(); +} var ports = []; var cpu = []; @@ -889,11 +894,9 @@ function loadlist(init) { $.post('/webGui/include/DashboardApps.php',{display:'',docker:'',vms:''},function(d) { var data = d.split('\0'); $('#docker_view tr.updated').remove(); - $('#docker_view').append(data[0]); - hideMe($('#docker_view')); + $('#docker_view').append(data[0]).hideMe(); $('#vm_view tr.updated').remove(); - $('#vm_view').append(data[1]); - hideMe($('#vm_view')); + $('#vm_view').append(data[1]).hideMe(); if ($.cookie('my_apps')!=null) $('span.apps.stopped').hide(0,noApps()); if ($.cookie('my_vms')!=null) $('span.vms.stopped').hide(0,noVMs()); }); @@ -1189,11 +1192,6 @@ function setColor(l, t1, t2) { case (t2 > 0 && l >= t2): return 'orangebar'; default: return '';} } -function hideMe(tbody) { - var hidden = $.cookie('hidden_content'); - hidden = hidden==null ? [] : hidden.split(';'); - if (hidden.indexOf(tbody.attr('sort'))>=0) tbody.find('tr:gt(0)').hide(); -} function mixed(tbody) { if (tbody.attr('data')) { setTimeout(tbody.attr('data')); @@ -1380,8 +1378,7 @@ dashboard.on('message',function(msg,meta) { var info = moreInfo(data,"_(Array)_"); // array devices $('#array_list tr.updated').remove(); - $('#array_list').append(data[0]); - hideMe($('#array_list')); + $('#array_list').append(data[0]).hideMe(); $('#array_info').parent().css('display',info?'':'none'); $('#array_info').html(info); smartMenu('#array_list'); @@ -1391,8 +1388,7 @@ dashboard.on('message',function(msg,meta) { var data = t.split('\0'); var info = moreInfo(data,"_(Pool)_"); $('#pool_list'+i+' tr.updated').remove(); - $('#pool_list'+i).append(t); - hideMe($('#pool_list'+i)); + $('#pool_list'+i).append(t).hideMe(); $('#pool_info'+i).parent().css('display',info?'':'none'); $('#pool_info'+i).html(info); smartMenu('#pool_list'+i); @@ -1402,8 +1398,7 @@ dashboard.on('message',function(msg,meta) { var data = part[2].split('\0'); var info = moreInfo(data,"_(Unassigned)_"); $('#devs_list tr.updated').remove(); - $('#devs_list').append(data[0]); - hideMe($('#devs_list')); + $('#devs_list').append(data[0]).hideMe(); $('#devs_info').parent().css('display',info?'':'none'); $('#devs_info').html(info); smartMenu('#devs_list'); From f9a72c0dbf8fb85c3f51b11c020454dcc62686cd Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 23 Jun 2023 11:58:32 +0200 Subject: [PATCH 082/239] Dashboard: use prototype function --- emhttp/plugins/dynamix/DashStats.page | 33 +++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index 24c518768..c7291436f 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -750,6 +750,20 @@ jQuery.prototype.hideMe = function() { hidden = hidden==null ? [] : hidden.split(';'); if (hidden.indexOf(this.attr('sort'))>=0) this.find('tr:gt(0)').hide(); } +jQuery.prototype.mixedView = function() { + this.find('tr:gt(0)').show() + if (this.attr('data')) { + setTimeout(this.attr('data')); + } + if (this.hasClass('mixed')) { + var select = this.find('select[name^="enter"]'); + select = parseInt(select.val())+1; + this.find('tr:gt(0)').each(function(){ + var names = ($(this).attr('class')||'').split(' '); + for (var n=0,name; name=names[n]; n++) if (/[0-9]/.test(name.slice(-1)) && name.slice(-1)!=select) $(this).hide(); + }); + } +} var ports = []; var cpu = []; @@ -1192,19 +1206,6 @@ function setColor(l, t1, t2) { case (t2 > 0 && l >= t2): return 'orangebar'; default: return '';} } -function mixed(tbody) { - if (tbody.attr('data')) { - setTimeout(tbody.attr('data')); - } - if (tbody.hasClass('mixed')) { - var select = tbody.find('select[name^="enter"]'); - select = parseInt(select.val())+1; - tbody.find('tr:gt(0)').each(function(){ - var names = ($(this).attr('class')||'').split(' '); - for (var n=0,name; name=names[n]; n++) if (/[0-9]/.test(name.slice(-1)) && name.slice(-1)!=select) $(this).hide(); - }); - } -} function openClose(button) { var hidden = $.cookie('hidden_content'); hidden = hidden==null ? [] : hidden.split(';'); @@ -1217,8 +1218,7 @@ function openClose(button) { hidden.push(tbody.attr('sort')); } else { button.removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-up'); - tbody.find('tr:gt(0)').show(); - mixed(tbody); + tbody.mixedView(); hidden.splice(hidden.indexOf(tbody.attr('sort')),1); } $.cookie('hidden_content',hidden.join(';'),{expires:3650}); @@ -1234,8 +1234,7 @@ function openClose(button) { } else { $('div.frame tbody').each(function(){ $(this).find('.openclose').removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-up'); - $(this).find('tr:gt(0)').show(); - mixed($(this)); + $(this).mixedView(); }); $.removeCookie('hidden_content'); } From 529e6f492fa51af8dff005a82288d3cecdf7a0f5 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 23 Jun 2023 12:05:44 +0200 Subject: [PATCH 083/239] Dashboard: use prototype function --- emhttp/plugins/dynamix/DashStats.page | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index c7291436f..1c05746d8 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -750,8 +750,12 @@ jQuery.prototype.hideMe = function() { hidden = hidden==null ? [] : hidden.split(';'); if (hidden.indexOf(this.attr('sort'))>=0) this.find('tr:gt(0)').hide(); } -jQuery.prototype.mixedView = function() { - this.find('tr:gt(0)').show() +jQuery.prototype.mixedView = function(s) { + if (s==0) { + this.find('tr:gt(0)').hide(); + return; + } + this.find('tr:gt(0)').show(); if (this.attr('data')) { setTimeout(this.attr('data')); } @@ -1214,11 +1218,11 @@ function openClose(button) { var tbody = button.closest('tbody'); if (button.hasClass('fa-chevron-up')) { button.removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-down'); - tbody.find('tr:gt(0)').hide(); + tbody.mixedView(0); hidden.push(tbody.attr('sort')); } else { button.removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-up'); - tbody.mixedView(); + tbody.mixedView(1); hidden.splice(hidden.indexOf(tbody.attr('sort')),1); } $.cookie('hidden_content',hidden.join(';'),{expires:3650}); @@ -1227,14 +1231,14 @@ function openClose(button) { if (hidden.length==0) { $('div.frame tbody').each(function(){ $(this).find('.openclose').removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-down'); - $(this).find('tr:gt(0)').hide(); + $(this).mixedView(0); hidden.push($(this).attr('sort')); }); $.cookie('hidden_content',hidden.join(';'),{expires:3650}); } else { $('div.frame tbody').each(function(){ $(this).find('.openclose').removeClass('fa-chevron-up fa-chevron-down').addClass('fa-chevron-up'); - $(this).mixedView(); + $(this).mixedView(1); }); $.removeCookie('hidden_content'); } From d0db98ebd3c0956bb133b104e8fc5d8bc9538fa2 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 23 Jun 2023 18:20:02 +0200 Subject: [PATCH 084/239] Dashboard: description -> model --- emhttp/plugins/dynamix/DashStats.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index 1c05746d8..59d92057e 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -256,7 +256,7 @@ input[value=Edit]{margin:12px 0 0 0;padding:5px 10px}
"; + + if (is_array($arrModules)) ksort($arrModules) ; + foreach($arrModules as $modname => $module) + { + echo ""; + if (is_array($module["modprobe"])) { + $i = 0 ; + foreach($module["modprobe"] as $line) { + if ($i) echo "" ; else echo "" ; + $i++ ; + } + } + + } + break; + +} +?> From 74416ae50250c649744413d0e14b289f7d7ac468 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 24 Jun 2023 16:07:01 +0100 Subject: [PATCH 092/239] Update SysDrivers.page --- emhttp/plugins/dynamix/SysDrivers.page | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 370391a38..36bfe2e86 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -16,12 +16,10 @@ Tag="server" */ $select = []; + $select[] = mk_option(1,"conf",'Modprobe.d conf only'); + $select[] = mk_option(0,"inuse",'Inuse'); + $select[] = mk_option(0,"all",'All'); - - $select[] = mk_option(1,"conf",'Modprobe.d conf only'); - $select[] = mk_option(0,"inuse",'Inuse'); - $select[] = mk_option(0,"all",'All'); -#var_dump($select[]) ; ?>

diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 9f4681a8c..74ef59c76 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -18,7 +18,7 @@ require_once "$docroot/webGui/include/Translations.php"; require_once "$docroot/webGui/include/Helpers.php"; function getmodules($kernel,$line) { - global $arrModules ; + global $arrModules,$lsmod ; $modprobe = "" ; $name = $line ; #echo $line ; @@ -62,7 +62,7 @@ function getmodules($kernel,$line) { break ; } } -$state = "Enabled" ; +if (strpos($lsmod, $modname,0)) $state = "Inuse" ; else $state = "Available"; if (is_file("/boot/config/modprobe.d/$modname.conf")) { $modprobe = explode(PHP_EOL,file_get_contents("/boot/config/modprobe.d/$modname.conf")) ; $state = array_search("blacklist",$modprobe); @@ -71,7 +71,6 @@ if (is_file("/boot/config/modprobe.d/$modname.conf")) { } else if($option == "conf") return ; if ($filename != "(builtin)") { - $type = pathinfo($filename) ; $dir = $type['dirname'] ; $dir = str_replace("/lib/modules/$kernel/kernel/drivers/", "" ,$dir) ; @@ -79,7 +78,7 @@ $dir = str_replace("/lib/modules/$kernel/kernel/", "" ,$dir) ; } else { $dir = $file ; $dir = str_replace("drivers/", "" ,$dir) ; - $state= "(builtin)"; + if ($state == "Inuse") $state= "(builtin) - Inuse"; else $state="(builtin)" ; } $arrModules[$modname] = [ 'modname' => $modname, @@ -98,7 +97,7 @@ case 't1': $option = $_POST['option'] ; $select = $_POST['select'] ; #$procmodules = file_get_contents("/proc/modules") ; - + $lsmod = shell_exec("lsmod") ; $kernel = shell_exec("uname -r") ; $kernel = trim($kernel,"\n") ; #$procmodules = shell_exec('find /lib/modules/$(uname -r) -type f -not -path "/lib/modules/$(uname -r)/source/*" -not -path "/lib/modules/$(uname -r)/build/*" -name "*ko*" ') ; @@ -111,6 +110,7 @@ case 't1': foreach($builtinmodules as $bultin) { + if ($bultin == "") continue ; getmodules($kernel,pathinfo($bultin)["filename"]) ; } @@ -125,6 +125,18 @@ foreach($procmodules as $line) { if (is_array($arrModules)) ksort($arrModules) ; foreach($arrModules as $modname => $module) { + + switch ($_POST['option']){ + case "inuse": + if ($module['state'] == "Available" || $module['state'] == "(builtin)") continue(2) ; + break ; + case "confonly": + if ($module['modprobe'] == "" ) continue(2) ; + break ; + case "all": + break ; + } + echo "$modname{$module['description']}{$module['state']}{$module['type']}"; if (is_array($module["modprobe"])) { $i = 0 ; From 1de464754fda1cf4a6fc9dd3742e653d7705ac9a Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Thu, 6 Jul 2023 17:21:14 +0100 Subject: [PATCH 109/239] Modprobe file update. --- emhttp/plugins/dynamix/SysDrivers.page | 23 +++++++++++++++- emhttp/plugins/dynamix/include/SysDrivers.php | 27 +++++++++++-------- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 7446d806f..bc9ccfb80 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -61,13 +61,34 @@ function showDrivers(options) { $.post('/webGui/include/SysDrivers.php',{table:'t1',option:option},function(data){ clearTimeout(timers.refresh); $('#t1').html(data); + $('div.spinner.fixed').hide('slow'); }); } +function textedit(module) { + var i=module ; + $('#text'+module).prop('disabled', false); + $('#save'+module).attr('hidden', false); + $('#text'+module).attr('hidden', false); +} -$('.tabs').append("_(Select View)_:"); +function textsave(module) { + var i=module ; + $('#text'+module).prop('disabled', true); + $('#save'+module).attr('hidden', true); + var x = document.getElementById("text" + module).value; + $.post('/webGui/include/SysDrivers.php',{table:'update',module:module,conf:x},function(data){ + + select = document.getElementById("select").value; + showDrivers(select) ; + var message = "_(System Drivers)_: _(A reboot is required to apply changes)_"; + addRebootNotice(message); + }); +} + +$('.tabs').append("_(Select View)_:");

diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 74ef59c76..e3f52ee52 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -120,14 +120,15 @@ foreach($procmodules as $line) { } - echo ""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; - + echo ""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; + if (is_array($arrModules)) ksort($arrModules) ; foreach($arrModules as $modname => $module) { switch ($_POST['option']){ case "inuse": + if ($module['state'] == "Available" || $module['state'] == "(builtin)") continue(2) ; break ; case "confonly": @@ -136,18 +137,22 @@ foreach($procmodules as $line) { case "all": break ; } - - echo "$modname{$module['description']}{$module['state']}{$module['type']}"; + if (substr($module['state'],0,9) == "(builtin)") $disable = "disabled" ; else $disable = "" ; + $disable = "disabled" ; + echo " $modname{$module['description']}{$module['state']}{$module['type']}"; + $text = "" ; if (is_array($module["modprobe"])) { - $i = 0 ; - foreach($module["modprobe"] as $line) { - if ($i) echo "$line" ; else echo "$line" ; - $i++ ; - } - } + $text = implode("\n",$module["modprobe"]) ; + echo ""; + } else echo ""; } break; - +case "update": + $conf = $_POST['conf'] ; + $module = $_POST['module'] ; + if ($conf == "") $error = unlink("/boot/config/modprobe.d/$module.conf") ; + else $error = file_put_contents("/boot/config/modprobe.d/$module.conf",$conf) ; + echo $error ; } ?> From 62b2ef74dcc2c40d707481caa931d302a2c20f0c Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Thu, 6 Jul 2023 18:25:02 +0100 Subject: [PATCH 110/239] Fix unsaved error prompt. --- emhttp/plugins/dynamix/SysDrivers.page | 31 ++++---------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index bc9ccfb80..b33535a1c 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -31,30 +31,7 @@ table tr td.thin{line-height:8px;height:8px} $(function(){ $('#t1').load('/webGui/include/SysDrivers.php',{table:'t1',option:"inuse"}); }); -function applyCfg() { - var message = "_(System Devices)_: _(A reboot is required to apply changes)_"; - var string = "BIND="; - var elements = document.getElementById("vfiopci").elements; - for (var i = 0, element; element = elements[i++];) { - if (element.type === "checkbox" && element.checked === true) - string = string + element.value + " "; - } - string = string.trim(); - if (string === "BIND=") { - string = ""; - } - $.get( "/plugins/dynamix/include/update.vfio-pci-cfg.php", { cfg: string } ) - .done(function(d) { - if (d==1) { - addRebootNotice(message); - document.getElementById("warning").innerHTML = "_(ALERT)_: _(Changes saved)_. _(Reboot to take effect)_."; - } else { - removeRebootNotice(message); - document.getElementById("warning").innerHTML = "_(No changes)_."; - } - $("#applycfg").attr("disabled",true); - }); -} + function showDrivers(options) { option = options ; timers.refresh = setTimeout(function(){$('div.spinner.fixed').show('slow');},500); @@ -80,7 +57,7 @@ function textsave(module) { $('#save'+module).attr('hidden', true); var x = document.getElementById("text" + module).value; $.post('/webGui/include/SysDrivers.php',{table:'update',module:module,conf:x},function(data){ - +formHasUnsavedChanges=false; select = document.getElementById("select").value; showDrivers(select) ; var message = "_(System Drivers)_: _(A reboot is required to apply changes)_"; @@ -91,6 +68,6 @@ function textsave(module) { $('.tabs').append("_(Select View)_:"); -

- +

+ From 72626dbebf0915c907453804603136053ab03e6e Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 6 Jul 2023 22:09:23 +0200 Subject: [PATCH 111/239] rc.library fix regression --- etc/rc.d/rc.library.source | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index d7ba78328..16fdf1f0a 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -106,9 +106,9 @@ main() { show() { case $# in - 1) ip -br addr show scope global to $1 2>/dev/null|awk '{print $1}';; - 2) ip -br addr show scope global $1 $2 2>/dev/null|awk '{print $3}';; - 3) [[ $1 == -6 ]] && main $(ip -br -6 addr show scope global $2 $3 2>/dev/null|awk '{$2="";print}') || ip -br -4 addr show scope global $2 $3 2>/dev/null|awk '{print $3}';; + 1) ip -br addr show scope global to $1 2>/dev/null|awk '{print $1;exit}';; + 2) ip -br addr show scope global $1 $2 2>/dev/null|awk '{print $3;exit}';; + 3) [[ $1 == -6 ]] && main $(ip -br -6 addr show scope global $2 $3 2>/dev/null|awk '{$2="";print;exit}') || ip -br -4 addr show scope global $2 $3 2>/dev/null|awk '{print $3;exit}';; esac } From d8e0d82152ced0a5cf70993af69a287250cbb6b2 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Thu, 6 Jul 2023 22:03:37 +0100 Subject: [PATCH 112/239] Set highlight lines --- emhttp/plugins/dynamix/SysDrivers.page | 93 ++++++++++++++++++- emhttp/plugins/dynamix/include/SysDrivers.php | 36 +++---- 2 files changed, 108 insertions(+), 21 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index b33535a1c..3c6a1d412 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -21,15 +21,99 @@ Tag="server" $select[] = mk_option(0,"all",'All'); ?> + - -

+

diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index e3f52ee52..135e43a61 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -119,35 +119,37 @@ foreach($procmodules as $line) { getmodules($kernel,$line) ; } - - echo ""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; - + echo ""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; + echo "" ; if (is_array($arrModules)) ksort($arrModules) ; foreach($arrModules as $modname => $module) { switch ($_POST['option']){ - case "inuse": - - if ($module['state'] == "Available" || $module['state'] == "(builtin)") continue(2) ; - break ; - case "confonly": - if ($module['modprobe'] == "" ) continue(2) ; + case "inuse": + if ($module['state'] == "Available" || $module['state'] == "(builtin)") continue(2) ; break ; + + case "confonly": + if ($module['modprobe'] == "" ) continue(2) ; + break ; + case "all": break ; } - if (substr($module['state'],0,9) == "(builtin)") $disable = "disabled" ; else $disable = "" ; - $disable = "disabled" ; - echo " $modname{$module['description']}{$module['state']}{$module['type']}"; - $text = "" ; - if (is_array($module["modprobe"])) { - $text = implode("\n",$module["modprobe"]) ; - echo ""; - } else echo ""; + #echo "
$modname"; + $text = "" ; + if (is_array($module["modprobe"])) { + $text = implode("\n",$module["modprobe"]) ; + echo ""; + } else echo ""; } + echo "" ; break; + case "update": $conf = $_POST['conf'] ; $module = $_POST['module'] ; From b91a4ef28c2b4845efc5da09286c019064dd4c1d Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 7 Jul 2023 13:01:08 +0200 Subject: [PATCH 113/239] VM settings: fixed typo --- emhttp/plugins/dynamix.vm.manager/VMSettings.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix.vm.manager/VMSettings.page b/emhttp/plugins/dynamix.vm.manager/VMSettings.page index 32aebd634..b7ca08f24 100644 --- a/emhttp/plugins/dynamix.vm.manager/VMSettings.page +++ b/emhttp/plugins/dynamix.vm.manager/VMSettings.page @@ -233,7 +233,7 @@ _(VFIO allow unsafe interrupts)_: _(btrfs filesystem show)_: : ".shell_exec("btrfs filesystem show /etc/libvirt").""?> -
_(btrfs scrub status)_: : ".implode("\n", $scrub_status).""?> From b051e7e02869db0470e93fc7107738ac7b046b19 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 7 Jul 2023 13:03:27 +0200 Subject: [PATCH 114/239] rc.docker: revised docker daemon running check --- etc/rc.d/rc.docker | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 09173e251..15a7a97da 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -15,9 +15,9 @@ SYSTEM=/sys/class/net CONF6=/proc/sys/net/ipv6/conf ACTIVE=$(ls --indicator-style=none $SYSTEM|awk '/^(bond|br|eth)[0-9]/' ORS=' ') -BASE=dockerd -DOCKER=/usr/bin/$BASE -DOCKER_PIDFILE=/var/run/$BASE.pid +DOCKERD=dockerd +DOCKER=/usr/bin/$DOCKERD +DOCKER_PIDFILE=/var/run/$DOCKERD.pid DOCKER_LOG=/var/log/docker.log DOCKER_ROOT=/var/lib/docker STOCK="eth br bond" @@ -85,9 +85,14 @@ fi export DOCKER_RAMDISK=true +# Get docker daemon PID (if existing) +docker_pid() { + cat $DOCKER_PIDFILE 2>/dev/null +} + # Verify if docker daemon running is_docker_running(){ - [[ -S /var/run/docker.sock ]] || return 1 + [[ $(ps -p $(docker_pid) -o comm= 2>/dev/null) == $DOCKERD ]] || return 1 [[ $(docker info 2>&1) =~ "Cannot connect to the Docker daemon" ]] && return 1 || return 0 } @@ -458,11 +463,11 @@ start_docker(){ echo "no image mounted at $DOCKER_ROOT" exit 1 fi - echo "starting $BASE ..." + echo "starting $DOCKERD ..." if [[ -x $DOCKER ]]; then # If there is an old PID file (no docker running), clean it up: if [[ -r $DOCKER_PIDFILE ]]; then - if ! ps axc|grep docker 1>/dev/null 2>&1; then + if ! is_docker_running; then echo "Cleaning up old $DOCKER_PIDFILE." rm -f $DOCKER_PIDFILE fi @@ -473,10 +478,10 @@ start_docker(){ # Stop docker stop_docker(){ - echo "stopping $BASE ..." + echo "stopping $DOCKERD ..." # If there is no PID file, ignore this request... if [[ -r $DOCKER_PIDFILE ]]; then - kill $(cat $DOCKER_PIDFILE) + kill $(docker_pid) 2>/dev/null # must ensure daemon has stopped before unmounting image volume sleep 1 for n in {1..15}; do @@ -526,11 +531,11 @@ restart) disown ;; status) - if [[ -f $DOCKER_PIDFILE ]] && ps -o cmd $(cat $DOCKER_PIDFILE)|grep -q $BASE; then - echo "status of $BASE: running" + if is_docker_running; then + echo "status of $DOCKERD: running" echo "running containers:" $(running_containers) else - echo "status of $BASE: stopped" + echo "status of $DOCKERD: stopped" exit 1 fi ;; From 1bea99393912236328b68d42955c952df20fcffe Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 7 Jul 2023 20:29:49 +0200 Subject: [PATCH 115/239] rc.docker: revised docker daemon running check --- etc/rc.d/rc.docker | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 15a7a97da..aee833978 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -92,8 +92,7 @@ docker_pid() { # Verify if docker daemon running is_docker_running(){ - [[ $(ps -p $(docker_pid) -o comm= 2>/dev/null) == $DOCKERD ]] || return 1 - [[ $(docker info 2>&1) =~ "Cannot connect to the Docker daemon" ]] && return 1 || return 0 + [[ $(ps -p $(docker_pid) -o comm= 2>/dev/null) == $DOCKERD ]] && return 0 || return 1 } # Wait max 30s to daemon start From 29e31d3b757f0f5c4aa06009860f18554d5354ed Mon Sep 17 00:00:00 2001 From: Tom Mortensen Date: Fri, 7 Jul 2023 21:10:59 -0700 Subject: [PATCH 116/239] further refinements testing for dockerd exit in 'docker stop' --- etc/rc.d/rc.docker | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index aee833978..d789bf357 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -92,7 +92,8 @@ docker_pid() { # Verify if docker daemon running is_docker_running(){ - [[ $(ps -p $(docker_pid) -o comm= 2>/dev/null) == $DOCKERD ]] && return 0 || return 1 + [[ -S /var/run/docker.sock ]] || return 1 + [[ $(docker info 2>&1) =~ "Cannot connect to the Docker daemon" ]] && return 1 || return 0 } # Wait max 30s to daemon start @@ -481,26 +482,22 @@ stop_docker(){ # If there is no PID file, ignore this request... if [[ -r $DOCKER_PIDFILE ]]; then kill $(docker_pid) 2>/dev/null - # must ensure daemon has stopped before unmounting image volume - sleep 1 + # must ensure daemon has exited for n in {1..15}; do - if is_docker_running; then - echo "waiting for docker to die ..." - sleep 1 + sleep 1 + if [[ $(ps -p $(docker_pid) -o comm= 2>/dev/null) != $DOCKERD ]]; then + rm -f $DOCKER_PIDFILE + # tear down the bridge + if ip link show docker0 >/dev/null 2>&1; then + ip link set docker0 down + ip link del docker0 + fi + exit 0 fi + echo "waiting for docker to die ..." done - if is_docker_running; then - echo "docker will not die!" - exit 1 - elif [[ -r $DOCKER_PIDFILE ]]; then - echo "Cleaning up old $DOCKER_PIDFILE." - rm -f $DOCKER_PIDFILE - fi - fi - # tear down the bridge - if ip link show docker0 >/dev/null 2>&1; then - ip link set docker0 down - ip link del docker0 + echo "docker will not die!" + exit 1 fi } From aaebd5e23768b5d20f6fb774107b34298632f80c Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 8 Jul 2023 09:02:46 +0100 Subject: [PATCH 117/239] Sigle Line Update for Modprobe --- emhttp/plugins/dynamix/SysDrivers.page | 84 +++---------------- emhttp/plugins/dynamix/include/SysDrivers.php | 39 +++++---- 2 files changed, 34 insertions(+), 89 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 3c6a1d412..9616ff0ee 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -1,5 +1,5 @@ Menu="UNRAID-OS" -Title="System Modules/Drivers" +Title="System Drivers" Icon="fa-sitemap" Tag="server" --- @@ -46,76 +46,13 @@ table.t1 tr>td+td+td+td+td+td+td+td+td+td+td+td+td{text-align:left;} - if (typeof " ".formatUnicorn !== "function") - { - String.prototype.formatUnicorn = String.prototype.formatUnicorn || - function () { - "use strict"; - var str = this.toString(); - if (arguments.length) { - var t = typeof arguments[0]; - var key; - var args = ("string" === t || "number" === t) ? - Array.prototype.slice.call(arguments) - : arguments[0]; - - for (key in args) { - str = str.replace(new RegExp("\\{" + key + "\\}", "gi"), args[key]); - } - } - - return str; - }; - } - - (function ($) { - $.fn.getHiddenDimensions = function (includeMargin) - { - var $item = this, - props = { position: 'absolute', visibility: 'hidden', display: 'block' }, - dim = { width: 0, height: 0, innerWidth: 0, innerHeight: 0, outerWidth: 0, outerHeight: 0 }, - $hiddenParents = $item.parents().andSelf().not(':visible'), - includeMargin = (includeMargin == null) ? false : includeMargin; - - var oldProps = []; - $hiddenParents.each(function () - { - var old = {}; - - for (var name in props) - { - old[name] = this.style[name]; - this.style[name] = props[name]; - } - - oldProps.push(old); - }); - - dim.width = $item.width(); - dim.outerWidth = $item.outerWidth(includeMargin); - dim.innerWidth = $item.innerWidth(); - dim.height = $item.height(); - dim.innerHeight = $item.innerHeight(); - dim.outerHeight = $item.outerHeight(includeMargin); - - $hiddenParents.each(function (i) - { - var old = oldProps[i]; - for (var name in props) - { - this.style[name] = old[name]; - } - }); - - return dim; - } - }(jQuery)); - $(function(){ - $('#t1').load('/webGui/include/SysDrivers.php',{table:'t1',option:"inuse"}); + $('#t1').load('/webGui/include/SysDrivers.php',{table:'t1',option:"inuse"}).tablesorter(); }); + + function showDrivers(options) { option = options ; timers.refresh = setTimeout(function(){$('div.spinner.fixed').show('slow');},500); @@ -141,18 +78,21 @@ function textsave(module) { $('#save'+module).attr('hidden', true); var x = document.getElementById("text" + module).value; $.post('/webGui/include/SysDrivers.php',{table:'update',module:module,conf:x},function(data){ - formHasUnsavedChanges=false; - select = document.getElementById("select").value; - showDrivers(select) ; + if(data) { + formHasUnsavedChanges=false; + $('#text'+module).val(data.modprobe) ; + $('#status'+module).html(data.state) ; + if (data.modprobe == "") $('#text'+module).attr('hidden', true); else $('#text'+module).attr('rows', 3) + } var message = "_(System Drivers)_: _(A reboot is required to apply changes)_"; addRebootNotice(message); - }); + },"json"); } $('.tabs').append("_(Select View)_:"); -
{$module['description']}{$module['state']}{$module['type']}

+

diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 135e43a61..ee72ebf70 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -17,8 +17,12 @@ $_SERVER['REQUEST_URI'] = 'tools'; require_once "$docroot/webGui/include/Translations.php"; require_once "$docroot/webGui/include/Helpers.php"; -function getmodules($kernel,$line) { - global $arrModules,$lsmod ; +$kernel = shell_exec("uname -r") ; +$kernel = trim($kernel,"\n") ; +$lsmod = shell_exec("lsmod") ; + +function getmodules($line) { + global $arrModules,$lsmod,$kernel ; $modprobe = "" ; $name = $line ; #echo $line ; @@ -64,9 +68,10 @@ function getmodules($kernel,$line) { } if (strpos($lsmod, $modname,0)) $state = "Inuse" ; else $state = "Available"; if (is_file("/boot/config/modprobe.d/$modname.conf")) { - $modprobe = explode(PHP_EOL,file_get_contents("/boot/config/modprobe.d/$modname.conf")) ; - $state = array_search("blacklist",$modprobe); - if($state) {$state = "Disabled" ;} + $modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf") ; + $state = strpos($modprobe, "blacklist"); + $modprobe = explode(PHP_EOL,$modprobe) ; + if($state !== false) {$state = "Disabled" ;} else $state="Custom" ; } else if($option == "conf") return ; @@ -96,30 +101,26 @@ switch ($_POST['table']) { case 't1': $option = $_POST['option'] ; $select = $_POST['select'] ; - #$procmodules = file_get_contents("/proc/modules") ; - $lsmod = shell_exec("lsmod") ; - $kernel = shell_exec("uname -r") ; - $kernel = trim($kernel,"\n") ; - #$procmodules = shell_exec('find /lib/modules/$(uname -r) -type f -not -path "/lib/modules/$(uname -r)/source/*" -not -path "/lib/modules/$(uname -r)/build/*" -name "*ko*" ') ; - $procmodules = shell_exec('find /lib/modules/$(uname -r)/kernel/drivers/ -type f -not -path "/lib/modules/$(uname -r)/source/*" -not -path "/lib/modules/$(uname -r)/build/*" -name "*ko*" ') ; - $procmodules = explode(PHP_EOL,$procmodules) ; $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; $builtinmodules = explode(PHP_EOL,$builtinmodules) ; + $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; + $procmodules = explode(PHP_EOL,$procmodules) ; $option = $_POST['option'] ; $arrModules = array() ; foreach($builtinmodules as $bultin) { if ($bultin == "") continue ; - getmodules($kernel,pathinfo($bultin)["filename"]) ; + getmodules(pathinfo($bultin)["filename"]) ; } foreach($procmodules as $line) { if ($line == "") continue ; - getmodules($kernel,$line) ; + getmodules(pathinfo($line)["filename"]) ; } - echo ""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; + echo ""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; + # echo "Total Number of drivers the system:".count($arrModules)."" ; echo "" ; if (is_array($arrModules)) ksort($arrModules) ; foreach($arrModules as $modname => $module) @@ -139,7 +140,7 @@ foreach($procmodules as $line) { } #echo "
$modname"; + echo ""; $text = "" ; if (is_array($module["modprobe"])) { $text = implode("\n",$module["modprobe"]) ; @@ -155,6 +156,10 @@ case "update": $module = $_POST['module'] ; if ($conf == "") $error = unlink("/boot/config/modprobe.d/$module.conf") ; else $error = file_put_contents("/boot/config/modprobe.d/$module.conf",$conf) ; - echo $error ; + getmodules($module) ; + $return = $arrModules[$module] ; + if (is_array($return["modprobe"]))$return["modprobe"] = implode("\n",$return["modprobe"]) ; + if ($error !== false) $return["error"] = false ; else $return["error"] = true ; + echo json_encode($return) ; } ?> From 8933d4e18de306cc4a1acaea0dbbeeb2fa4c29b1 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 8 Jul 2023 13:38:28 +0100 Subject: [PATCH 118/239] New load methods --- emhttp/plugins/dynamix/SysDrivers.page | 20 ++-- emhttp/plugins/dynamix/include/SysDrivers.php | 94 ++++++++++++++----- 2 files changed, 87 insertions(+), 27 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 9616ff0ee..dae33c7fe 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -45,22 +45,28 @@ table.t1 tr>td+td+td+td+td+td+td+td+td+td+td+td+td{text-align:left;} -
{$module['description']}{$module['state']}{$module['type']}
$modname{$module['description']}{$module['state']}{$module['type']}

+

diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index ee72ebf70..614807a63 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -99,26 +99,26 @@ $arrModules[$modname] = [ switch ($_POST['table']) { case 't1': - $option = $_POST['option'] ; - $select = $_POST['select'] ; - $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; - $builtinmodules = explode(PHP_EOL,$builtinmodules) ; - $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; - $procmodules = explode(PHP_EOL,$procmodules) ; - $option = $_POST['option'] ; - $arrModules = array() ; - - foreach($builtinmodules as $bultin) - { - if ($bultin == "") continue ; - getmodules(pathinfo($bultin)["filename"]) ; - } - -foreach($procmodules as $line) { - if ($line == "") continue ; - getmodules(pathinfo($line)["filename"]) ; -} + $option = $_POST['option'] ; + $select = $_POST['select'] ; + $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; + $builtinmodules = explode(PHP_EOL,$builtinmodules) ; + $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; + $procmodules = explode(PHP_EOL,$procmodules) ; + $arrModules = array() ; + + foreach($builtinmodules as $bultin) + { + if ($bultin == "") continue ; + getmodules(pathinfo($bultin)["filename"]) ; + } + + foreach($procmodules as $line) { + if ($line == "") continue ; + getmodules(pathinfo($line)["filename"]) ; + } + echo ""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; # echo "Total Number of drivers the system:".count($arrModules)."" ; echo "" ; @@ -139,8 +139,8 @@ foreach($procmodules as $line) { break ; } #echo "
$modname"; + $status = _('loading').'...'; + echo ""; $text = "" ; if (is_array($module["modprobe"])) { $text = implode("\n",$module["modprobe"]) ; @@ -151,6 +151,58 @@ foreach($procmodules as $line) { echo "" ; break; + case 't1update': + $option = $_POST['option'] ; + $select = $_POST['select'] ; + $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; + $builtinmodules = explode(PHP_EOL,$builtinmodules) ; + $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; + $procmodules = explode(PHP_EOL,$procmodules) ; + $arrModules = array() ; + + foreach($builtinmodules as $bultin) + { + if ($bultin == "") continue ; + getmodules(pathinfo($bultin)["filename"]) ; + } + + foreach($procmodules as $line) { + if ($line == "") continue ; + getmodules(pathinfo($line)["filename"]) ; + } + + echo ""; + # echo "" ; + echo "" ; + if (is_array($arrModules)) ksort($arrModules) ; + foreach($arrModules as $modname => $module) + { + + switch ($_POST['option']){ + case "inuse": + if ($module['state'] == "Available" || $module['state'] == "(builtin)") continue(2) ; + break ; + + case "confonly": + if ($module['modprobe'] == "" ) continue(2) ; + break ; + + case "all": + break ; + } + #echo "
{$module['description']}{$module['state']}{$module['type']}
$modname $status $status $status
"._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file")."
Total Number of drivers the system:".count($arrModules)."
$modname"; + $text = "" ; + if (is_array($module["modprobe"])) { + $text = implode("\n",$module["modprobe"]) ; + echo ""; + } else echo ""; + + } + echo "" ; + break; + case "update": $conf = $_POST['conf'] ; $module = $_POST['module'] ; From aa93672c5958297a605e42d9d9156452fb72d437 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 8 Jul 2023 20:14:22 +0100 Subject: [PATCH 119/239] Revert to original load model. --- emhttp/plugins/dynamix/SysDrivers.page | 11 +++--- emhttp/plugins/dynamix/include/SysDrivers.php | 37 +++++++++++++++---- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index dae33c7fe..e0dc52262 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -23,8 +23,8 @@ Tag="server" ?> +
{$module['description']}{$module['state']}{$module['type']}

From 2c03593a5f4d097d9a59bb37bf50d5f87fcd9b33 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Thu, 13 Jul 2023 14:05:32 -0700 Subject: [PATCH 152/239] refactor: feedback script for dev maintainability --- emhttp/plugins/dynamix/scripts/feedback | 323 ++++++++++++------------ 1 file changed, 165 insertions(+), 158 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/feedback b/emhttp/plugins/dynamix/scripts/feedback index 6952d8064..e1593d233 100755 --- a/emhttp/plugins/dynamix/scripts/feedback +++ b/emhttp/plugins/dynamix/scripts/feedback @@ -10,170 +10,177 @@ * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. */ -?> -"]; -$style[] = "div.spinner.fixed{z-index:100000}"; -$style[] = "div#control_panel{position:absolute;left:0;right:0;top:0;padding-top:8px;line-height:24px;white-space:nowrap}"; -$style[] = "div.divide{text-align:center;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}"; -$style[] = "div.divide label:first-child{margin-left:0}"; -$style[] = "div.divide label{margin-left:2%;cursor:pointer}"; -$style[] = "div.allpanels{display:none;position:absolute;left:0;right:0;top:40px;bottom:0;overflow:auto}"; -$style[] = "div#footer_panel{position:absolute;left:0;right:0;bottom:0;height:30px;line-height:30px;text-align:center}"; -$style[] = "textarea.feedback{width:$width;height:530px;margin:0;resize:none}"; -$style[] = "@media (max-width:960px){textarea.feedback{height:330px}}"; -$style[] = "@media (max-height:768px){textarea.feedback{height:330px}}"; -$style[] = "input.submit[type=button]{margin-right:0;float:right}"; -$style[] = "input.submit[type=email]{margin-top:10px;float:left}"; -$style[] = "p.note,label.note{font-size:1.1rem!important;display:block}"; -$style[] = "p.success{text-align:center!important;margin-top:20px}"; -$style[] = "span.spacer{margin:0 4px}"; -$style[] = ""; - -$html = ["
"]; -$html[] = "
"; -$html[] = ""; -$html[] = ""; -$html[] = ""; -$html[] = "
"; -$html[] = "
"; -$html[] = "
"; -$html[] = "
"; -$html[] = ""; -$html[] = "
"; -$html[] = ""; -$html[] = "
"; -$html[] = "
"; -$html[] = ""; -$html[] = ""; -$html[] = ""; -$html[] = "

"._('NOTE').": "._('Submission of this bug report will automatically send your system diagnostics to Lime Technology').".

"; -$html[] = "
"; -$html[] = "
"; -$html[] = ""; -$html[] = "
"; -$html[] = ""; -$html[] = "
"; -$html[] = ""; -$html[] = "
"; - -$script = [""; - -echo implode($style),implode($html),implode($script); +$var = parse_ini_file('state/var.ini'); +$unraid = parse_ini_file('/etc/unraid-version'); +$keyfile = !empty(_var($var, 'regFILE')) ? trim(base64_encode(@file_get_contents($var['regFILE']))) : ''; +$width = in_array($display['theme'], ['azure', 'gray']) ? '98.4%' : '100%'; ?> + + + + + Feedback Form + + + +
+
+ + + +
+
+
+
+ +
+ +
+
+ + + +

: .

+
+
+ +
+ +
+ +
+ + + \ No newline at end of file From 9f95fe49893f5e46cf67e0e473475c9ec34304c9 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Thu, 13 Jul 2023 14:21:45 -0700 Subject: [PATCH 153/239] revert: feedback script to old format --- emhttp/plugins/dynamix/scripts/feedback | 323 ++++++++++++------------ 1 file changed, 158 insertions(+), 165 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/feedback b/emhttp/plugins/dynamix/scripts/feedback index e1593d233..6952d8064 100755 --- a/emhttp/plugins/dynamix/scripts/feedback +++ b/emhttp/plugins/dynamix/scripts/feedback @@ -10,177 +10,170 @@ * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. */ - +?> +"]; +$style[] = "div.spinner.fixed{z-index:100000}"; +$style[] = "div#control_panel{position:absolute;left:0;right:0;top:0;padding-top:8px;line-height:24px;white-space:nowrap}"; +$style[] = "div.divide{text-align:center;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}"; +$style[] = "div.divide label:first-child{margin-left:0}"; +$style[] = "div.divide label{margin-left:2%;cursor:pointer}"; +$style[] = "div.allpanels{display:none;position:absolute;left:0;right:0;top:40px;bottom:0;overflow:auto}"; +$style[] = "div#footer_panel{position:absolute;left:0;right:0;bottom:0;height:30px;line-height:30px;text-align:center}"; +$style[] = "textarea.feedback{width:$width;height:530px;margin:0;resize:none}"; +$style[] = "@media (max-width:960px){textarea.feedback{height:330px}}"; +$style[] = "@media (max-height:768px){textarea.feedback{height:330px}}"; +$style[] = "input.submit[type=button]{margin-right:0;float:right}"; +$style[] = "input.submit[type=email]{margin-top:10px;float:left}"; +$style[] = "p.note,label.note{font-size:1.1rem!important;display:block}"; +$style[] = "p.success{text-align:center!important;margin-top:20px}"; +$style[] = "span.spacer{margin:0 4px}"; +$style[] = ""; + +$html = ["
"]; +$html[] = "
"; +$html[] = ""; +$html[] = ""; +$html[] = ""; +$html[] = "
"; +$html[] = "
"; +$html[] = "
"; +$html[] = "
"; +$html[] = ""; +$html[] = "
"; +$html[] = ""; +$html[] = "
"; +$html[] = "
"; +$html[] = ""; +$html[] = ""; +$html[] = ""; +$html[] = "

"._('NOTE').": "._('Submission of this bug report will automatically send your system diagnostics to Lime Technology').".

"; +$html[] = "
"; +$html[] = "
"; +$html[] = ""; +$html[] = "
"; +$html[] = ""; +$html[] = "
"; +$html[] = ""; +$html[] = "
"; + +$script = [""; + +echo implode($style),implode($html),implode($script); ?> - - - - - Feedback Form - - - -
-
- - - -
-
-
-
- -
- -
-
- - - -

: .

-
-
- -
- -
- -
- - - \ No newline at end of file From bc972e54700d552f0582f17064d8bd24ab52c32c Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Thu, 13 Jul 2023 14:52:26 -0700 Subject: [PATCH 154/239] refactor: feedback script dev maintainability --- emhttp/plugins/dynamix/scripts/feedback | 323 ++++++++++++------------ 1 file changed, 165 insertions(+), 158 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/feedback b/emhttp/plugins/dynamix/scripts/feedback index 6952d8064..e1593d233 100755 --- a/emhttp/plugins/dynamix/scripts/feedback +++ b/emhttp/plugins/dynamix/scripts/feedback @@ -10,170 +10,177 @@ * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. */ -?> -"]; -$style[] = "div.spinner.fixed{z-index:100000}"; -$style[] = "div#control_panel{position:absolute;left:0;right:0;top:0;padding-top:8px;line-height:24px;white-space:nowrap}"; -$style[] = "div.divide{text-align:center;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}"; -$style[] = "div.divide label:first-child{margin-left:0}"; -$style[] = "div.divide label{margin-left:2%;cursor:pointer}"; -$style[] = "div.allpanels{display:none;position:absolute;left:0;right:0;top:40px;bottom:0;overflow:auto}"; -$style[] = "div#footer_panel{position:absolute;left:0;right:0;bottom:0;height:30px;line-height:30px;text-align:center}"; -$style[] = "textarea.feedback{width:$width;height:530px;margin:0;resize:none}"; -$style[] = "@media (max-width:960px){textarea.feedback{height:330px}}"; -$style[] = "@media (max-height:768px){textarea.feedback{height:330px}}"; -$style[] = "input.submit[type=button]{margin-right:0;float:right}"; -$style[] = "input.submit[type=email]{margin-top:10px;float:left}"; -$style[] = "p.note,label.note{font-size:1.1rem!important;display:block}"; -$style[] = "p.success{text-align:center!important;margin-top:20px}"; -$style[] = "span.spacer{margin:0 4px}"; -$style[] = ""; - -$html = ["
"]; -$html[] = "
"; -$html[] = ""; -$html[] = ""; -$html[] = ""; -$html[] = "
"; -$html[] = "
"; -$html[] = "
"; -$html[] = "
"; -$html[] = ""; -$html[] = "
"; -$html[] = ""; -$html[] = "
"; -$html[] = "
"; -$html[] = ""; -$html[] = ""; -$html[] = ""; -$html[] = "

"._('NOTE').": "._('Submission of this bug report will automatically send your system diagnostics to Lime Technology').".

"; -$html[] = "
"; -$html[] = "
"; -$html[] = ""; -$html[] = "
"; -$html[] = ""; -$html[] = "
"; -$html[] = ""; -$html[] = "
"; - -$script = [""; - -echo implode($style),implode($html),implode($script); +$var = parse_ini_file('state/var.ini'); +$unraid = parse_ini_file('/etc/unraid-version'); +$keyfile = !empty(_var($var, 'regFILE')) ? trim(base64_encode(@file_get_contents($var['regFILE']))) : ''; +$width = in_array($display['theme'], ['azure', 'gray']) ? '98.4%' : '100%'; ?> + + + + + Feedback Form + + + +
+
+ + + +
+
+
+
+ +
+ +
+
+ + + +

: .

+
+
+ +
+ +
+ +
+ + + \ No newline at end of file From 807e3effc0664a70e64652f5d57cc73cafc3f184 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Thu, 13 Jul 2023 15:44:03 -0700 Subject: [PATCH 155/239] refactor: feedback modal add troubleshoot option --- emhttp/plugins/dynamix/scripts/feedback | 39 +++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/feedback b/emhttp/plugins/dynamix/scripts/feedback index e1593d233..af7bcb430 100755 --- a/emhttp/plugins/dynamix/scripts/feedback +++ b/emhttp/plugins/dynamix/scripts/feedback @@ -42,9 +42,9 @@ $width = in_array($display['theme'], ['azure', 'gray']) ? '98.4%' : '100%'; textarea.feedback { width: ; height: 530px; margin: 0; resize: none; } @media (max-width: 960px) { textarea.feedback { height: 330px; } } @media (max-height: 768px) { textarea.feedback { height: 330px; } } - input.submit[type=button] { margin-right: 0; float: right; } - input.submit[type=email] { margin-top: 10px; float: left; } - p.note, label.note { font-size: 1.1rem !important; display: block; } + input.submit[type=button] { margin-right: 0; float: right; position: relative; z-index: 1; } + input.submit[type=email] { margin-top: 10px; float: left; position: relative; z-index: 1; } + p.note, label.note { font-size: 1.1rem !important; display: block; position: relative; z-index: 0; } p.success { text-align: center !important; margin-top: 20px; } span.spacer { margin: 0 4px; } @@ -54,6 +54,7 @@ $width = in_array($display['theme'], ['azure', 'gray']) ? '98.4%' : '100%';
+
@@ -66,9 +67,16 @@ $width = in_array($display['theme'], ['azure', 'gray']) ? '98.4%' : '100%';
- +

: .

+
+ + + + +

: .

+

@@ -96,6 +104,11 @@ $width = in_array($display['theme'], ['azure', 'gray']) ? '98.4%' : '100%'; $('#bugEmail').val(''); } + function troubleshoot_reset() { + $('#troubleshootDescription').val(": \n\n\n\n: \n\n\n\n: \n\n\n\n: \n\n\n\n: \n"); + $('#troubleshootEmail').val(''); + } + function comment_reset() { $('#commentDescription').val(''); $('#commentEmail').val(''); @@ -171,6 +184,21 @@ $width = in_array($display['theme'], ['azure', 'gray']) ? '98.4%' : '100%'; form_submit('https://keys.lime-technology.com/feedback/bugreport', { description: $('#bugDescription').val(), email: $('#bugEmail').val() }, $('#bugreport_panel'), true); }); + $('#troubleshootSubmit').click(function bugSubmitClick() { + if ($('#troubleshootDescription').val() === '') return; + if ($('#troubleshootEmail').val() === '') return alert('Email is required for troubleshooting requests'); + // @todo - update this to use a new troubleshoot endpoint + form_submit( + 'https://keys.lime-technology.com/feedback/bugreport', + { + description: $('#troubleshootDescription').val() + '\n\n' + $('#troubleshootDetails').val(), + email: $('#troubleshootEmail').val() + }, + $('#troubleshoot_panel'), + true + ); + }); + $('#commentSubmit').click(function commentSubmitClick() { if ($('#commentDescription').val() === '') return; form_submit('https://keys.lime-technology.com/feedback/comment', { description: $('#commentDescription').val(), email: $('#commentEmail').val() }, $('#comment_panel')); @@ -178,9 +206,10 @@ $width = in_array($display['theme'], ['azure', 'gray']) ? '98.4%' : '100%'; featurerequest_reset(); bugreport_reset(); + troubleshoot_reset(); comment_reset(); $('#optFeatureRequest').click(); }); - \ No newline at end of file + From e4e5c09b49e533c81dbdec441274f506744e86e2 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Fri, 14 Jul 2023 17:58:13 +0100 Subject: [PATCH 156/239] Updates to selection and PHP updates. --- emhttp/plugins/dynamix/SysDrivers.page | 20 +++--- emhttp/plugins/dynamix/include/SysDrivers.php | 72 ++++++++++++++++--- 2 files changed, 74 insertions(+), 18 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 028b620d7..09d87956e 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -76,9 +76,6 @@ function showDrivers(options, init = false) { }); $('div.spinner.fixed').hide('slow'); - - $('#t1').trigger('search', [ filter ]); - //showDriversupdate(options) }); } else { @@ -86,14 +83,17 @@ function showDrivers(options, init = false) { if (option === "inuse") filter[3] = "Inuse|Custom|Disabled"; if (option === "all") filter[3] = ""; $('#t1').trigger('search', [ filter ]); - }; + } } function showDriversupdate(options) { option = options ; - $.post('/webGui/include/SysDrivers.php',{table:'t1update',option:option},function(data){ - $('#t1').html(data); - }); + filter = []; + if (option === "inuse") filter[3] = "Inuse|Custom|Disabled"; + if (option === "all") filter[3] = ""; + + $('#t1').trigger('search', [ filter ]); + } function textedit(module) { @@ -128,9 +128,9 @@ function textsave(module) { },"json"); } -$('.tabs').append("_(Select View)_:"); -//select = document.getElementById("select").value; -showDrivers("all",true),function() { sleep(1000);showDriver("inuse") ;} ; +$('.tabs').append("_(Select View)_:"); + +showDrivers("all",true) ; diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 0f672f583..a891e538b 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -34,11 +34,13 @@ function getplugin($in) { } function getmodules($line) { - global $arrModules,$lsmod,$kernel ; + global $arrModules,$lsmod,$kernel,$list ; $modprobe = "" ; + $desc = $file = $pluginfile = $option = $filename = $depends = $supporturl = $dir = null ; $name = $line ; #echo $line ; - $modname = trim(shell_exec("modinfo $name > /dev/null"),"\n") ; + $modname = shell_exec("modinfo $name > /dev/null") ; + if ($modname != null) $modname = trim($modname,"\n") ; $output=null ; exec("modinfo $name",$output,$error) ; $parms = array() ; @@ -79,11 +81,13 @@ function getmodules($line) { break ; } } -if (strpos($lsmod, $modname,0)) $state = "Inuse" ; else $state = "Available"; +if ($modname != null) if (strpos($lsmod, $modname,0)) $state = "Inuse" ; else $state = "Available"; if (is_file("/boot/config/modprobe.d/$modname.conf")) { $modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf") ; $state = strpos($modprobe, "blacklist"); $supportpos = strpos($modprobe, "#Plugin:"); + if (isset($file[$modname])) { $supporturl = getplugin($file[$modname]) ; } + else { if ($supportpos !== false) { $support = true ; $supportendpos = strpos($modprobe,"\n",$supportpos) ; @@ -95,21 +99,26 @@ if (is_file("/boot/config/modprobe.d/$modname.conf")) { $support = false ; $plugin = "" ; } +} $modprobe = explode(PHP_EOL,$modprobe) ; if($state !== false) {$state = "Disabled" ;} else $state="Custom" ; } else if($option == "conf") return ; if ($filename != "(builtin)") { +if ($filename != null) { $type = pathinfo($filename) ; $dir = $type['dirname'] ; + $dir = str_replace("/lib/modules/$kernel/kernel/drivers/", "" ,$dir) ; $dir = str_replace("/lib/modules/$kernel/kernel/", "" ,$dir) ; +} } else { $dir = $file ; $dir = str_replace("drivers/", "" ,$dir) ; if ($state == "Inuse") $state= "(builtin) - Inuse"; else $state="(builtin)" ; } +if ($desc != null) $description = substr($desc , 0 ,60) ; else $description = null ; $arrModules[$modname] = [ 'modname' => $modname, 'dependacy' => $depends, @@ -121,10 +130,46 @@ $arrModules[$modname] = [ 'type' => $dir, 'support' => $support, 'supporturl' => $supporturl, - 'description' => substr($desc , 0 ,60) , + 'description' => $description , ] ; } +function modtoplg() { + global $list ; + $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/boot/config/plugins')); + $files = array(); + + /** @var SplFileInfo $file */ + foreach ($rii as $file) { + if ($file->isDir()){ + continue; + } + if ($file->getExtension() != "tgz" && $file->getExtension() != "txz") continue ; + $files[] = $file->getPathname(); + } + + #$list = getDirContents("/boot/config/plugins/") ; + $list =array() ; + foreach ($files as $f) + { + $plugin = str_replace("/boot/config/plugins/", "", $f) ; + $plugin = substr($plugin,0,strpos($plugin,'/') ) ; + exec("tar -tf $f | grep -E '.ko.xz|.ko' ",$tar) ; + + #var_dump($plugin) ; + foreach ($tar as $t) { + $p = pathinfo($t) ; + $filename = str_replace(".ko","",$p["filename"]) ; + $list[$filename] = $plugin ; + } + + } + + file_put_contents("/tmp/modulestoplg",json_encode($list)) ; + +} + +#modtoplg() ; switch ($_POST['table']) { case 't1pre': $option = $_POST['option'] ; @@ -189,7 +234,7 @@ case 't1pre': case 't1': $option = $_POST['option'] ; - $select = $_POST['select'] ; + $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; $builtinmodules = explode(PHP_EOL,$builtinmodules) ; $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; @@ -206,9 +251,18 @@ case 't1pre': if ($line == "") continue ; getmodules(pathinfo($line)["filename"]) ; } - - echo ""._("Actions").""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; + + $lsmod2 = explode(PHP_EOL,$lsmod) ; + foreach($lsmod2 as $line) { + if ($line == "") continue ; + $line2 = explode(" ",$line) ; + getmodules($line2['0']) ; + } + + var_dump(count($arrModules)) ; + echo ""._("Actions").""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; echo "" ; + if (is_array($arrModules)) ksort($arrModules) ; foreach($arrModules as $modname => $module) { @@ -246,6 +300,7 @@ case 't1pre': } echo "" ; + break; case "update": @@ -259,5 +314,6 @@ case "update": if (is_array($return["modprobe"]))$return["modprobe"] = implode("\n",$return["modprobe"]) ; if ($error !== false) $return["error"] = false ; else $return["error"] = true ; echo json_encode($return) ; -} + break ; +} ?> From 9467711a869209b45280bcbe506f896d69d6a9c3 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Jul 2023 00:11:37 +0200 Subject: [PATCH 157/239] Wireguard: fix typo in Ipv6 mask --- emhttp/plugins/dynamix/WG0.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/WG0.page b/emhttp/plugins/dynamix/WG0.page index faa80797b..c654581a5 100644 --- a/emhttp/plugins/dynamix/WG0.page +++ b/emhttp/plugins/dynamix/WG0.page @@ -160,7 +160,7 @@ $validDNS = "([0-9a-z]([0-9a-z\-]{0,61}[0-9a-z])?\.)+($tld)"; $validIP4 = "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}"; $validIP6 = "(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(:|([0-9a-fA-F]{1,4}:)+):(([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})?)"; $maskIP4 = "([0-9]|[12][0-9]|3[0-2])?"; -$maskIP6 = "([0-9]|[1-9][[0-9]|1[01][0-9]|12[0-8])?"; +$maskIP6 = "([0-9]|[1-9][0-9]|1[01][0-9]|12[0-8])?"; $validText = "^($validDNS|$validIP4|$validIP6)$"; $validList = "^(($validIP4/?$maskIP4|$validIP6/?$maskIP6)(, *)?)+$"; From 8b8bf199d7305c6f966fa16893f90e9e64e199d7 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Jul 2023 00:12:09 +0200 Subject: [PATCH 158/239] Routing table: fix display of metric value when zero --- emhttp/plugins/dynamix/include/RoutingTable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/RoutingTable.php b/emhttp/plugins/dynamix/include/RoutingTable.php index 45629d31a..cc024d3c6 100644 --- a/emhttp/plugins/dynamix/include/RoutingTable.php +++ b/emhttp/plugins/dynamix/include/RoutingTable.php @@ -33,7 +33,7 @@ default: $route = $cell[0]; $gateway = $cell[2]; if ($route=='default') $gateway .= " via {$cell[4]}"; - $metric = '1'; + $metric = '0'; for ($i=5; $iIPv4$route$gateway$metric"; } From 3a6d7f345edcd3f3200f7c12a97fba41243b21a1 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Jul 2023 00:13:27 +0200 Subject: [PATCH 159/239] rc.docker: change route metric of main interface as needed to avoid conflict with shim interface --- etc/rc.d/rc.docker | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index d789bf357..62e6b29d2 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -404,7 +404,11 @@ shim_network(){ ip -4 route flush dev $LINK ip -4 route add $2 src $1 dev $LINK ip -4 route add $3 src $1 dev $LINK - DEFAULT=$(ip -4 route show dev $NETWORK default|awk '{print $3}') + DEFAULT=($(ip -4 route show dev $NETWORK default|awk '{print $3,$5}')) + if [[ ${DEFAULT[1]} -eq 0 ]]; then + ip -4 route del default via $DEFAULT dev $NETWORK metric 0 + ip -4 route add default via $DEFAULT dev $NETWORK metric 1 + fi [[ -n $DEFAULT ]] && ip -4 route add default via $DEFAULT dev $LINK metric 0 } From e61ca5a898b3a6a1aac6b122aaf239b86675e157 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Jul 2023 00:26:32 +0200 Subject: [PATCH 160/239] =?UTF-8?q?rc.docker:=20change=20route=20metric=20?= =?UTF-8?q?of=20main=20interface=20as=20needed=20to=20avoid=20conf?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etc/rc.d/rc.docker | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 62e6b29d2..7c2116eca 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -404,10 +404,11 @@ shim_network(){ ip -4 route flush dev $LINK ip -4 route add $2 src $1 dev $LINK ip -4 route add $3 src $1 dev $LINK - DEFAULT=($(ip -4 route show dev $NETWORK default|awk '{print $3,$5}')) - if [[ ${DEFAULT[1]} -eq 0 ]]; then + DEFAULT=$(ip -4 route show dev $NETWORK default|awk '{print $3}') + if [[ $(ip -4 route show dev $NETWORK default|awk '{print $5}') -eq 0 ]]; then ip -4 route del default via $DEFAULT dev $NETWORK metric 0 - ip -4 route add default via $DEFAULT dev $NETWORK metric 1 + METRIC=$(($(ip -4 route show default|grep -Po 'metric \K\d+'|sort|tail -1)+1)) + ip -4 route add default via $DEFAULT dev $NETWORK metric $METRIC fi [[ -n $DEFAULT ]] && ip -4 route add default via $DEFAULT dev $LINK metric 0 } From 7b56181c61266830991419e96db2a23cfc51991a Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Jul 2023 00:27:42 +0200 Subject: [PATCH 161/239] =?UTF-8?q?rc.docker:=20change=20route=20metric=20?= =?UTF-8?q?of=20main=20interface=20as=20needed=20to=20avoid=20conf?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etc/rc.d/rc.docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 7c2116eca..927262703 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -406,8 +406,8 @@ shim_network(){ ip -4 route add $3 src $1 dev $LINK DEFAULT=$(ip -4 route show dev $NETWORK default|awk '{print $3}') if [[ $(ip -4 route show dev $NETWORK default|awk '{print $5}') -eq 0 ]]; then - ip -4 route del default via $DEFAULT dev $NETWORK metric 0 METRIC=$(($(ip -4 route show default|grep -Po 'metric \K\d+'|sort|tail -1)+1)) + ip -4 route del default via $DEFAULT dev $NETWORK metric 0 ip -4 route add default via $DEFAULT dev $NETWORK metric $METRIC fi [[ -n $DEFAULT ]] && ip -4 route add default via $DEFAULT dev $LINK metric 0 From 3dc69204852f0e592fd3fd3e80752418d6210e72 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Jul 2023 00:33:50 +0200 Subject: [PATCH 162/239] =?UTF-8?q?Revert=20"rc.docker:=20change=20route?= =?UTF-8?q?=20metric=20of=20main=20interface=20as=20needed=20to=20avoid=20?= =?UTF-8?q?conf=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7b56181c61266830991419e96db2a23cfc51991a. --- etc/rc.d/rc.docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 927262703..7c2116eca 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -406,8 +406,8 @@ shim_network(){ ip -4 route add $3 src $1 dev $LINK DEFAULT=$(ip -4 route show dev $NETWORK default|awk '{print $3}') if [[ $(ip -4 route show dev $NETWORK default|awk '{print $5}') -eq 0 ]]; then - METRIC=$(($(ip -4 route show default|grep -Po 'metric \K\d+'|sort|tail -1)+1)) ip -4 route del default via $DEFAULT dev $NETWORK metric 0 + METRIC=$(($(ip -4 route show default|grep -Po 'metric \K\d+'|sort|tail -1)+1)) ip -4 route add default via $DEFAULT dev $NETWORK metric $METRIC fi [[ -n $DEFAULT ]] && ip -4 route add default via $DEFAULT dev $LINK metric 0 From 49d4f64874a9e7b020676c42597b2b5c9fb5f89c Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Jul 2023 00:34:08 +0200 Subject: [PATCH 163/239] =?UTF-8?q?Revert=20"rc.docker:=20change=20route?= =?UTF-8?q?=20metric=20of=20main=20interface=20as=20needed=20to=20avoid=20?= =?UTF-8?q?conf=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e61ca5a898b3a6a1aac6b122aaf239b86675e157. --- etc/rc.d/rc.docker | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 7c2116eca..62e6b29d2 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -404,11 +404,10 @@ shim_network(){ ip -4 route flush dev $LINK ip -4 route add $2 src $1 dev $LINK ip -4 route add $3 src $1 dev $LINK - DEFAULT=$(ip -4 route show dev $NETWORK default|awk '{print $3}') - if [[ $(ip -4 route show dev $NETWORK default|awk '{print $5}') -eq 0 ]]; then + DEFAULT=($(ip -4 route show dev $NETWORK default|awk '{print $3,$5}')) + if [[ ${DEFAULT[1]} -eq 0 ]]; then ip -4 route del default via $DEFAULT dev $NETWORK metric 0 - METRIC=$(($(ip -4 route show default|grep -Po 'metric \K\d+'|sort|tail -1)+1)) - ip -4 route add default via $DEFAULT dev $NETWORK metric $METRIC + ip -4 route add default via $DEFAULT dev $NETWORK metric 1 fi [[ -n $DEFAULT ]] && ip -4 route add default via $DEFAULT dev $LINK metric 0 } From 5344d24e93c62113f6019d0739814594a5097fe4 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Jul 2023 01:04:04 +0200 Subject: [PATCH 164/239] rc.docker: change route metric of main interface as needed to avoid conflict with shim interface with shim interface --- etc/rc.d/rc.docker | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 62e6b29d2..4784baa63 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -405,9 +405,12 @@ shim_network(){ ip -4 route add $2 src $1 dev $LINK ip -4 route add $3 src $1 dev $LINK DEFAULT=($(ip -4 route show dev $NETWORK default|awk '{print $3,$5}')) - if [[ ${DEFAULT[1]} -eq 0 ]]; then - ip -4 route del default via $DEFAULT dev $NETWORK metric 0 - ip -4 route add default via $DEFAULT dev $NETWORK metric 1 + if [[ -z ${DEFAULT[1]} ]]; then + METRIC=1 + METRICS=$(ip -4 route show default|grep -Po 'metric \K\d+') + while [[ " $METRICS " =~ " $METRIC " ]]; do ((METRIC++)); done + ip -4 route del default via $DEFAULT dev $NETWORK + ip -4 route add default via $DEFAULT dev $NETWORK metric $METRIC fi [[ -n $DEFAULT ]] && ip -4 route add default via $DEFAULT dev $LINK metric 0 } From 602dc49291ae437156fb0c97b65c9cf5745afb60 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Jul 2023 01:47:01 +0200 Subject: [PATCH 165/239] rc.docker: change route metric of main interface as needed to avoid conflict with shim interface with shim interface --- etc/rc.d/rc.docker | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 4784baa63..43e1bc000 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -405,14 +405,16 @@ shim_network(){ ip -4 route add $2 src $1 dev $LINK ip -4 route add $3 src $1 dev $LINK DEFAULT=($(ip -4 route show dev $NETWORK default|awk '{print $3,$5}')) - if [[ -z ${DEFAULT[1]} ]]; then - METRIC=1 - METRICS=$(ip -4 route show default|grep -Po 'metric \K\d+') - while [[ " $METRICS " =~ " $METRIC " ]]; do ((METRIC++)); done - ip -4 route del default via $DEFAULT dev $NETWORK - ip -4 route add default via $DEFAULT dev $NETWORK metric $METRIC + if [[ -n $DEFAULT ]]; then + if [[ -z ${DEFAULT[1]} ]]; then + METRIC=1 + METRICS=$(ip -4 route show default|grep -Po 'metric \K\d+') + while [[ " $METRICS " =~ " $METRIC " ]]; do ((METRIC++)); done + ip -4 route del default via $DEFAULT dev $NETWORK + ip -4 route add default via $DEFAULT dev $NETWORK metric $METRIC + fi + ip -4 route add default via $DEFAULT dev $LINK metric 0 fi - [[ -n $DEFAULT ]] && ip -4 route add default via $DEFAULT dev $LINK metric 0 } # Remove custom networks From 7d803ad7dbfa828da3d3c6952003b1b1f656799e Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 15 Jul 2023 09:44:16 +0100 Subject: [PATCH 166/239] Code Tidy --- emhttp/plugins/dynamix/SysDrivers.page | 14 +- emhttp/plugins/dynamix/include/SysDrivers.php | 243 ++++++------------ 2 files changed, 89 insertions(+), 168 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 09d87956e..5d7b00976 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -54,7 +54,7 @@ table.t1 tr>td+td+td+td+td+td+td+td+td+td+td+td+td{text-align:left;} function showDrivers(options, init = false) { option = options ; if (init) { - $.post('/webGui/include/SysDrivers.php',{table:'t1',option:"all"},function(data){ + $.post('/webGui/include/SysDrivers.php',{table:'t1load',option:"all"},function(data){ clearTimeout(timers.refresh); filter = []; filter[3] = "Inuse|Custom|Disabled"; @@ -86,14 +86,8 @@ function showDrivers(options, init = false) { } } -function showDriversupdate(options) { - option = options ; - filter = []; - if (option === "inuse") filter[3] = "Inuse|Custom|Disabled"; - if (option === "all") filter[3] = ""; - - $('#t1').trigger('search', [ filter ]); - +function showDriversupdate() { + $.post('/webGui/include/SysDrivers.php',{table:'t1create',option:"all"}) ; } function textedit(module) { @@ -123,6 +117,7 @@ function textsave(module) { } } } + //showDriversupdate() ; var message = "_(System Drivers)_: _(A reboot is required to apply changes)_"; addRebootNotice(message); },"json"); @@ -131,6 +126,7 @@ function textsave(module) { $('.tabs').append("_(Select View)_:"); showDrivers("all",true) ; +showDriversupdate() ; diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index a891e538b..b175c355b 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -22,19 +22,18 @@ $kernel = shell_exec("uname -r") ; $kernel = trim($kernel,"\n") ; $lsmod = shell_exec("lsmod") ; $supportpage = true; +$arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ; function getplugin($in) { - $plugins = "/var/log/plugins/"; $plugin_link = $plugins.$in ; $plugin_file = @readlink($plugin_link); $support = plugin('support',$plugin_file) ?: ""; - #$support = $support ? ""._('Support Thread')."" : ""; return($support) ; } function getmodules($line) { - global $arrModules,$lsmod,$kernel,$list ; + global $arrModules,$lsmod,$kernel,$arrModtoPlg,$modplugins ; $modprobe = "" ; $desc = $file = $pluginfile = $option = $filename = $depends = $supporturl = $dir = null ; $name = $line ; @@ -81,29 +80,17 @@ function getmodules($line) { break ; } } -if ($modname != null) if (strpos($lsmod, $modname,0)) $state = "Inuse" ; else $state = "Available"; +if ($modname != null) { + if (strpos($lsmod, $modname,0)) $state = "Inuse" ; else $state = "Available"; + if (isset($arrModtoPlg[$modname])) { $support = true ; $supporturl = plugin("support", $modplugins[$arrModtoPlg[$modname]]) ; $pluginfile = "Plugin name: {$arrModtoPlg[$modname]}" ; } else { $support = false ; $supporturl = null ; } + } if (is_file("/boot/config/modprobe.d/$modname.conf")) { $modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf") ; $state = strpos($modprobe, "blacklist"); - $supportpos = strpos($modprobe, "#Plugin:"); - if (isset($file[$modname])) { $supporturl = getplugin($file[$modname]) ; } - else { - if ($supportpos !== false) { - $support = true ; - $supportendpos = strpos($modprobe,"\n",$supportpos) ; - $pluginfileget = substr($modprobe,$supportpos + 8,$supportendpos ) ; - $pluginfile = str_replace("\n","",$pluginfileget) ; - $supporturl = getplugin($pluginfile) ; - #$modprobe = str_replace($pluginfileget,"",$modprobe) ; - } else { - $support = false ; - $plugin = "" ; - } -} $modprobe = explode(PHP_EOL,$modprobe) ; if($state !== false) {$state = "Disabled" ;} else $state="Custom" ; - } else if($option == "conf") return ; + } if ($filename != "(builtin)") { if ($filename != null) { @@ -135,7 +122,6 @@ $arrModules[$modname] = [ } function modtoplg() { - global $list ; $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/boot/config/plugins')); $files = array(); @@ -148,166 +134,105 @@ function modtoplg() { $files[] = $file->getPathname(); } - #$list = getDirContents("/boot/config/plugins/") ; - $list =array() ; - foreach ($files as $f) - { + $list = array() ; + foreach ($files as $f) { $plugin = str_replace("/boot/config/plugins/", "", $f) ; $plugin = substr($plugin,0,strpos($plugin,'/') ) ; + $tar = [] ; exec("tar -tf $f | grep -E '.ko.xz|.ko' ",$tar) ; - - #var_dump($plugin) ; foreach ($tar as $t) { $p = pathinfo($t) ; $filename = str_replace(".ko","",$p["filename"]) ; $list[$filename] = $plugin ; } + } - } - - file_put_contents("/tmp/modulestoplg",json_encode($list)) ; + file_put_contents("/tmp/modulestoplg.json",json_encode($list,JSON_PRETTY_PRINT)) ; } -#modtoplg() ; switch ($_POST['table']) { -case 't1pre': - $option = $_POST['option'] ; - $select = $_POST['select'] ; - $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; - $builtinmodules = explode(PHP_EOL,$builtinmodules) ; - $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; - $procmodules = explode(PHP_EOL,$procmodules) ; - $arrModules = array() ; - foreach($builtinmodules as $bultin) - { - if ($bultin == "") continue ; - getmodules(pathinfo($bultin)["filename"]) ; - } - - foreach($procmodules as $line) { - if ($line == "") continue ; - getmodules(pathinfo($line)["filename"]) ; - } + case 't1create': + $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; + $builtinmodules = explode(PHP_EOL,$builtinmodules) ; + $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; + $procmodules = explode(PHP_EOL,$procmodules) ; + $arrModules = array() ; - - echo ""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; - echo "" ; - if (is_array($arrModules)) ksort($arrModules) ; - foreach($arrModules as $modname => $module) - { - - switch ($_POST['option']){ - case "inuse": - if ($module['state'] == "Available" || $module['state'] == "(builtin)") continue(2) ; - break ; - - case "confonly": - if ($module['modprobe'] == "" ) continue(2) ; - break ; - - case "all": - break ; - } - #echo "
" ; - echo "" ; - echo ""; - $text = "" ; - if (is_array($module["modprobe"])) { - $text = implode("\n",$module["modprobe"]) ; - echo ""; - } else echo ""; - - } - echo "" ; - break; - - case 't1': - $option = $_POST['option'] ; - - $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; - $builtinmodules = explode(PHP_EOL,$builtinmodules) ; - $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; - $procmodules = explode(PHP_EOL,$procmodules) ; - $arrModules = array() ; - - foreach($builtinmodules as $bultin) - { - if ($bultin == "") continue ; - getmodules(pathinfo($bultin)["filename"]) ; - } - - foreach($procmodules as $line) { - if ($line == "") continue ; - getmodules(pathinfo($line)["filename"]) ; - } - - $lsmod2 = explode(PHP_EOL,$lsmod) ; - foreach($lsmod2 as $line) { - if ($line == "") continue ; - $line2 = explode(" ",$line) ; - getmodules($line2['0']) ; - } - - var_dump(count($arrModules)) ; - echo ""; - echo "" ; - - if (is_array($arrModules)) ksort($arrModules) ; - foreach($arrModules as $modname => $module) - { - - switch ($_POST['option']){ - case "inuse": - if ($module['state'] == "Available" || $module['state'] == "(builtin)") continue(2) ; - break ; - - case "confonly": - if ($module['modprobe'] == "" ) continue(2) ; - break ; - - case "all": - break ; + $list = scandir('/var/log/plugins/') ; + foreach($list as $f) $modplugins[plugin("name" , @readlink("/var/log/plugins/$f"))] = readlink("/var/log/plugins/$f") ; + + foreach($builtinmodules as $bultin) + { + if ($bultin == "") continue ; + getmodules(pathinfo($bultin)["filename"]) ; } - - echo "" ; - echo ""; - - $text = "" ; - if (is_array($module["modprobe"])) { - $text = implode("\n",$module["modprobe"]) ; - echo ""; - } else echo ""; - - } - echo "" ; - break; + $lsmod2 = explode(PHP_EOL,$lsmod) ; + foreach($lsmod2 as $line) { + if ($line == "") continue ; + $line2 = explode(" ",$line) ; + getmodules($line2['0']) ; + } + + unset($arrModules['null']); + file_put_contents("/tmp/sysdrivers.json",json_encode($arrModules,JSON_PRETTY_PRINT)) ; + modtoplg() ; + + break; + + case 't1load': + $list = file_get_contents("/tmp/sysdrivers.json") ; + $arrModules = json_decode($list,TRUE) ; + echo ""; + echo "" ; + + if (is_array($arrModules)) ksort($arrModules) ; + foreach($arrModules as $modname => $module) { + if ($modname == "") continue ; + + if (is_file("/boot/config/modprobe.d/$modname.conf")) { + $modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf") ; + $state = strpos($modprobe, "blacklist"); + $modprobe = explode(PHP_EOL,$modprobe) ; + if($state !== false) {$state = "Disabled" ;} else $state="Custom" ; + $module['state'] = $state ; + $module['modprobe'] = $modprobe ; + } + + echo "" ; + echo ""; + + $text = "" ; + if (is_array($module["modprobe"])) { + $text = implode("\n",$module["modprobe"]) ; + echo ""; + } else echo ""; + + } + echo "" ; + break; case "update": $conf = $_POST['conf'] ; $module = $_POST['module'] ; - if ($conf == "") $error = unlink("/boot/config/modprobe.d/$module.conf") ; - else $error = file_put_contents("/boot/config/modprobe.d/$module.conf",$conf) ; + if ($conf == "") $error = unlink("/boot/config/modprobe.d/$module.conf") ; else $error = file_put_contents("/boot/config/modprobe.d/$module.conf",$conf) ; getmodules($module) ; $return = $arrModules[$module] ; $return['supportpage'] = $supportpage ; From bfdb01559f323ddd664858b1ce10262da1277c01 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 15 Jul 2023 10:14:38 +0100 Subject: [PATCH 167/239] Create SysDriversInit event. --- .../event/disks_mounted/SysDriversInit.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php diff --git a/emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php b/emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php new file mode 100644 index 000000000..8c88f9bf9 --- /dev/null +++ b/emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php @@ -0,0 +1,18 @@ +#!/usr/bin/php +"t1create","csrf_token" => $var['csrf_token']]) ; +echo $rtn ; +?> \ No newline at end of file From dc58e2fd6975a467789be0bb7452108a58889a8b Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 15 Jul 2023 10:16:14 +0100 Subject: [PATCH 168/239] Make script executable --- emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php diff --git a/emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php b/emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php old mode 100644 new mode 100755 From 90f26f43125f20761dfb0cd1d851f484b52e2496 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 15 Jul 2023 10:28:43 +0100 Subject: [PATCH 169/239] Set Timeout for curl process --- emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php b/emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php index 8c88f9bf9..a402f2e23 100755 --- a/emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php +++ b/emhttp/plugins/dynamix/event/disks_mounted/SysDriversInit.php @@ -7,6 +7,7 @@ function httpPost($url, $data) curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_TIMEOUT_MS, 1000); $response = curl_exec($curl); curl_close($curl); return $response; @@ -14,5 +15,4 @@ function httpPost($url, $data) $var = @parse_ini_file("/var/local/emhttp/var.ini") ?: []; $rtn = httpPost("http://localhost/webGui/include/SysDrivers.php", ["table"=>"t1create","csrf_token" => $var['csrf_token']]) ; -echo $rtn ; ?> \ No newline at end of file From 2e712e4b33f4db0e9681d9610c3d0e666606c80d Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 15 Jul 2023 10:35:23 +0100 Subject: [PATCH 170/239] Fix php warnings. --- emhttp/plugins/dynamix/include/SysDrivers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index b175c355b..231854c85 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -35,7 +35,7 @@ function getplugin($in) { function getmodules($line) { global $arrModules,$lsmod,$kernel,$arrModtoPlg,$modplugins ; $modprobe = "" ; - $desc = $file = $pluginfile = $option = $filename = $depends = $supporturl = $dir = null ; + $desc = $file = $pluginfile = $option = $filename = $depends = $support = $supporturl = $dir = null ; $name = $line ; #echo $line ; $modname = shell_exec("modinfo $name > /dev/null") ; @@ -161,7 +161,7 @@ switch ($_POST['table']) { $arrModules = array() ; $list = scandir('/var/log/plugins/') ; - foreach($list as $f) $modplugins[plugin("name" , @readlink("/var/log/plugins/$f"))] = readlink("/var/log/plugins/$f") ; + foreach($list as $f) $modplugins[plugin("name" , @readlink("/var/log/plugins/$f"))] = @readlink("/var/log/plugins/$f") ; foreach($builtinmodules as $bultin) { From a562e98a7535b08e8ebbbf311eb8cd30dea41dd3 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 15 Jul 2023 11:13:30 +0100 Subject: [PATCH 171/239] Change order of json file creation. --- emhttp/plugins/dynamix/include/SysDrivers.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 231854c85..b67d9e287 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -154,6 +154,8 @@ function modtoplg() { switch ($_POST['table']) { case 't1create': + modtoplg() ; + $arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ; $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; $builtinmodules = explode(PHP_EOL,$builtinmodules) ; $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; @@ -182,9 +184,7 @@ switch ($_POST['table']) { } unset($arrModules['null']); - file_put_contents("/tmp/sysdrivers.json",json_encode($arrModules,JSON_PRETTY_PRINT)) ; - modtoplg() ; - + file_put_contents("/tmp/sysdrivers.json",json_encode($arrModules,JSON_PRETTY_PRINT)) ; break; case 't1load': From a19f33757580b270fc95adc2b22ea703c0619bf9 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 15 Jul 2023 20:29:03 +0100 Subject: [PATCH 172/239] Move iniit and php fixes. --- emhttp/plugins/dynamix/SysDrivers.page | 11 +++-------- .../SysDriversInit.php | 0 2 files changed, 3 insertions(+), 8 deletions(-) rename emhttp/plugins/dynamix/event/{disks_mounted => driver_loaded}/SysDriversInit.php (100%) mode change 100755 => 100644 diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 5d7b00976..751951de8 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -15,12 +15,6 @@ Tag="server" * all copies or substantial portions of the Software. */ - $select = []; - $select[] = mk_option(1,"conf",'Modprobe.d conf only'); - $select[] = mk_option(0,"inuse",'Inuse'); - $select[] = mk_option(0,"all",'All'); - $newmodel = version_compare($version['version'],'6.12.0-beta5', '>') ? "true" : "false" ; - ?> From 74b8b47d931db97a152f4951e9765dabc1ff5548 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 15 Jul 2023 23:21:07 +0100 Subject: [PATCH 174/239] Make script executable --- emhttp/plugins/dynamix/event/driver_loaded/SysDriversInit.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 emhttp/plugins/dynamix/event/driver_loaded/SysDriversInit.php diff --git a/emhttp/plugins/dynamix/event/driver_loaded/SysDriversInit.php b/emhttp/plugins/dynamix/event/driver_loaded/SysDriversInit.php old mode 100644 new mode 100755 From 52ac7fe459c96217180b17ec631f41b0c35a0acf Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 16 Jul 2023 11:26:38 +0200 Subject: [PATCH 175/239] rc.docker: create same IPv6 network for containers and services --- etc/rc.d/rc.docker | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 43e1bc000..36de51a67 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -115,6 +115,46 @@ running_containers(){ docker ps --format='{{.Names}}' 2>/dev/null } +max6() { + # ipv6 addresses in long notation + f=:ffff: + for x in $*; do + read a m < <(IFS=/; echo $x) + [[ $a =~ $f && $a =~ '.' ]] && b=${a#*$f} a=${a%$f*}$f:0 || b= + c=${a//[^:]/} + [[ ${a:0:1} == : ]] && a=0${a} + [[ ${a:${#a}-1} == : ]] && a=${a}0 + a=${a/::/:$(for((i=1;i<=$((8-${#c}));i++)); do printf "0:"; done)} + d= a=$(for q in ${a//:/ }; do printf "$d%04x" "0x$q"; d=:; done) + [[ -n $b ]] && d= a=${a%$f*}${f}$(for q in ${b//./ }; do printf "$d%03x" "0x$q"; d=.; done) + [[ -z $m ]] && echo $a || echo $a/$m + done +} + +min6() { + # ipv6 address in short notation + f=:ffff: + [[ -n $1 ]] && read a m < <(IFS=/; echo $1) || return + [[ $a =~ $f && $a =~ '.' ]] && b=${a#*$f} a=${a%$f*}$f || b= + d= a=:$(for q in ${a//:/ }; do printf "$d%x" "0x$q"; d=:; done) + a=${a/$(grep -Po ':(0(:|$)){2,8}' <<< $a|sort|tail -1)/::} + [[ ${a:0:2} != :: ]] && a=${a:1} + [[ -n $b ]] && d= a=${a%$f*}:$(for q in ${b//./ }; do printf "$d%x" "0x$q"; d=.; done) + [[ -z $m ]] && echo $a || echo $a/$m +} + +wipe() { + wet=($*) + # remove temporary (privacy extensions) ipv6 addresses + for tmp in $(ip -br -6 addr show scope global temporary dev $wet 2>/dev/null|awk '{$1=$2="";print}'); do + for i in ${!wet[@]}; do + [[ ${wet[$i]} == $tmp ]] && unset 'wet[i]' + done + done + # return cleaned-up list without interface name + echo ${wet[@]/$wet} +} + # Custom networks network(){ docker network ls --filter driver="$1" --format='{{.Name}}' 2>/dev/null|tr '\n' ' ' @@ -272,17 +312,17 @@ start_network(){ fi if [[ -n $IPV4 ]]; then SUBNET=$(ip -4 route show dev $NETWORK $IPV4|awk '{print $1;exit}') - SERVER=${IPV4%%/*} + SERVER=${IPV4%/*} DHCP=${NETWORK/./_} DHCP=DOCKER_DHCP_${DHCP^^} RANGE=${!DHCP} GATEWAY=$(ip -4 route show dev $NETWORK default|awk '{print $3;exit}') fi SUBNET6=; GATEWAY6=; SERVER6=; RANGE6=; - IPV6=$(ip -br -6 addr show $NETWORK scope global|awk '{print $3}') + IPV6=$(min6 $(max6 $(wipe $(ip -br -6 addr show $NETWORK scope global|awk '{$2="";print;exit}'))|sort|head -1)) if [[ -n $IPV6 ]]; then SUBNET6=$(ip -6 route show dev $NETWORK $IPV6|awk '{print $1;exit}') - SERVER6=${IPV6%%/*} + SERVER6=${IPV6%/*} DHCP6=${NETWORK/./_} DHCP6=DOCKER_DHCP6_${DHCP6^^} RANGE6=${!DHCP6} From c3e5801e82ed427f2aeb4b8b6327c7ce2d45e3f9 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 16 Jul 2023 15:08:06 +0100 Subject: [PATCH 176/239] Fix scrolling/php issues add search box. Set colours. Only show support if available next to name, --- emhttp/plugins/dynamix/SysDrivers.page | 49 ++++++++----- emhttp/plugins/dynamix/include/SysDrivers.php | 69 +++++++++++++++---- 2 files changed, 86 insertions(+), 32 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 901cbc9f1..ae1f16818 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -19,8 +19,7 @@ $theme = $display['theme'] ; ?> @@ -68,15 +75,12 @@ function showDrivers(options, init = false) { $.post('/webGui/include/SysDrivers.php',{table:'t1load',option:"all"},function(data){ clearTimeout(timers.refresh); filter = []; - filter[3] = "Inuse|Custom|Disabled"; + filter[2] = "Inuse|Custom|Disabled"; $("#t1").trigger("destroy"); $('#t1').html(data); $('#t1').tablesorter({ - sortList:[[1,0]], - sortAppend:[[1,0]], - headers:{ - 0:{sorter:false} - }, + sortList:[[0,0]], + sortAppend:[[0,0]], widgets: ['stickyHeaders','filter', 'zebra'], widgetOptions: { // on black and white, offset is height of #menu @@ -92,12 +96,18 @@ function showDrivers(options, init = false) { } else { filter = []; - if (option === "inuse") filter[3] = "Inuse|Custom|Disabled"; - if (option === "all") filter[3] = ""; - $('#t1').trigger('search', [ filter ]); + filterDrivers() ; } } +function filterDrivers() { + var totalColumns = $('#t1')[0].config.columns; + var filter = []; + filter[2] = ($('#select').val() === "inuse") ? "Inuse|Custom|Disabled" : ""; + filter[totalColumns] = $('#driversearch').val(); // this searches all columns + $('#t1').trigger('search', [ filter ]); +} + function showDriversupdate() { $.post('/webGui/include/SysDrivers.php',{table:'t1create',option:"all"}) ; } @@ -142,6 +152,7 @@ showDriversupdate() ; +
" ; - if ($module['support'] == false) { - $supporthtml = "title='"._("Support Page")."' id=\"support'.$modname.'\" class='fa fa-circle' disabled " ; - } else { - $supporturl = $module['supporturl'] ; - $supporthtml = ""._('Support Thread').""; - } - echo "$supporthtml $modname $status $status $status
"._("Actions").""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file")."
" ; - if ($supportpage) { - if ($module['support'] == false) { - $supporthtml = "" ; - } else { - $supporturl = $module['supporturl'] ; - $supporthtml = "" ; + + foreach($procmodules as $line) { + if ($line == "") continue ; + getmodules(pathinfo($line)["filename"]) ; } - } - echo "$supporthtml$modname{$module['description']}{$module['state']}{$module['type']}
"._("Actions").""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file")."
" ; + if ($supportpage) { + if ($module['support'] == false) { + $supporthtml = "" ; + } else { + $supporturl = $module['supporturl'] ; + $pluginname = $module['plugin'] ; + $supporthtml = "" ; + } + } + echo "$supporthtml$modname{$module['description']}{$module['state']}{$module['type']}

diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index b67d9e287..ef5645221 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -22,6 +22,9 @@ $kernel = shell_exec("uname -r") ; $kernel = trim($kernel,"\n") ; $lsmod = shell_exec("lsmod") ; $supportpage = true; +$modtoplgfile = "/tmp/modulestoplg.json" ; +$sysdrvfile = "/tmp/sysdrivers.json" ; +if (!is_file($modtoplgfile) || !is_file($sysdrvfile)) { modtoplg() ; createlist() ;} $arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ; function getplugin($in) { @@ -35,7 +38,7 @@ function getplugin($in) { function getmodules($line) { global $arrModules,$lsmod,$kernel,$arrModtoPlg,$modplugins ; $modprobe = "" ; - $desc = $file = $pluginfile = $option = $filename = $depends = $support = $supporturl = $dir = null ; + $desc = $file = $pluginfile = $option = $filename = $depends = $support = $supporturl = $dir = $state = null ; $name = $line ; #echo $line ; $modname = shell_exec("modinfo $name > /dev/null") ; @@ -122,6 +125,7 @@ $arrModules[$modname] = [ } function modtoplg() { + global $modtoplgfile ; $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/boot/config/plugins')); $files = array(); @@ -147,21 +151,56 @@ function modtoplg() { } } - file_put_contents("/tmp/modulestoplg.json",json_encode($list,JSON_PRETTY_PRINT)) ; + file_put_contents($modtoplgfile,json_encode($list,JSON_PRETTY_PRINT)) ; } +function createlist() { + global $modtoplgfile, $sysdrvfile, $lsmod, $kernel,$arrModules ; + $arrModtoPlg = json_decode(file_get_contents($modtoplgfile) ,TRUE) ; + $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; + $builtinmodules = explode(PHP_EOL,$builtinmodules) ; + $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; + $procmodules = explode(PHP_EOL,$procmodules) ; + $arrModules = array() ; + + $list = scandir('/var/log/plugins/') ; + foreach($list as $f) $modplugins[plugin("name" , @readlink("/var/log/plugins/$f"))] = @readlink("/var/log/plugins/$f") ; + + foreach($builtinmodules as $bultin) + { + if ($bultin == "") continue ; + getmodules(pathinfo($bultin)["filename"]) ; + } + + foreach($procmodules as $line) { + if ($line == "") continue ; + getmodules(pathinfo($line)["filename"]) ; + } + + $lsmod2 = explode(PHP_EOL,$lsmod) ; + foreach($lsmod2 as $line) { + if ($line == "") continue ; + $line2 = explode(" ",$line) ; + getmodules($line2['0']) ; + } + + unset($arrModules['null']); + file_put_contents($sysdrvfile,json_encode($arrModules,JSON_PRETTY_PRINT)) ; +} + switch ($_POST['table']) { case 't1create': modtoplg() ; - $arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ; + createlist() ; + /*$arrModtoPlg = json_decode(file_get_contents($modtoplgfile) ,TRUE) ; $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; $builtinmodules = explode(PHP_EOL,$builtinmodules) ; $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; $procmodules = explode(PHP_EOL,$procmodules) ; $arrModules = array() ; - + $list = scandir('/var/log/plugins/') ; foreach($list as $f) $modplugins[plugin("name" , @readlink("/var/log/plugins/$f"))] = @readlink("/var/log/plugins/$f") ; @@ -182,15 +221,17 @@ switch ($_POST['table']) { $line2 = explode(" ",$line) ; getmodules($line2['0']) ; } - + unset($arrModules['null']); - file_put_contents("/tmp/sysdrivers.json",json_encode($arrModules,JSON_PRETTY_PRINT)) ; + file_put_contents($sysdrvfile,json_encode($arrModules,JSON_PRETTY_PRINT)) ; */ + break; case 't1load': - $list = file_get_contents("/tmp/sysdrivers.json") ; + $list = file_get_contents($sysdrvfile) ; $arrModules = json_decode($list,TRUE) ; - echo ""._("Actions").""._("Module/Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; + #echo ""._("Actions").""._("Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; + echo ""._("Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; echo "" ; if (is_array($arrModules)) ksort($arrModules) ; @@ -206,24 +247,26 @@ switch ($_POST['table']) { $module['modprobe'] = $modprobe ; } - echo "" ; + echo "" ; + #echo "" ; if ($supportpage) { if ($module['support'] == false) { - $supporthtml = "" ; + #$supporthtml = "" ; + $supporthtml = "" ; } else { $supporturl = $module['supporturl'] ; $pluginname = $module['plugin'] ; $supporthtml = "" ; } } - echo "$supporthtml$modname" ; + echo "$modname$supporthtml" ; echo "{$module['description']}{$module['state']}{$module['type']}"; $text = "" ; if (is_array($module["modprobe"])) { $text = implode("\n",$module["modprobe"]) ; - echo ""; - } else echo ""; + echo ""; + } else echo ""; } echo "" ; From 8372970be843e2cbbb9ebc2643a65e3e17765cf7 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:10:43 +0100 Subject: [PATCH 177/239] Fix support url. --- emhttp/plugins/dynamix/include/SysDrivers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index ef5645221..fef8dc092 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -156,7 +156,7 @@ function modtoplg() { } function createlist() { - global $modtoplgfile, $sysdrvfile, $lsmod, $kernel,$arrModules ; + global $modtoplgfile, $sysdrvfile, $lsmod, $kernel,$arrModules, $modplugins ; $arrModtoPlg = json_decode(file_get_contents($modtoplgfile) ,TRUE) ; $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; $builtinmodules = explode(PHP_EOL,$builtinmodules) ; From d617c7508a181d8e842fe129033fa2ca6b11d2f9 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 16 Jul 2023 23:15:59 +0100 Subject: [PATCH 178/239] Code Tidy --- emhttp/plugins/dynamix/SysDrivers.page | 6 ++---- emhttp/plugins/dynamix/include/SysDrivers.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index ae1f16818..b7593fe4e 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -74,8 +74,6 @@ function showDrivers(options, init = false) { if (init) { $.post('/webGui/include/SysDrivers.php',{table:'t1load',option:"all"},function(data){ clearTimeout(timers.refresh); - filter = []; - filter[2] = "Inuse|Custom|Disabled"; $("#t1").trigger("destroy"); $('#t1').html(data); $('#t1').tablesorter({ @@ -148,11 +146,11 @@ function textsave(module) { $('.tabs').append("_(Select View)_:"); showDrivers("all",true) ; -showDriversupdate() ; +

- + diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index fef8dc092..95f41c791 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -108,7 +108,7 @@ $dir = str_replace("/lib/modules/$kernel/kernel/", "" ,$dir) ; $dir = str_replace("drivers/", "" ,$dir) ; if ($state == "Inuse") $state= "(builtin) - Inuse"; else $state="(builtin)" ; } -if ($desc != null) $description = substr($desc , 0 ,60) ; else $description = null ; +if ($desc != null) $description = substr($desc , 0 ,70) ; else $description = null ; $arrModules[$modname] = [ 'modname' => $modname, 'dependacy' => $depends, From 3dcd3a7e71d08ba54c0ba7c4c94ee64b856d0db5 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Mon, 17 Jul 2023 17:25:31 +0100 Subject: [PATCH 179/239] Updates to rebuild. --- emhttp/plugins/dynamix/SysDrivers.page | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index b7593fe4e..447fe9c1b 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -72,6 +72,8 @@ div.tablesorter-header-inner {color:#606e7f;background-color:#e4e2e4;} function showDrivers(options, init = false) { option = options ; if (init) { + $('#driversearch').prop('disabled', true); + $('#select').prop('disabled', true); $.post('/webGui/include/SysDrivers.php',{table:'t1load',option:"all"},function(data){ clearTimeout(timers.refresh); $("#t1").trigger("destroy"); @@ -90,6 +92,8 @@ function showDrivers(options, init = false) { }); $('div.spinner.fixed').hide('slow'); + $('#driversearch').prop('disabled', false); + $('#select').prop('disabled', false); }); } else { @@ -107,7 +111,16 @@ function filterDrivers() { } function showDriversupdate() { - $.post('/webGui/include/SysDrivers.php',{table:'t1create',option:"all"}) ; + $('#rebuild').prop('disabled', true); + $('#t1').html(""); + $('#driversearch').prop('disabled', true); + $('#select').prop('disabled', true); + $('div.spinner.fixed').show('slow'); + $.post('/webGui/include/SysDrivers.php',{table:'t1create',option:"all"},function(data){ + $('#rebuild').prop('disabled', false); + showDrivers("all",true) ; + $('div.spinner.fixed').hide('slow'); + }) ; } function textedit(module) { @@ -152,5 +165,5 @@ showDrivers("all",true) ;

- + From f0b13665a21f4bdd723e71e75c576e220b1b9bd4 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Mon, 17 Jul 2023 23:25:58 +0100 Subject: [PATCH 180/239] Change (builtin) to Kernel Include Kernel - Inuse in selection. --- emhttp/plugins/dynamix/SysDrivers.page | 2 +- emhttp/plugins/dynamix/include/SysDrivers.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 447fe9c1b..b071241e2 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -105,7 +105,7 @@ function showDrivers(options, init = false) { function filterDrivers() { var totalColumns = $('#t1')[0].config.columns; var filter = []; - filter[2] = ($('#select').val() === "inuse") ? "Inuse|Custom|Disabled" : ""; + filter[2] = ($('#select').val() === "inuse") ? "Inuse|Custom|Disabled|'Kernel - Inuse'" : ""; filter[totalColumns] = $('#driversearch').val(); // this searches all columns $('#t1').trigger('search', [ filter ]); } diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 95f41c791..30ddf988a 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -106,9 +106,9 @@ $dir = str_replace("/lib/modules/$kernel/kernel/", "" ,$dir) ; } else { $dir = $file ; $dir = str_replace("drivers/", "" ,$dir) ; - if ($state == "Inuse") $state= "(builtin) - Inuse"; else $state="(builtin)" ; + if ($state == "Inuse") $state= "Kernel - Inuse"; else $state="Kernel" ; } -if ($desc != null) $description = substr($desc , 0 ,70) ; else $description = null ; +if ($desc != null) $description = substr($desc , 0 ,60) ; else $description = null ; $arrModules[$modname] = [ 'modname' => $modname, 'dependacy' => $depends, @@ -231,7 +231,7 @@ switch ($_POST['table']) { $list = file_get_contents($sysdrvfile) ; $arrModules = json_decode($list,TRUE) ; #echo ""._("Actions").""._("Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; - echo ""._("Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; + echo ""._("Driver").""._("Description").""._("State").""._("Type").""._("Modprobe.d config file").""; echo "" ; if (is_array($arrModules)) ksort($arrModules) ; From 993fe61e755bc40b8095871bb7f55bc7142a80fb Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 04:55:52 +0200 Subject: [PATCH 181/239] NFS: changed running process detection --- etc/rc.d/rc.nfsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.nfsd b/etc/rc.d/rc.nfsd index 7eb9bf129..85eef7186 100755 --- a/etc/rc.d/rc.nfsd +++ b/etc/rc.d/rc.nfsd @@ -104,7 +104,7 @@ nfsd_reload() { } nfsd_update() { - [[ $(pgrep -c nfsd) -le 1 ]] && exit 1 # not running + [[ -z $(rpcinfo -s 2>/dev/null|grep -Pom1 'nfs') ]] && exit 1 # not running if check && [[ "$(this)" == "-H ${bind// / -H }" ]]; then # no action required exit 1 From 34276527dac5236cb9416d65fe1aad7c58d0af38 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 04:56:54 +0200 Subject: [PATCH 182/239] rc.library: interfaces always listed in the same order --- etc/rc.d/rc.library.source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index c8d5dc80e..83c96db74 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -199,7 +199,7 @@ check() { [[ $CALLER == ntp ]] && name=$(show $net1) || name= [[ ${name:0:2} != wg && -n $net1 && -z $(good $net1) ]] && ipv4=yes bind+=($net1) fi - done <<< $(ip -br -4 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ {print $1,$3}') + done <<< $(ip -br -4 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ {print $1,$3}'|sort) # active ipv6 interfaces (including wireguard) nets=() while IFS='\n' read -r net; do @@ -213,7 +213,7 @@ check() { [[ $CALLER == ntp ]] && name=$(show $net1) || name= [[ -z $deny6 && ${name:0:2} != wg && -n $net1 && -z $(good $net1) ]] && ipv6=yes bind+=($net1) fi - done <<< $(ip -br -6 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/{$2="";print}') + done <<< $(ip -br -6 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/{$2="";print}'|sort) # add loopback interface if [[ "smb nfs" =~ $CALLER ]]; then [[ $ipv4 == yes ]] && bind+=(127.0.0.1) From 104eee06e3310ad4b5f614f64ef8dd5ec1a253bb Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 11:45:02 +0200 Subject: [PATCH 183/239] RPC: changed running process detection --- etc/rc.d/rc.rpc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.rpc b/etc/rc.d/rc.rpc index 74c77ce37..8d8833afa 100755 --- a/etc/rc.d/rc.rpc +++ b/etc/rc.d/rc.rpc @@ -80,7 +80,7 @@ rpc_reload() { } rpc_update() { - [[ $(pgrep -cf $RPCBIND) -eq 0 ]] && exit 1; # not running + if ! ps axc | grep -q rpcbind; then exit 1; fi # not running if check && [[ "$(this)" == "-h ${bind// / -h }" ]]; then # no action required exit 1 From b4ff52dcac1f3fcef7e34f023ae9352de1e0322e Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 11:46:31 +0200 Subject: [PATCH 184/239] create_network_ini: fixed dhcp hook --- sbin/create_network_ini | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sbin/create_network_ini b/sbin/create_network_ini index c569354f2..2df1989a4 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -4,10 +4,10 @@ # # create initial network.ini file on system start # create system welcome message -# update files on DHCP events 'BOUND[6] REPLY[6] IPV4LL ROUTERADVERT' +# update files on DHCP events 'BOUND[6] IPV4LL' # update services listening interfaces / addresses -[[ (-z $reason && -z $1) || (-n $reason && ! "BOUND6 REPLY6 IPV4LL ROUTERADVERT" =~ $reason) ]] && exit 0 +[[ (-z $reason && -z $1) || (-n $reason && ! "BOUND6 IPV4LL" =~ $reason) ]] && exit 0 ini=/var/local/emhttp/network.ini.new cfg=/boot/config/network.cfg @@ -219,12 +219,13 @@ done # atomically update file /usr/bin/mv $ini ${ini%.*} +logger -t network "hook services: interface=${interface:-$1}, reason=$reason, protocol=$protocol" # delayed execution -/usr/local/emhttp/webGui/scripts/update_services 35 +/usr/local/emhttp/webGui/scripts/update_services 30 # send update information -if [[ -n $interface && -n $data && -e /var/run/nginx.socket ]]; then - curl -sfd "$data" --unix-socket /var/run/nginx.socket http://localhost/pub/dhcp?buffer_length=0 >/dev/null 2>&1 +if [[ -n $data && -e /var/run/nginx.socket ]]; then + curl -sfd "$data" --unix-socket /var/run/nginx.socket http://localhost/pub/dhcp?buffer_length=1 >/dev/null 2>&1 fi # generate our welcome text (management interface only) From 4a11108fea6b7d40a865965dc1ae61ebd9e06b75 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 11:46:46 +0200 Subject: [PATCH 185/239] services: add logging --- emhttp/plugins/dynamix/scripts/reload_services | 1 + emhttp/plugins/dynamix/scripts/update_services | 1 + 2 files changed, 2 insertions(+) diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index f3750640e..84cf285f3 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -4,6 +4,7 @@ SERVICES="rpc nfsd ntpd nginx sshd avahidaemon samba" if [[ -n $1 ]]; then [[ ! -e $1 ]] && touch $1 || exit 0 fi +logger -t network "reload services: ${1:-direct}" for cmd in $SERVICES; do if /etc/rc.d/rc.$cmd update; then /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 diff --git a/emhttp/plugins/dynamix/scripts/update_services b/emhttp/plugins/dynamix/scripts/update_services index 8dc4b3ef2..8f9b0f489 100755 --- a/emhttp/plugins/dynamix/scripts/update_services +++ b/emhttp/plugins/dynamix/scripts/update_services @@ -1,6 +1,7 @@ #!/bin/bash lock=/tmp/atlock.tmp +logger -t network "update services: ${1:-1}s" rm -f $lock echo "sleep ${1:-1};/usr/local/emhttp/webGui/scripts/reload_services $lock"|at -M now 2>/dev/null exit 0 From 14d3b3f2dd11adbf166ce85d3c81b194a3a73bd8 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 12:05:51 +0200 Subject: [PATCH 186/239] create_network_ini: improved IP address collection --- sbin/create_network_ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sbin/create_network_ini b/sbin/create_network_ini index 2df1989a4..5f4d8c31b 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -117,7 +117,7 @@ for ((i=0;i<${SYSNICS:-1};i++)); do echo "USE_DHCP:0=\"${USE_DHCP[$i]}\"" >>$ini if [[ ${USE_DHCP[$i]} == yes ]]; then # get dhcp assigned ipv4 address & mask - NET=($(ip -4 addr show $IFACE|awk '/inet /{sub("/"," ",$2);print $2;exit}')) + NET=($(ip -br -4 addr show $IFACE|awk '{sub("/"," ",$3);print $3;exit}')) GW=$(ip -4 route show default dev $IFACE|awk '{print $3;exit}') echo "IPADDR:0=\"${NET[0]}\"" >>$ini echo "NETMASK:0=\"$(mask ${NET[1]})\"" >>$ini @@ -141,7 +141,7 @@ for ((i=0;i<${SYSNICS:-1};i++)); do echo "USE_DHCP6:0=\"${USE_DHCP6[$i]}\"" >>$ini if [[ ${USE_DHCP6[$i]} == yes ]]; then # get auto assigned ipv6 address & prefix - NET6=($(ip -6 addr show $IFACE noprefixroute|awk '/inet6 /{sub("/"," ",$2);print $2;exit}')) + NET6=($(ip -br -6 addr show $IFACE scope global|awk '{sub("/"," ",$3);print $3;exit}')) GW6=$(ip -6 route show default dev $IFACE|awk '{print $3;exit}') echo "IPADDR6:0=\"${NET6[0]}\"" >>$ini echo "NETMASK6:0=\"${NET6[1]}\"" >>$ini @@ -176,7 +176,7 @@ for ((i=0;i<${SYSNICS:-1};i++)); do if [[ ${USE_DHCP[$i,$j]} == yes ]]; then DEV=$IFACE.${VLANID[$i,$j]} # get dhcp assigned ipv4 address & mask - NET=($(ip -4 addr show $DEV|awk '/inet /{sub("/"," ",$2);print $2;exit}')) + NET=($(ip -br -4 addr show $DEV|awk '{sub("/"," ",$3);print $3;exit}')) GW=$(ip -4 route show default dev $DEV|awk '{print $3;exit}') echo "IPADDR:$j=\"${NET[0]}\"" >>$ini echo "NETMASK:$j=\"$(mask ${NET[1]})\"" >>$ini @@ -194,7 +194,7 @@ for ((i=0;i<${SYSNICS:-1};i++)); do if [[ ${USE_DHCP6[$i,$j]} == yes ]]; then DEV=$IFACE.${VLANID[$i,$j]} # get auto assigned ipv6 address & prefix - NET6=($(ip -6 addr show $DEV noprefixroute|awk '/inet6 /{sub("/"," ",$2);print $2;exit}')) + NET6=($(ip -br -6 addr show $DEV scope global|awk '{sub("/"," ",$3);print $3;exit}')) GW6=$(ip -6 route show default dev $DEV|awk '{print $3;exit}') echo "IPADDR6:$j=\"${NET6[0]}\"" >>$ini echo "NETMASK6:$j=\"${NET6[1]}\"" >>$ini From c880b4d4b2eae2c61829ef30bbcd13819adf2ef5 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 13:03:01 +0200 Subject: [PATCH 187/239] rc.services: exclude wireguard VPN docker tunnels --- etc/rc.d/rc.library.source | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 83c96db74..3f7cdc710 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -190,28 +190,32 @@ check() { nets=() while IFS='\n' read -r net; do net=($net) + # exclude wireguard VPN docker tunnels + [[ ${net:0:2} == wg && $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8 ]] && continue net1=$(sub ${net[1]}) if [[ "avahi show" =~ $CALLER ]]; then [[ -n $net && -n $net1 && -z $(good $net $net1) ]] && bind+=($net) [[ -n $net1 ]] && ipv4=yes nets+=($net1) else # exclude wireguard tunnels for ntp - [[ $CALLER == ntp ]] && name=$(show $net1) || name= - [[ ${name:0:2} != wg && -n $net1 && -z $(good $net1) ]] && ipv4=yes bind+=($net1) + [[ $CALLER == ntp ]] && name=${net:0:2} || name= + [[ $name != wg && -n $net1 && -z $(good $net1) ]] && ipv4=yes bind+=($net1) fi done <<< $(ip -br -4 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ {print $1,$3}'|sort) # active ipv6 interfaces (including wireguard) nets=() while IFS='\n' read -r net; do net=($net) + # exclude wireguard VPN docker tunnels + [[ ${net:0:2} == wg && $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8 ]] && continue net1=$(sub $(main ${net[@]})) if [[ "avahi show" =~ $CALLER ]]; then [[ -n $net && -n $net1 && -z $(good $net $net1) ]] && bind+=($net) [[ -n $net1 ]] && ipv6=yes nets+=($net1) else # exclude wireguard tunnels for ntp - [[ $CALLER == ntp ]] && name=$(show $net1) || name= - [[ -z $deny6 && ${name:0:2} != wg && -n $net1 && -z $(good $net1) ]] && ipv6=yes bind+=($net1) + [[ $CALLER == ntp ]] && name=${net:0:2} || name= + [[ -z $deny6 && $name != wg && -n $net1 && -z $(good $net1) ]] && ipv6=yes bind+=($net1) fi done <<< $(ip -br -6 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/{$2="";print}'|sort) # add loopback interface From a5b16f05bb6eacfb6c95106e8878167f60a8e098 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 13:06:33 +0200 Subject: [PATCH 188/239] rc.services: exclude wireguard tunnels for ntp (code optimization) --- etc/rc.d/rc.library.source | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 3f7cdc710..58a9b2395 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -198,8 +198,8 @@ check() { [[ -n $net1 ]] && ipv4=yes nets+=($net1) else # exclude wireguard tunnels for ntp - [[ $CALLER == ntp ]] && name=${net:0:2} || name= - [[ $name != wg && -n $net1 && -z $(good $net1) ]] && ipv4=yes bind+=($net1) + [[ $CALLER == ntp && ${net:0:2} == wg ]] && continue + [[ -n $net1 && -z $(good $net1) ]] && ipv4=yes bind+=($net1) fi done <<< $(ip -br -4 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ {print $1,$3}'|sort) # active ipv6 interfaces (including wireguard) @@ -214,8 +214,8 @@ check() { [[ -n $net1 ]] && ipv6=yes nets+=($net1) else # exclude wireguard tunnels for ntp - [[ $CALLER == ntp ]] && name=${net:0:2} || name= - [[ -z $deny6 && $name != wg && -n $net1 && -z $(good $net1) ]] && ipv6=yes bind+=($net1) + [[ $CALLER == ntp && ${net:0:2} == wg ]] && continue + [[ -z $deny6 && -n $net1 && -z $(good $net1) ]] && ipv6=yes bind+=($net1) fi done <<< $(ip -br -6 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/{$2="";print}'|sort) # add loopback interface From 5adeed05153c6ad5f9703ec4d740e924a0fa4c60 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 13:12:11 +0200 Subject: [PATCH 189/239] rc.services: exclude wireguard tunnels for ntp (code optimization) --- etc/rc.d/rc.library.source | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index 58a9b2395..f08fb0bd8 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -190,15 +190,14 @@ check() { nets=() while IFS='\n' read -r net; do net=($net) - # exclude wireguard VPN docker tunnels - [[ ${net:0:2} == wg && $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8 ]] && continue + # exclude wireguard VPN docker tunnels and ntp + [[ ${net:0:2} == wg && ($CALLER == ntp || $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8) ]] && continue net1=$(sub ${net[1]}) if [[ "avahi show" =~ $CALLER ]]; then [[ -n $net && -n $net1 && -z $(good $net $net1) ]] && bind+=($net) [[ -n $net1 ]] && ipv4=yes nets+=($net1) else # exclude wireguard tunnels for ntp - [[ $CALLER == ntp && ${net:0:2} == wg ]] && continue [[ -n $net1 && -z $(good $net1) ]] && ipv4=yes bind+=($net1) fi done <<< $(ip -br -4 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ {print $1,$3}'|sort) @@ -206,15 +205,14 @@ check() { nets=() while IFS='\n' read -r net; do net=($net) - # exclude wireguard VPN docker tunnels - [[ ${net:0:2} == wg && $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8 ]] && continue + # exclude wireguard VPN docker tunnels and ntp + [[ ${net:0:2} == wg && ($CALLER == ntp || $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8) ]] && continue net1=$(sub $(main ${net[@]})) if [[ "avahi show" =~ $CALLER ]]; then [[ -n $net && -n $net1 && -z $(good $net $net1) ]] && bind+=($net) [[ -n $net1 ]] && ipv6=yes nets+=($net1) else # exclude wireguard tunnels for ntp - [[ $CALLER == ntp && ${net:0:2} == wg ]] && continue [[ -z $deny6 && -n $net1 && -z $(good $net1) ]] && ipv6=yes bind+=($net1) fi done <<< $(ip -br -6 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/{$2="";print}'|sort) From f427471e244f88aee13b42c8c7648da4b338e715 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 13:13:17 +0200 Subject: [PATCH 190/239] rc.services: exclude wireguard tunnels for ntp (code optimization) --- etc/rc.d/rc.library.source | 2 -- 1 file changed, 2 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index f08fb0bd8..a2762ff16 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -197,7 +197,6 @@ check() { [[ -n $net && -n $net1 && -z $(good $net $net1) ]] && bind+=($net) [[ -n $net1 ]] && ipv4=yes nets+=($net1) else - # exclude wireguard tunnels for ntp [[ -n $net1 && -z $(good $net1) ]] && ipv4=yes bind+=($net1) fi done <<< $(ip -br -4 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ {print $1,$3}'|sort) @@ -212,7 +211,6 @@ check() { [[ -n $net && -n $net1 && -z $(good $net $net1) ]] && bind+=($net) [[ -n $net1 ]] && ipv6=yes nets+=($net1) else - # exclude wireguard tunnels for ntp [[ -z $deny6 && -n $net1 && -z $(good $net1) ]] && ipv6=yes bind+=($net1) fi done <<< $(ip -br -6 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/{$2="";print}'|sort) From ea8c4e57e106c61f09606139bc20b67a551ef99c Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 13:38:38 +0200 Subject: [PATCH 191/239] rc.services: exclude wireguard VPN docker tunnels --- etc/rc.d/rc.library.source | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index a2762ff16..c8149003c 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -190,8 +190,10 @@ check() { nets=() while IFS='\n' read -r net; do net=($net) + # exclude wireguard tunnels for ntp + [[ ${net:0:2} == wg && $CALLER == ntp ]] && continue # exclude wireguard VPN docker tunnels and ntp - [[ ${net:0:2} == wg && ($CALLER == ntp || $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8) ]] && continue + [[ ${net:0:2} == wg && $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8 ]] && continue net1=$(sub ${net[1]}) if [[ "avahi show" =~ $CALLER ]]; then [[ -n $net && -n $net1 && -z $(good $net $net1) ]] && bind+=($net) @@ -204,8 +206,10 @@ check() { nets=() while IFS='\n' read -r net; do net=($net) - # exclude wireguard VPN docker tunnels and ntp - [[ ${net:0:2} == wg && ($CALLER == ntp || $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8) ]] && continue + # exclude wireguard tunnels for ntp + [[ ${net:0:2} == wg && $CALLER == ntp ]] && continue + # exclude wireguard VPN docker tunnels + [[ ${net:0:2} == wg && $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8 ]] && continue net1=$(sub $(main ${net[@]})) if [[ "avahi show" =~ $CALLER ]]; then [[ -n $net && -n $net1 && -z $(good $net $net1) ]] && bind+=($net) From 01fb06138c732d0409acb2427634cd322f4ceb09 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 13:43:29 +0200 Subject: [PATCH 192/239] rc.services: exclude wireguard VPN docker tunnels --- etc/rc.d/rc.library.source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index c8149003c..e40036fd5 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -192,7 +192,7 @@ check() { net=($net) # exclude wireguard tunnels for ntp [[ ${net:0:2} == wg && $CALLER == ntp ]] && continue - # exclude wireguard VPN docker tunnels and ntp + # exclude wireguard VPN docker tunnels [[ ${net:0:2} == wg && $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8 ]] && continue net1=$(sub ${net[1]}) if [[ "avahi show" =~ $CALLER ]]; then From a1e6c4a7a7783cda0d4fc5002fd023662d727f21 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 13:56:38 +0200 Subject: [PATCH 193/239] services: add logging --- emhttp/plugins/dynamix/scripts/reload_services | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index 84cf285f3..0988decc2 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -4,9 +4,9 @@ SERVICES="rpc nfsd ntpd nginx sshd avahidaemon samba" if [[ -n $1 ]]; then [[ ! -e $1 ]] && touch $1 || exit 0 fi -logger -t network "reload services: ${1:-direct}" for cmd in $SERVICES; do if /etc/rc.d/rc.$cmd update; then + logger -t network "reload service: $cmd" /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 fi done From 1caadf7da03dc0e2ea56b3c739ededc83fd4fe2f Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 17:03:19 +0200 Subject: [PATCH 194/239] Update monitor_nchan --- sbin/monitor_nchan | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sbin/monitor_nchan b/sbin/monitor_nchan index 02bd3776a..18d854a43 100755 --- a/sbin/monitor_nchan +++ b/sbin/monitor_nchan @@ -15,7 +15,8 @@ while :; do # steady state? subs=$(curl --unix-socket $nginx $status 2>/dev/null|grep -Pom1 'subscribers: \K\d+') if [[ -z $subs || $subs -eq 0 ]]; then - # kill GUI registered nchan processes + logger -t monitor "Stop running nchan processes" + # kill GUI registered nchan processes while IFS=$'\n' read -r running; do pkill -f $docroot/${running/:stop/} done < $nchan_pid @@ -27,3 +28,4 @@ while :; do # check every 30 seconds sleep 30 done & +disown %% From 157d28ab0b7330ed94b0300841b47d330a47cacc Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 17:04:15 +0200 Subject: [PATCH 195/239] Add nginx watcher: restart nginx when open sockets are present --- etc/rc.d/rc.local | 5 +++++ sbin/monitor_nginx | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 sbin/monitor_nginx diff --git a/etc/rc.d/rc.local b/etc/rc.d/rc.local index 056c7e8f9..b8d21c6bf 100755 --- a/etc/rc.d/rc.local +++ b/etc/rc.d/rc.local @@ -65,6 +65,11 @@ if [[ -x /usr/local/sbin/monitor_nchan ]]; then /usr/local/sbin/monitor_nchan fi +# start nginx monitoring -> restart nginx service when open sockets are present +if [[ -x /usr/local/sbin/monitor_nginx ]]; then + /usr/local/sbin/monitor_nginx +fi + # First boot following unRAID Server OS update: delete plugin file rm -f /boot/plugins/unRAIDServer.plg rm -f $CONFIG/plugins/unRAIDServer.plg diff --git a/sbin/monitor_nginx b/sbin/monitor_nginx new file mode 100644 index 000000000..af02fa44c --- /dev/null +++ b/sbin/monitor_nginx @@ -0,0 +1,20 @@ +#!/bin/bash +NGINX="/usr/sbin/nginx" +CONF="/etc/nginx/nginx.conf" +LOG="/var/log/nginx/error.log" + +while :; do + # check log for nginx socket errors + if tail -3 $LOG 2>/dev/null|grep -q 'open socket'; then + # hard restart + logger -t monitor "Restarting nginx" + pkill -f $NGINX + sleep 1 + # remove open socket errors from LOG + sed -ri '/alert.+?(open socket|aborting)/d' $LOG + $NGINX -c $CONF 2>/dev/null + fi + # check every 10 seconds + sleep 10 +done & +disown %% From a6f615ead2ebf5ccae5a9bdacc33768083ae64b2 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 17:05:24 +0200 Subject: [PATCH 196/239] Make script executable --- sbin/monitor_nginx | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 sbin/monitor_nginx diff --git a/sbin/monitor_nginx b/sbin/monitor_nginx old mode 100644 new mode 100755 From 89d52bb7020a3e2cb1df9668e53a59aaa4b1c784 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 21:54:50 +0200 Subject: [PATCH 197/239] Revert "Make script executable" This reverts commit a6f615ead2ebf5ccae5a9bdacc33768083ae64b2. --- sbin/monitor_nginx | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 sbin/monitor_nginx diff --git a/sbin/monitor_nginx b/sbin/monitor_nginx old mode 100755 new mode 100644 From 3bdc5f50940080af4134dc1668a835f11ecf267a Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 18 Jul 2023 21:55:05 +0200 Subject: [PATCH 198/239] Revert "Add nginx watcher: restart nginx when open sockets are present" This reverts commit 157d28ab0b7330ed94b0300841b47d330a47cacc. --- etc/rc.d/rc.local | 5 ----- sbin/monitor_nginx | 20 -------------------- 2 files changed, 25 deletions(-) delete mode 100644 sbin/monitor_nginx diff --git a/etc/rc.d/rc.local b/etc/rc.d/rc.local index b8d21c6bf..056c7e8f9 100755 --- a/etc/rc.d/rc.local +++ b/etc/rc.d/rc.local @@ -65,11 +65,6 @@ if [[ -x /usr/local/sbin/monitor_nchan ]]; then /usr/local/sbin/monitor_nchan fi -# start nginx monitoring -> restart nginx service when open sockets are present -if [[ -x /usr/local/sbin/monitor_nginx ]]; then - /usr/local/sbin/monitor_nginx -fi - # First boot following unRAID Server OS update: delete plugin file rm -f /boot/plugins/unRAIDServer.plg rm -f $CONFIG/plugins/unRAIDServer.plg diff --git a/sbin/monitor_nginx b/sbin/monitor_nginx deleted file mode 100644 index af02fa44c..000000000 --- a/sbin/monitor_nginx +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -NGINX="/usr/sbin/nginx" -CONF="/etc/nginx/nginx.conf" -LOG="/var/log/nginx/error.log" - -while :; do - # check log for nginx socket errors - if tail -3 $LOG 2>/dev/null|grep -q 'open socket'; then - # hard restart - logger -t monitor "Restarting nginx" - pkill -f $NGINX - sleep 1 - # remove open socket errors from LOG - sed -ri '/alert.+?(open socket|aborting)/d' $LOG - $NGINX -c $CONF 2>/dev/null - fi - # check every 10 seconds - sleep 10 -done & -disown %% From 783d5637c5e3f5c9145d8e1646d9760e02c2c388 Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 19 Jul 2023 01:01:26 +0200 Subject: [PATCH 199/239] NFS: fixed running process detection --- etc/rc.d/rc.nfsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.nfsd b/etc/rc.d/rc.nfsd index 85eef7186..9b369a1a6 100755 --- a/etc/rc.d/rc.nfsd +++ b/etc/rc.d/rc.nfsd @@ -104,7 +104,7 @@ nfsd_reload() { } nfsd_update() { - [[ -z $(rpcinfo -s 2>/dev/null|grep -Pom1 'nfs') ]] && exit 1 # not running + if ! ps axc | grep -q rpc.mountd; then exit 1; fi # not running if check && [[ "$(this)" == "-H ${bind// / -H }" ]]; then # no action required exit 1 From 78cdf2a7cd54434d4d579ad1d0837c430168a382 Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 19 Jul 2023 01:30:12 +0200 Subject: [PATCH 200/239] NGINX: revise running process detection --- etc/rc.d/rc.nginx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.nginx b/etc/rc.d/rc.nginx index b8c10afba..f4f254d08 100755 --- a/etc/rc.d/rc.nginx +++ b/etc/rc.d/rc.nginx @@ -697,7 +697,7 @@ nginx_renew() { } nginx_update() { - [[ $(pgrep -cf $NGINX) -eq 0 ]] && exit 1 # not running + if ! nginx_status; then exit 1; fi # not running if check && [[ "$(this)" == "$bind" ]]; then # no action required exit 1 From ba0e21b27fb41e1bf01f4d465496ad889c835118 Mon Sep 17 00:00:00 2001 From: ljm42 Date: Tue, 18 Jul 2023 19:59:38 -0700 Subject: [PATCH 201/239] rc.libvirt: revised libvirt daemon running check --- etc/rc.d/rc.libvirt | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.libvirt b/etc/rc.d/rc.libvirt index e19f7790f..17f0900a4 100755 --- a/etc/rc.d/rc.libvirt +++ b/etc/rc.d/rc.libvirt @@ -142,6 +142,22 @@ test() { exit 1 } +waitstop() { + # wait for daemon to exit + PIDFILE=$1 + PNAME=$2 + for n in {1..15}; do + sleep 1 + if [[ ! -f "$PIDFILE" || $(ps -p $(cat "$PIDFILE") -o comm= 2>/dev/null) != "$PNAME" ]]; then + rm -f "$PIDFILE" + return 0 + fi + echo "waiting for $PNAME to die ..." + done + echo "$PNAME will not die!" + return 1 +} + start_libvirtd() { if [ -f $LIBVIRTD_PIDFILE ];then echo "libvirt is already running..." @@ -177,7 +193,7 @@ stop_libvirtd() { /usr/sbin/virsh net-destroy $network done kill -TERM $(cat $LIBVIRTD_PIDFILE) - sleep 3 + waitstop $LIBVIRTD_PIDFILE "libvirtd" check_processor /sbin/modprobe -ra $MODULE $MODULES 2>/dev/null } @@ -199,7 +215,7 @@ stop_virtlogd() { fi echo "Stopping virtlogd..." kill -TERM $(cat $VIRTLOGD_PIDFILE) - sleep 1 + waitstop $VIRTLOGD_PIDFILE "virtlogd" } start_virtlockd() { @@ -219,7 +235,7 @@ stop_virtlockd() { fi echo "Stopping virtlockd..." kill -TERM $(cat $VIRTLOCKD_PIDFILE) - sleep 1 + waitstop $VIRTLOCKD_PIDFILE "virtlockd" } cleanup() { From dd503c9552b20d0125980335b25fe99d4e6b8dff Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 19 Jul 2023 11:40:42 +0200 Subject: [PATCH 202/239] Shares: show "Minimum free space" as absolute number instead of percentage --- emhttp/plugins/dynamix/ShareEdit.page | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/emhttp/plugins/dynamix/ShareEdit.page b/emhttp/plugins/dynamix/ShareEdit.page index 00d7db594..9c26abb99 100644 --- a/emhttp/plugins/dynamix/ShareEdit.page +++ b/emhttp/plugins/dynamix/ShareEdit.page @@ -62,13 +62,10 @@ function presetSpace($val) { $pool = _var($shares[$name],'cachePool'); $size = _var($fsSize,$pool,0); $size = $size>0 ? round(100*$val/$size,1) : 0; - $unit = '%'; - if ($size < 1) { - $units = ['KB','MB','GB','TB','PB','EB','ZB','YB']; - $base = $val>0 ? floor(log($val,1000)) : 0; - $size = round($val/pow(1000,$base),1); - $unit = _var($units,$base); - } + $units = ['KB','MB','GB','TB','PB','EB','ZB','YB']; + $base = $val>0 ? floor(log($val,1000)) : 0; + $size = round($val/pow(1000,$base),1); + $unit = _var($units,$base); [$dot,$comma] = str_split(_var($display,'number','.,')); return $size>0 ? number_format($size,$size-floor($size)?1:0,$dot,$comma).' '.$unit : ''; } From 4ee1b3e9d1f39e2ac845f08f4a8aebab26c5e656 Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 19 Jul 2023 11:42:30 +0200 Subject: [PATCH 203/239] Pools: show "Minimum free space" as absolute number instead of percentage --- emhttp/plugins/dynamix/DeviceInfo.page | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/emhttp/plugins/dynamix/DeviceInfo.page b/emhttp/plugins/dynamix/DeviceInfo.page index 933fe6141..589c52ac3 100644 --- a/emhttp/plugins/dynamix/DeviceInfo.page +++ b/emhttp/plugins/dynamix/DeviceInfo.page @@ -39,13 +39,10 @@ function presetSpace($val) { sanitize($val); $size = _var($disk,'fsSize',0); $size = $size>0 ? round(100*$val/$size,1) : 0; - $unit = '%'; - if ($size < 1) { - $units = ['KB','MB','GB','TB','PB','EB','ZB','YB']; - $base = $val>0 ? floor(log($val,1000)) : 0; - $size = round($val/pow(1000,$base),1); - $unit = _var($units,$base); - } + $units = ['KB','MB','GB','TB','PB','EB','ZB','YB']; + $base = $val>0 ? floor(log($val,1000)) : 0; + $size = round($val/pow(1000,$base),1); + $unit = _var($units,$base); [$dot,$comma] = str_split(_var($display,'number','.,')); return $size>0 ? number_format($size,$size-floor($size)?1:0,$dot,$comma).' '.$unit : ''; } From 4a7a654a5eb07b172f13b0ea934d52800ffd0d62 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 21 Jul 2023 09:41:26 +0200 Subject: [PATCH 204/239] rc.library: fix show ipv6 --- etc/rc.d/rc.library.source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.library.source b/etc/rc.d/rc.library.source index e40036fd5..f27c1b65b 100644 --- a/etc/rc.d/rc.library.source +++ b/etc/rc.d/rc.library.source @@ -107,7 +107,7 @@ show() { case $# in 1) ip -br addr show scope global to $1 2>/dev/null|awk '{print $1;exit}';; 2) ip -br addr show scope global $1 $2 2>/dev/null|awk '{print $3;exit}';; - 3) [[ $1 == -6 ]] && main $(ip -br -6 addr show scope global $2 $3 2>/dev/null|awk '{$2="";print;exit}') || ip -br -4 addr show scope global $2 $3 2>/dev/null|awk '{print $3;exit}';; + 3) if [[ $1 == -6 ]]; then main $(ip -br -6 addr show scope global $2 $3 2>/dev/null|awk '{$2="";print;exit}'); else ip -br -4 addr show scope global $2 $3 2>/dev/null|awk '{print $3;exit}'; fi;; esac } From b7a1fc07efe271283c3227103237b3d4a1f9f4ba Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Fri, 21 Jul 2023 12:54:08 +0100 Subject: [PATCH 205/239] Retain VNC password during update. --- .../plugins/dynamix.vm.manager/include/libvirt.php | 14 ++++++++++++++ .../dynamix.vm.manager/include/libvirt_helpers.php | 1 + .../dynamix.vm.manager/templates/Custom.form.php | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index eaa144ef7..7652564ad 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -1944,6 +1944,20 @@ return $var; } + function domain_get_vnc_password($domain) { + $domain_name = $this->domain_get_name($domain) ; + $password = shell_exec("cat /etc/libvirt/qemu/'{$domain_name}.xml' | grep 'passwd'") ; + + if (!$password) + return ''; + + $strpos = strpos($password, "passwd=") +8 ; + $endpos = strpos($password, "'",$strpos) ; + $password = substr($password,$strpos, $endpos-$strpos) ; + + return $password ; + } + function domain_get_ws_port($domain) { $tmp = $this->get_xpath($domain, '//domain/devices/graphics/@websocket', false); $var = (int)$tmp[0]; diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php index 7bf82d5cd..5d9193c3e 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php @@ -1149,6 +1149,7 @@ private static $encoding = 'UTF-8'; 'protocol' => $lv->domain_get_vmrc_protocol($res), 'model' => $lv->domain_get_vnc_model($res), 'keymap' => $lv->domain_get_vnc_keymap($res), + 'password' => $lv->domain_get_vnc_password($res), 'port' => $vmrcport, 'wsport' => $lv->domain_get_ws_port($res), 'autoport' => $autoport, diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 011d82724..d5fa2369a 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -1044,7 +1044,7 @@ _(VM Console Password)_: - + _(VM Console Keyboard)_: From 33230da120086f31305a4463eecb352bf559a79c Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Fri, 21 Jul 2023 23:19:02 +0100 Subject: [PATCH 206/239] Update initial build process --- .../event/driver_loaded/SysDriversBuild | 3 + emhttp/plugins/dynamix/include/SysDrivers.php | 198 +----------------- .../dynamix/include/SysDriversHelpers.php | 176 ++++++++++++++++ .../dynamix/include/SysDriversInit.php | 33 +++ 4 files changed, 214 insertions(+), 196 deletions(-) create mode 100644 emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild create mode 100644 emhttp/plugins/dynamix/include/SysDriversHelpers.php create mode 100644 emhttp/plugins/dynamix/include/SysDriversInit.php diff --git a/emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild b/emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild new file mode 100644 index 000000000..132c40dfc --- /dev/null +++ b/emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild @@ -0,0 +1,3 @@ +#!/bin/bash +/usr/bin/logger "Submitting SysDrivers Build" +/usr/local/emhttp/plugins/dynamix/include/SysDriversInit.php &> /dev/null & \ No newline at end of file diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 30ddf988a..a32de7a18 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -16,6 +16,7 @@ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; $_SERVER['REQUEST_URI'] = 'tools'; require_once "$docroot/webGui/include/Translations.php"; require_once "$docroot/webGui/include/Helpers.php"; +require_once "$docroot/webGui/include/SysDriversHelpers.php"; require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php"; $kernel = shell_exec("uname -r") ; @@ -27,210 +28,17 @@ $sysdrvfile = "/tmp/sysdrivers.json" ; if (!is_file($modtoplgfile) || !is_file($sysdrvfile)) { modtoplg() ; createlist() ;} $arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ; -function getplugin($in) { - $plugins = "/var/log/plugins/"; - $plugin_link = $plugins.$in ; - $plugin_file = @readlink($plugin_link); - $support = plugin('support',$plugin_file) ?: ""; - return($support) ; -} - -function getmodules($line) { - global $arrModules,$lsmod,$kernel,$arrModtoPlg,$modplugins ; - $modprobe = "" ; - $desc = $file = $pluginfile = $option = $filename = $depends = $support = $supporturl = $dir = $state = null ; - $name = $line ; - #echo $line ; - $modname = shell_exec("modinfo $name > /dev/null") ; - if ($modname != null) $modname = trim($modname,"\n") ; - $output=null ; - exec("modinfo $name",$output,$error) ; - $parms = array() ; - foreach($output as $outline) { - $data = explode(":",$outline) ; - $support = false ; $supporturl = null ; - switch ($data[0]) - { - case "name": - $modname = trim($data[1]) ; - break ; - case "depends": - $depends = trim($data[1]) ; - break ; - case "filename": - $filename = trim($data[1]) ; - break ; - case "description": - $desc = trim($data[1]) ; - break ; - case "parm": - $parms[] = trim(str_replace("parm:","",$outline)) ; - break ; - case "file": - $file = trim(str_replace("file:","",$outline)) ; - break ; - case "alias": - case "author": - case "firmware": - case "intree": - case "vermagic": - case "retpoline": - case "import_ns": - case "license": - break ; - default: - $parms[] = trim($outline) ; - break ; - } -} -if ($modname != null) { - if (strpos($lsmod, $modname,0)) $state = "Inuse" ; else $state = "Available"; - if (isset($arrModtoPlg[$modname])) { $support = true ; $supporturl = plugin("support", $modplugins[$arrModtoPlg[$modname]]) ; $pluginfile = "Plugin name: {$arrModtoPlg[$modname]}" ; } else { $support = false ; $supporturl = null ; } - } -if (is_file("/boot/config/modprobe.d/$modname.conf")) { - $modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf") ; - $state = strpos($modprobe, "blacklist"); - $modprobe = explode(PHP_EOL,$modprobe) ; - if($state !== false) {$state = "Disabled" ;} - else $state="Custom" ; - } - -if ($filename != "(builtin)") { -if ($filename != null) { -$type = pathinfo($filename) ; -$dir = $type['dirname'] ; - -$dir = str_replace("/lib/modules/$kernel/kernel/drivers/", "" ,$dir) ; -$dir = str_replace("/lib/modules/$kernel/kernel/", "" ,$dir) ; -} -} else { - $dir = $file ; - $dir = str_replace("drivers/", "" ,$dir) ; - if ($state == "Inuse") $state= "Kernel - Inuse"; else $state="Kernel" ; -} -if ($desc != null) $description = substr($desc , 0 ,60) ; else $description = null ; -$arrModules[$modname] = [ - 'modname' => $modname, - 'dependacy' => $depends, - 'parms' => $parms, - 'file' => $file, - 'modprobe' => $modprobe, - 'plugin' => $pluginfile , - 'state' => $state, - 'type' => $dir, - 'support' => $support, - 'supporturl' => $supporturl, - 'description' => $description , -] ; -} - -function modtoplg() { - global $modtoplgfile ; - $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/boot/config/plugins')); - $files = array(); - - /** @var SplFileInfo $file */ - foreach ($rii as $file) { - if ($file->isDir()){ - continue; - } - if ($file->getExtension() != "tgz" && $file->getExtension() != "txz") continue ; - $files[] = $file->getPathname(); - } - - $list = array() ; - foreach ($files as $f) { - $plugin = str_replace("/boot/config/plugins/", "", $f) ; - $plugin = substr($plugin,0,strpos($plugin,'/') ) ; - $tar = [] ; - exec("tar -tf $f | grep -E '.ko.xz|.ko' ",$tar) ; - foreach ($tar as $t) { - $p = pathinfo($t) ; - $filename = str_replace(".ko","",$p["filename"]) ; - $list[$filename] = $plugin ; - } - } - - file_put_contents($modtoplgfile,json_encode($list,JSON_PRETTY_PRINT)) ; - -} - -function createlist() { - global $modtoplgfile, $sysdrvfile, $lsmod, $kernel,$arrModules, $modplugins ; - $arrModtoPlg = json_decode(file_get_contents($modtoplgfile) ,TRUE) ; - $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; - $builtinmodules = explode(PHP_EOL,$builtinmodules) ; - $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; - $procmodules = explode(PHP_EOL,$procmodules) ; - $arrModules = array() ; - - $list = scandir('/var/log/plugins/') ; - foreach($list as $f) $modplugins[plugin("name" , @readlink("/var/log/plugins/$f"))] = @readlink("/var/log/plugins/$f") ; - - foreach($builtinmodules as $bultin) - { - if ($bultin == "") continue ; - getmodules(pathinfo($bultin)["filename"]) ; - } - - foreach($procmodules as $line) { - if ($line == "") continue ; - getmodules(pathinfo($line)["filename"]) ; - } - - $lsmod2 = explode(PHP_EOL,$lsmod) ; - foreach($lsmod2 as $line) { - if ($line == "") continue ; - $line2 = explode(" ",$line) ; - getmodules($line2['0']) ; - } - - unset($arrModules['null']); - file_put_contents($sysdrvfile,json_encode($arrModules,JSON_PRETTY_PRINT)) ; -} - switch ($_POST['table']) { case 't1create': modtoplg() ; createlist() ; - /*$arrModtoPlg = json_decode(file_get_contents($modtoplgfile) ,TRUE) ; - $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; - $builtinmodules = explode(PHP_EOL,$builtinmodules) ; - $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; - $procmodules = explode(PHP_EOL,$procmodules) ; - $arrModules = array() ; - - $list = scandir('/var/log/plugins/') ; - foreach($list as $f) $modplugins[plugin("name" , @readlink("/var/log/plugins/$f"))] = @readlink("/var/log/plugins/$f") ; - - foreach($builtinmodules as $bultin) - { - if ($bultin == "") continue ; - getmodules(pathinfo($bultin)["filename"]) ; - } - - foreach($procmodules as $line) { - if ($line == "") continue ; - getmodules(pathinfo($line)["filename"]) ; - } - - $lsmod2 = explode(PHP_EOL,$lsmod) ; - foreach($lsmod2 as $line) { - if ($line == "") continue ; - $line2 = explode(" ",$line) ; - getmodules($line2['0']) ; - } - - unset($arrModules['null']); - file_put_contents($sysdrvfile,json_encode($arrModules,JSON_PRETTY_PRINT)) ; */ - + break; case 't1load': $list = file_get_contents($sysdrvfile) ; $arrModules = json_decode($list,TRUE) ; - #echo ""._("Actions").""._("Driver").""._("Description").""._("State").""._("Type").""._("Modeprobe.d config file").""; echo ""._("Driver").""._("Description").""._("State").""._("Type").""._("Modprobe.d config file").""; echo "" ; @@ -248,10 +56,8 @@ switch ($_POST['table']) { } echo "" ; - #echo "" ; if ($supportpage) { if ($module['support'] == false) { - #$supporthtml = "" ; $supporthtml = "" ; } else { $supporturl = $module['supporturl'] ; diff --git a/emhttp/plugins/dynamix/include/SysDriversHelpers.php b/emhttp/plugins/dynamix/include/SysDriversHelpers.php new file mode 100644 index 000000000..a3a621e66 --- /dev/null +++ b/emhttp/plugins/dynamix/include/SysDriversHelpers.php @@ -0,0 +1,176 @@ + /dev/null") ; + if ($modname != null) $modname = trim($modname,"\n") ; + $output=null ; + exec("modinfo $name",$output,$error) ; + $parms = array() ; + foreach($output as $outline) { + $data = explode(":",$outline) ; + $support = false ; $supporturl = null ; + switch ($data[0]) + { + case "name": + $modname = trim($data[1]) ; + break ; + case "depends": + $depends = trim($data[1]) ; + break ; + case "filename": + $filename = trim($data[1]) ; + break ; + case "description": + $desc = trim($data[1]) ; + break ; + case "parm": + $parms[] = trim(str_replace("parm:","",$outline)) ; + break ; + case "file": + $file = trim(str_replace("file:","",$outline)) ; + break ; + case "alias": + case "author": + case "firmware": + case "intree": + case "vermagic": + case "retpoline": + case "import_ns": + case "license": + break ; + default: + $parms[] = trim($outline) ; + break ; + } +} +if ($modname != null) { + if (strpos($lsmod, $modname,0)) $state = "Inuse" ; else $state = "Available"; + if (isset($arrModtoPlg[$modname])) { $support = true ; $supporturl = plugin("support", $modplugins[$arrModtoPlg[$modname]]) ; $pluginfile = "Plugin name: {$arrModtoPlg[$modname]}" ; } else { $support = false ; $supporturl = null ; } + } +if (is_file("/boot/config/modprobe.d/$modname.conf")) { + $modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf") ; + $state = strpos($modprobe, "blacklist"); + $modprobe = explode(PHP_EOL,$modprobe) ; + if($state !== false) {$state = "Disabled" ;} + else $state="Custom" ; + } + +if ($filename != "(builtin)") { +if ($filename != null) { +$type = pathinfo($filename) ; +$dir = $type['dirname'] ; + +$dir = str_replace("/lib/modules/$kernel/kernel/drivers/", "" ,$dir) ; +$dir = str_replace("/lib/modules/$kernel/kernel/", "" ,$dir) ; +} +} else { + $dir = $file ; + $dir = str_replace("drivers/", "" ,$dir) ; + if ($state == "Inuse") $state= "Kernel - Inuse"; else $state="Kernel" ; +} +if ($desc != null) $description = substr($desc , 0 ,60) ; else $description = null ; +$arrModules[$modname] = [ + 'modname' => $modname, + 'dependacy' => $depends, + 'parms' => $parms, + 'file' => $file, + 'modprobe' => $modprobe, + 'plugin' => $pluginfile , + 'state' => $state, + 'type' => $dir, + 'support' => $support, + 'supporturl' => $supporturl, + 'description' => $description , +] ; +} + +function modtoplg() { + global $modtoplgfile ; + $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/boot/config/plugins')); + $files = array(); + + /** @var SplFileInfo $file */ + foreach ($rii as $file) { + if ($file->isDir()){ + continue; + } + if ($file->getExtension() != "tgz" && $file->getExtension() != "txz") continue ; + $files[] = $file->getPathname(); + } + + $list = array() ; + foreach ($files as $f) { + $plugin = str_replace("/boot/config/plugins/", "", $f) ; + $plugin = substr($plugin,0,strpos($plugin,'/') ) ; + $tar = [] ; + exec("tar -tf $f | grep -E '.ko.xz|.ko' ",$tar) ; + foreach ($tar as $t) { + $p = pathinfo($t) ; + $filename = str_replace(".ko","",$p["filename"]) ; + $list[$filename] = $plugin ; + } + } + + file_put_contents($modtoplgfile,json_encode($list,JSON_PRETTY_PRINT)) ; + +} + +function createlist() { + global $modtoplgfile, $sysdrvfile, $lsmod, $kernel,$arrModules, $modplugins ; + $arrModtoPlg = json_decode(file_get_contents($modtoplgfile) ,TRUE) ; + $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; + $builtinmodules = explode(PHP_EOL,$builtinmodules) ; + $procmodules =file_get_contents("/lib/modules/$kernel/modules.order") ; + $procmodules = explode(PHP_EOL,$procmodules) ; + $arrModules = array() ; + + $list = scandir('/var/log/plugins/') ; + foreach($list as $f) $modplugins[plugin("name" , @readlink("/var/log/plugins/$f"))] = @readlink("/var/log/plugins/$f") ; + + foreach($builtinmodules as $bultin) + { + if ($bultin == "") continue ; + getmodules(pathinfo($bultin)["filename"]) ; + } + + foreach($procmodules as $line) { + if ($line == "") continue ; + getmodules(pathinfo($line)["filename"]) ; + } + + $lsmod2 = explode(PHP_EOL,$lsmod) ; + foreach($lsmod2 as $line) { + if ($line == "") continue ; + $line2 = explode(" ",$line) ; + getmodules($line2['0']) ; + } + + unset($arrModules['null']); + file_put_contents($sysdrvfile,json_encode($arrModules,JSON_PRETTY_PRINT)) ; +} + +?> \ No newline at end of file diff --git a/emhttp/plugins/dynamix/include/SysDriversInit.php b/emhttp/plugins/dynamix/include/SysDriversInit.php new file mode 100644 index 000000000..ad2d6b75a --- /dev/null +++ b/emhttp/plugins/dynamix/include/SysDriversInit.php @@ -0,0 +1,33 @@ +#!/usr/bin/php + \ No newline at end of file From d2634e821a28030e03ddb5a808c7505fc793e75e Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Fri, 21 Jul 2023 23:19:16 +0100 Subject: [PATCH 207/239] Delete SysDriversInit.php --- .../event/driver_loaded/SysDriversInit.php | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100755 emhttp/plugins/dynamix/event/driver_loaded/SysDriversInit.php diff --git a/emhttp/plugins/dynamix/event/driver_loaded/SysDriversInit.php b/emhttp/plugins/dynamix/event/driver_loaded/SysDriversInit.php deleted file mode 100755 index a402f2e23..000000000 --- a/emhttp/plugins/dynamix/event/driver_loaded/SysDriversInit.php +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/php -"t1create","csrf_token" => $var['csrf_token']]) ; -?> \ No newline at end of file From beb3fe1527f92f9f9e74cee1396f08681cc5a550 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Fri, 21 Jul 2023 23:20:07 +0100 Subject: [PATCH 208/239] Make script executable --- emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild | 0 emhttp/plugins/dynamix/include/SysDriversInit.php | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild mode change 100644 => 100755 emhttp/plugins/dynamix/include/SysDriversInit.php diff --git a/emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild b/emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild old mode 100644 new mode 100755 diff --git a/emhttp/plugins/dynamix/include/SysDriversInit.php b/emhttp/plugins/dynamix/include/SysDriversInit.php old mode 100644 new mode 100755 From 6ec8cc9334d5f8b0cc7ae0e8f9cf26d066fc9b3f Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 22 Jul 2023 00:05:45 +0100 Subject: [PATCH 209/239] Disable rebuild button first time after boot. --- emhttp/plugins/dynamix/SysDrivers.page | 8 +++++-- emhttp/plugins/dynamix/include/SysDrivers.php | 24 ++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index b071241e2..f4b2ef9c0 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -74,10 +74,12 @@ function showDrivers(options, init = false) { if (init) { $('#driversearch').prop('disabled', true); $('#select').prop('disabled', true); + $('#rebuild').prop('disabled', true); + $.post('/webGui/include/SysDrivers.php',{table:'t1load',option:"all"},function(data){ clearTimeout(timers.refresh); $("#t1").trigger("destroy"); - $('#t1').html(data); + $('#t1').html(data.html); $('#t1').tablesorter({ sortList:[[0,0]], sortAppend:[[0,0]], @@ -94,7 +96,9 @@ function showDrivers(options, init = false) { $('div.spinner.fixed').hide('slow'); $('#driversearch').prop('disabled', false); $('#select').prop('disabled', false); - }); + $('#rebuild').prop('disabled', data.init); + + },"json"); } else { filter = []; diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index a32de7a18..9976e7863 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -25,6 +25,7 @@ $lsmod = shell_exec("lsmod") ; $supportpage = true; $modtoplgfile = "/tmp/modulestoplg.json" ; $sysdrvfile = "/tmp/sysdrivers.json" ; +$sysdrvinit = "/tmp/sysdrivers.init" ; if (!is_file($modtoplgfile) || !is_file($sysdrvfile)) { modtoplg() ; createlist() ;} $arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ; @@ -39,8 +40,9 @@ switch ($_POST['table']) { case 't1load': $list = file_get_contents($sysdrvfile) ; $arrModules = json_decode($list,TRUE) ; - echo ""._("Driver").""._("Description").""._("State").""._("Type").""._("Modprobe.d config file").""; - echo "" ; + $init = file_get_contents($sysdrvinit) ; + $html = ""._("Driver").""._("Description").""._("State").""._("Type").""._("Modprobe.d config file").""; + $html .= "" ; if (is_array($arrModules)) ksort($arrModules) ; foreach($arrModules as $modname => $module) { @@ -55,7 +57,7 @@ switch ($_POST['table']) { $module['modprobe'] = $modprobe ; } - echo "" ; + $html .= "" ; if ($supportpage) { if ($module['support'] == false) { $supporthtml = "" ; @@ -65,17 +67,23 @@ switch ($_POST['table']) { $supporthtml = "" ; } } - echo "$modname$supporthtml" ; - echo "{$module['description']}{$module['state']}{$module['type']}"; + $html .= "$modname$supporthtml" ; + $html .= "{$module['description']}{$module['state']}{$module['type']}"; $text = "" ; if (is_array($module["modprobe"])) { $text = implode("\n",$module["modprobe"]) ; - echo ""; - } else echo ""; + $html .= ""; + } else $html .= ""; } - echo "" ; + $html .= "" ; + #if ($init) {unlink($sysdrvinit) ; $init = true ;} + $rtn = array() ; + $rtn['html'] = $html ; + if ($init !== false) {$init = true ; unlink($sysdrvinit) ;} + $rtn['init'] = $init ; + echo json_encode($rtn) ; break; case "update": From c66026364b4f37952e5247c032048fa2cc4f1ed8 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 22 Jul 2023 08:14:21 +0100 Subject: [PATCH 210/239] Fix support icon after system boot --- emhttp/plugins/dynamix/include/SysDriversHelpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/SysDriversHelpers.php b/emhttp/plugins/dynamix/include/SysDriversHelpers.php index a3a621e66..6727258b5 100644 --- a/emhttp/plugins/dynamix/include/SysDriversHelpers.php +++ b/emhttp/plugins/dynamix/include/SysDriversHelpers.php @@ -140,7 +140,7 @@ function modtoplg() { } function createlist() { - global $modtoplgfile, $sysdrvfile, $lsmod, $kernel,$arrModules, $modplugins ; + global $modtoplgfile, $sysdrvfile, $lsmod, $kernel,$arrModules, $modplugins,$arrModtoPlg ; $arrModtoPlg = json_decode(file_get_contents($modtoplgfile) ,TRUE) ; $builtinmodules = file_get_contents("/lib/modules/$kernel/modules.builtin") ; $builtinmodules = explode(PHP_EOL,$builtinmodules) ; From e7fc92e231afd916a87d760d92413c0307b37189 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 23 Jul 2023 08:28:49 +0100 Subject: [PATCH 211/239] Check if rebuild is running. --- emhttp/plugins/dynamix/include/SysDrivers.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 9976e7863..9a06aa556 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -31,10 +31,12 @@ $arrModtoPlg = json_decode(file_get_contents("/tmp/modulestoplg.json") ,TRUE) ; switch ($_POST['table']) { - case 't1create': + case 't1create': + if (is_file("/tmp/sysdrvbuild.running")) break ; + touch("/tmp/sysdrvbuild.running") ; modtoplg() ; createlist() ; - + unlink("/tmp/sysdrvbuild.running") ; break; case 't1load': From 6a23a3d432d52ffe60bf870bc548c89bd1c5e8f5 Mon Sep 17 00:00:00 2001 From: dlandon Date: Mon, 24 Jul 2023 17:29:24 -0500 Subject: [PATCH 212/239] Add previous Unraid version to diagnostics version txt file. --- emhttp/plugins/dynamix/scripts/diagnostics | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index 342c745b9..e288050e9 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -333,6 +333,29 @@ file_put_contents("/$diag/unraid-".$unraid['version'].".txt",$unraid['version']. // add bz*.sha256 values run("tail /boot/bz*.sha256 >> ".escapeshellarg("/$diag/unraid-".$unraid['version'].".txt")); +// Get the previous version of Unraid from the previous directory on flash +$changes = '/boot/previous/changes.txt'; + +if (file_exists($changes)) { + exec("head -n4 $changes",$rows); + foreach ($rows as $row) { + $i = stripos($row, 'version'); + if ($i !== false) { + [$version,$date] = explode(' ', trim(substr($row,$i+7))); + break; + } + } + $branch = strpos($version,'rc')!==false ? 'Next' : (strpos($version,'beta')!==false ? 'Beta' : 'Stable'); + + $previous_version = "Previous Version: ".$version." ".$branch; + file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\n".$previous_version."\r\n", FILE_APPEND); + + $upgraded = "Upgraded on: ".date("F d Y", filemtime($changes)); + file_put_contents("/$diag/unraid-".$unraid['version'].".txt", $upgraded."\r\n", FILE_APPEND); +} else { + file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\nNo Previous Version Found\r\n", FILE_APPEND); +} + // copy ini variables foreach (glob("$path/*.ini") as $file) { $ini = basename($file,".ini"); From ab277ce2036b03027f4b11fcfce4d4bb2e70fbdd Mon Sep 17 00:00:00 2001 From: dlandon Date: Mon, 24 Jul 2023 18:00:21 -0500 Subject: [PATCH 213/239] Remove branch from previous version. --- emhttp/plugins/dynamix/scripts/diagnostics | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index e288050e9..963d585c0 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -345,9 +345,7 @@ if (file_exists($changes)) { break; } } - $branch = strpos($version,'rc')!==false ? 'Next' : (strpos($version,'beta')!==false ? 'Beta' : 'Stable'); - - $previous_version = "Previous Version: ".$version." ".$branch; + $previous_version = "Previous Version: ".$version; file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\n".$previous_version."\r\n", FILE_APPEND); $upgraded = "Upgraded on: ".date("F d Y", filemtime($changes)); From 12631a107d4eb51b3ca752f4aedfe3f7dc61ac68 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 25 Jul 2023 09:50:44 +0200 Subject: [PATCH 214/239] Dashboard: hide ZFS bar when no ZFS is used --- emhttp/plugins/dynamix/DashStats.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page index 55d9986d2..19af54ec3 100644 --- a/emhttp/plugins/dynamix/DashStats.page +++ b/emhttp/plugins/dynamix/DashStats.page @@ -71,7 +71,7 @@ $parity = _var($var,'mdResync'); $mover = file_exists('/var/run/mover.pid'); $btrfs = exec('pgrep -cf /sbin/btrfs'); $dot = _var($display,'number','.,')[0]; -$zfs = file_exists('/proc/spl/kstat/zfs/arcstats'); +$zfs = count(array_filter(array_column($disks,'fsType'),function($fs){return str_replace('luks:','',$fs??'')=='zfs';})); foreach ($disks as $disk) { switch (_var($disk,'type')) { From 3d284a0da0389560e800f18a5ff862ae29c100e2 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 25 Jul 2023 15:54:46 +0200 Subject: [PATCH 215/239] diagnostics: anonymize IP addresses --- emhttp/plugins/dynamix/scripts/diagnostics | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index 3b29ab10c..98749c826 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -97,6 +97,13 @@ function anonymize($text, $select) { return dirname($text)."/$name.cfg"; } } +function maskIP($file) { + // anonymize public IPv4 addresses + $rfc1918 = "(127|10|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)((\.[0-9]{1,3}){2,3}([/\" .]|$))"; + run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ]([0-9]{1,3}\.){3})[0-9]{1,3}([/\" .]|$)/\\1XXX\\3/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null"); + // anonymize full IPv6 addresses + run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)[0-9a-f]{1,4}([/\" .]|$)/\\1XXXX:XXXX:XXXX:XXXX\\5/g' ".escapeshellarg($file)." 2>/dev/null"); +} function prefix($key) { return preg_replace('/\d+$/','',$key); } @@ -367,7 +374,7 @@ run("ps -auxf --sort=-pcpu 2>/dev/null|todos >".escapeshellarg("/$diag/system/ps run("lsof -Pni 2>/dev/null|todos >".escapeshellarg("/$diag/system/lsof.txt")); run("lsmod|sort 2>/dev/null|todos >".escapeshellarg("/$diag/system/lsmod.txt")); run("df -h 2>/dev/null|todos >".escapeshellarg("/$diag/system/df.txt")); -run("ifconfig -a -s 2>/dev/null|grep -Po '^(eth|bond)[0-9]+'", $ports); +run("ip -br a|awk '/^(eth|bond)[0-9]+ /{print \$1}'|sort",$ports); run("dmidecode -qt2|awk -F: '/^\tManufacturer:/{m=\$2};/^\tProduct Name:/{p=\$2} END{print m\" -\"p}' 2>/dev/null|todos >".escapeshellarg("/$diag/system/motherboard.txt")); run("dmidecode -qt0 2>/dev/null|todos >>".escapeshellarg("/$diag/system/motherboard.txt")); run("cat /proc/meminfo 2>/dev/null|todos >".escapeshellarg("/$diag/system/meminfo.txt")); @@ -380,7 +387,8 @@ foreach ($ports as $port) { run("ethtool -i ".escapeshellarg($port)." 2>/dev/null|todos >>".escapeshellarg("/$diag/system/ethtool.txt")); file_put_contents("/$diag/system/ethtool.txt", "--------------------------------\r\n", FILE_APPEND); } -run("ifconfig -a 2>/dev/null|todos >".escapeshellarg("/$diag/system/ifconfig.txt")); +run("ip -br a|todos >".escapeshellarg("/$diag/system/ifconfig.txt")); +if (!$all) maskIP("/$diag/system/ifconfig.txt"); // create system information (suppress errors) run("find /sys/kernel/iommu_groups/ -type l 2>/dev/null|sort -V|todos >".escapeshellarg("/$diag/system/iommu_groups.txt")); @@ -397,16 +405,19 @@ run("cp /boot/config/*.{cfg,conf,dat} ".escapeshellarg("/$diag/config")." 2>/dev run("cp /boot/config/go ".escapeshellarg("/$diag/config/go.txt")." 2>/dev/null"); // anonymize go file -if (!$all) +if (!$all) { run("sed -i -e '/password/c ***line removed***' -e '/user/c ***line removed***' -e '/pass/c ***line removed***' ".escapeshellarg("/$diag/config/go.txt")); - +} // anonymize configuration files -if (!$all) +if (!$all) { run("sed -ri 's/^((disk|flash)(Read|Write)List.*=\")[^\"]+/\\1.../' ".escapeshellarg("/$diag/config/*.cfg")." 2>/dev/null"); - + // anonymize IP addresses + maskIP("/$diag/config/network.cfg"); +} // include listening interfaces run("$docroot/webGui/scripts/show_interfaces ip|tr -d ' '|tr '#' ' '|tr ',' '\n' >".escapeshellarg("/$diag/config/listen.txt")); run("$docroot/webGui/scripts/error_interfaces|sed 's///' >>".escapeshellarg("/$diag/config/listen.txt")); +if (!$all) maskIP("/$diag/config/listen.txt"); // copy share information (anonymize if applicable) $files = glob("/boot/config/shares/*.cfg"); @@ -581,6 +592,7 @@ foreach (glob("/var/log/syslog*") as $file) { run("grep -Po 'file: \K[^\"\\x27]+' ".escapeshellarg("$log.txt")." 2>/dev/null|sort|uniq", $titles); run("sed -ri 's|\b\S+@\S+\.\S+\b|email@removed.com|;s|\b(username\|password)([=:])\S+\b|\\1\\2xxx|;s|(GUID: \S)\S+(\S) |\\1..\\2 |;s|(moving \"\S\|\"/mnt/user/\S).*(\S)\"|\\1..\\2\"|' ".escapeshellarg("$log.txt")); run("sed -ri 's|(server: ).+(\.(my)?unraid\.net(:[0-9]+)?,)|\\1hash\\2|;s|(host: \").+(\.(my)?unraid\.net(:[0-9]+)?\")|\\1hash\\2|;s|(referrer: \"https?://).+(\.(my)?unraid\.net)|\\1hash\\2|' ".escapeshellarg("$log.txt")); + maskIP("$log.txt"); foreach ($titles as $mover) { if (!$mover) continue; $title = "/{$mover[0]}..".substr($mover,-1)."/..."; @@ -604,6 +616,7 @@ $dhcplog = "/var/log/dhcplog"; if (file_exists($dhcplog)) { $log = "/$diag/logs/dhcplog.txt"; run("todos <$dhcplog >".escapeshellarg($log)); + if (!$all) maskIP($log); } // copy graphql-api.log From 014d0831cd1fca5534798250c4ece51a1f832818 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 25 Jul 2023 19:10:54 +0200 Subject: [PATCH 216/239] diagnostics: anonymize IP addresses --- emhttp/plugins/dynamix/scripts/diagnostics | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index 98749c826..938f0d8a3 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -100,9 +100,9 @@ function anonymize($text, $select) { function maskIP($file) { // anonymize public IPv4 addresses $rfc1918 = "(127|10|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)((\.[0-9]{1,3}){2,3}([/\" .]|$))"; - run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ]([0-9]{1,3}\.){3})[0-9]{1,3}([/\" .]|$)/\\1XXX\\3/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null"); + run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null"); // anonymize full IPv6 addresses - run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)[0-9a-f]{1,4}([/\" .]|$)/\\1XXXX:XXXX:XXXX:XXXX\\5/g' ".escapeshellarg($file)." 2>/dev/null"); + run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([/\" .]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file)." 2>/dev/null"); } function prefix($key) { return preg_replace('/\d+$/','',$key); From 68aba40a7e09feb89c524af2407ce8e72ff5850c Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 25 Jul 2023 19:19:17 +0200 Subject: [PATCH 217/239] diagnostics: anonymize IP addresses --- emhttp/plugins/dynamix/scripts/diagnostics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index 938f0d8a3..af6716309 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -100,7 +100,7 @@ function anonymize($text, $select) { function maskIP($file) { // anonymize public IPv4 addresses $rfc1918 = "(127|10|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)((\.[0-9]{1,3}){2,3}([/\" .]|$))"; - run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null"); + run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@#@#\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@#@#//g' ".escapeshellarg($file)." 2>/dev/null"); // anonymize full IPv6 addresses run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([/\" .]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file)." 2>/dev/null"); } From 9781e9e41f08cd77a5993c73dd8a98b89e625ac2 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 25 Jul 2023 19:32:41 +0200 Subject: [PATCH 218/239] diagnostics: anonymize IP addresses --- emhttp/plugins/dynamix/scripts/diagnostics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index af6716309..88bdf8312 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -100,7 +100,7 @@ function anonymize($text, $select) { function maskIP($file) { // anonymize public IPv4 addresses $rfc1918 = "(127|10|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)((\.[0-9]{1,3}){2,3}([/\" .]|$))"; - run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@#@#\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@#@#//g' ".escapeshellarg($file)." 2>/dev/null"); + run("sed -ri 's/([\"\[ ])${rfc1918}/\\1~\255~\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/~\255~//g' ".escapeshellarg($file)." 2>/dev/null"); // anonymize full IPv6 addresses run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([/\" .]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file)." 2>/dev/null"); } From c6021ae87aa95c4587be6b9ec7c14ae42cd9539a Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 25 Jul 2023 19:38:44 +0200 Subject: [PATCH 219/239] Revert "diagnostics: anonymize IP addresses" This reverts commit 9781e9e41f08cd77a5993c73dd8a98b89e625ac2. --- emhttp/plugins/dynamix/scripts/diagnostics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index 309ffaaa5..7314b67bd 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -100,7 +100,7 @@ function anonymize($text, $select) { function maskIP($file) { // anonymize public IPv4 addresses $rfc1918 = "(127|10|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)((\.[0-9]{1,3}){2,3}([/\" .]|$))"; - run("sed -ri 's/([\"\[ ])${rfc1918}/\\1~\255~\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/~\255~//g' ".escapeshellarg($file)." 2>/dev/null"); + run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@#@#\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@#@#//g' ".escapeshellarg($file)." 2>/dev/null"); // anonymize full IPv6 addresses run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([/\" .]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file)." 2>/dev/null"); } From a54e61e80eeb4f9ebf7472c6a860e1fd76ea29cc Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 25 Jul 2023 19:38:52 +0200 Subject: [PATCH 220/239] Revert "diagnostics: anonymize IP addresses" This reverts commit 68aba40a7e09feb89c524af2407ce8e72ff5850c. --- emhttp/plugins/dynamix/scripts/diagnostics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index 7314b67bd..c1c7b5945 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -100,7 +100,7 @@ function anonymize($text, $select) { function maskIP($file) { // anonymize public IPv4 addresses $rfc1918 = "(127|10|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)((\.[0-9]{1,3}){2,3}([/\" .]|$))"; - run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@#@#\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@#@#//g' ".escapeshellarg($file)." 2>/dev/null"); + run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null"); // anonymize full IPv6 addresses run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([/\" .]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file)." 2>/dev/null"); } From 68cf94f04ffc6c6398d155e10e3541a62de804ba Mon Sep 17 00:00:00 2001 From: dlandon Date: Tue, 25 Jul 2023 15:08:09 -0500 Subject: [PATCH 221/239] Add ntp.conf, sshd.config, and servers.conf; apply maskIP to testparm; fix php warning. --- emhttp/plugins/dynamix/scripts/diagnostics | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index c1c7b5945..0c7047499 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -100,7 +100,7 @@ function anonymize($text, $select) { function maskIP($file) { // anonymize public IPv4 addresses $rfc1918 = "(127|10|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)((\.[0-9]{1,3}){2,3}([/\" .]|$))"; - run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null"); + run("sed -ri 's/([\"\[ ]){$rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null"); // anonymize full IPv6 addresses run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([/\" .]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file)." 2>/dev/null"); } @@ -672,6 +672,19 @@ $testparm = run("testparm -s 2>/dev/null"); if (!$all) $testparm = preg_replace("/(?<=\[.)(.*)(?=.\])|(?<=(write list = .)|(comment = .)|(valid users = .)|(path = \/mnt\/addons\/.)|(path = \/mnt\/remotes\/.)|(path = \/mnt\/disks\/.)|(path = \/mnt\/user\/.)).*(?=.)/","...",$testparm); file_put_contents("/$diag/system/testparm.txt",str_replace("\n","\r\n",$testparm)); +maskIP("/$diag/system/testparm.txt"); + +// copy ntp.conf +copy("/etc/ntp.conf", "/$diag/system/ntp.txt"); +maskIP("/$diag/system/ntp.txt"); + +// copy sshd_config +copy("/etc/ssh/sshd_config", "/$diag/system/sshd.txt"); +maskIP("/$diag/system/sshd.txt"); + +// copy servers.conf +copy("/etc/nginx/conf.d/servers.conf", "/$diag/system/servers.conf.txt"); +maskIP("/$diag/system/servers.conf.txt"); // BEGIN - third party plugins diagnostics // list third party packages in /boot/config/plugins/*/packages/ From 9ec5e7974c69746749b70f3608468396413b0a44 Mon Sep 17 00:00:00 2001 From: dlandon Date: Tue, 25 Jul 2023 21:05:34 -0500 Subject: [PATCH 222/239] Insure all files have newline changed to cr, lf; don't do maskIP if 'all' option is specified; fix linefeed routine not working; change update date to mtime.. --- emhttp/plugins/dynamix/scripts/diagnostics | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index 0c7047499..988f0bcae 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -58,9 +58,14 @@ function run($cmd, &$save=null) { exec("timeout -s9 30 $cmd", $save); return implode("\n",$save); } + function newline($file) { - exec("echo|todos >>".escapeshellarg($file)); + $tmp_file = "/tmp/".basename($file); + copy($file, $tmp_file); + exec("/usr/bin/todos < ".escapeshellarg($tmp_file)." > ".escapeshellarg($file)); + unlink($tmp_file); } + function shareDisks($share) { return str_replace(',',', ',exec("shopt -s dotglob; getfattr --no-dereference --absolute-names --only-values -n system.LOCATIONS ".escapeshellarg("/mnt/user/$share")." 2>/dev/null") ?: ""); } @@ -97,13 +102,19 @@ function anonymize($text, $select) { return dirname($text)."/$name.cfg"; } } + function maskIP($file) { + global $all; + + if ($all) return; + // anonymize public IPv4 addresses $rfc1918 = "(127|10|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)((\.[0-9]{1,3}){2,3}([/\" .]|$))"; run("sed -ri 's/([\"\[ ]){$rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null"); // anonymize full IPv6 addresses run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([/\" .]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file)." 2>/dev/null"); } + function prefix($key) { return preg_replace('/\d+$/','',$key); } @@ -355,7 +366,8 @@ if (file_exists($changes)) { $previous_version = "Previous Version: ".$version; file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\n".$previous_version."\r\n", FILE_APPEND); - $upgraded = "Upgraded on: ".date("F d Y", filemtime($changes)); + $file_stat = stat("/$diag/unraid-".$unraid['version'].".txt"); + $upgraded = "Upgraded on: ".date("F d Y", $file_stat[9]); file_put_contents("/$diag/unraid-".$unraid['version'].".txt", $upgraded."\r\n", FILE_APPEND); } else { file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\nNo Previous Version Found\r\n", FILE_APPEND); @@ -677,14 +689,17 @@ maskIP("/$diag/system/testparm.txt"); // copy ntp.conf copy("/etc/ntp.conf", "/$diag/system/ntp.txt"); maskIP("/$diag/system/ntp.txt"); +newline("/$diag/system/ntp.txt"); // copy sshd_config copy("/etc/ssh/sshd_config", "/$diag/system/sshd.txt"); maskIP("/$diag/system/sshd.txt"); +newline("/$diag/system/sshd.txt"); // copy servers.conf copy("/etc/nginx/conf.d/servers.conf", "/$diag/system/servers.conf.txt"); maskIP("/$diag/system/servers.conf.txt"); +newline("/$diag/system/servers.conf.txt"); // BEGIN - third party plugins diagnostics // list third party packages in /boot/config/plugins/*/packages/ From b233607809da23ae88e24754b07cbc10170cac81 Mon Sep 17 00:00:00 2001 From: dlandon Date: Wed, 26 Jul 2023 05:41:00 -0500 Subject: [PATCH 223/239] Remove upgrade date. --- emhttp/plugins/dynamix/scripts/diagnostics | 4 ---- 1 file changed, 4 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index 988f0bcae..21ba9d709 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -365,10 +365,6 @@ if (file_exists($changes)) { } $previous_version = "Previous Version: ".$version; file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\n".$previous_version."\r\n", FILE_APPEND); - - $file_stat = stat("/$diag/unraid-".$unraid['version'].".txt"); - $upgraded = "Upgraded on: ".date("F d Y", $file_stat[9]); - file_put_contents("/$diag/unraid-".$unraid['version'].".txt", $upgraded."\r\n", FILE_APPEND); } else { file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\nNo Previous Version Found\r\n", FILE_APPEND); } From ab56583c71b72dc5ca3b5aeb78a1bc2726bc6dc0 Mon Sep 17 00:00:00 2001 From: dlandon Date: Wed, 26 Jul 2023 10:23:32 -0500 Subject: [PATCH 224/239] Add detection of network supporting promiscuous mode and disable macvlan if so, --- emhttp/plugins/dynamix.docker.manager/DockerSettings.page | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/emhttp/plugins/dynamix.docker.manager/DockerSettings.page b/emhttp/plugins/dynamix.docker.manager/DockerSettings.page index 1579ab18d..b12989ec0 100644 --- a/emhttp/plugins/dynamix.docker.manager/DockerSettings.page +++ b/emhttp/plugins/dynamix.docker.manager/DockerSettings.page @@ -83,6 +83,10 @@ $gw4class = $wide ? 'gw6' : 'gw4'; $unset = array_unique($unset); +/* See if the requirements are met for macvlan to work properly. */ +$flag = exec("/bin/netstat -i | /usr/bin/grep ".escapeshellarg($network)." | /usr/bin/grep -v vir* | /bin/awk '{print $11}'"); +$proniscuous = (strpos($flag, "P") !== false) ? true : false; + function normalize($network) { return strtoupper(str_replace('.','_',$network)); } @@ -257,8 +261,12 @@ _(Template Authoring Mode)_: _(Docker custom network type)_: :  _(Please read the Help carefully)_. _(Misconfiguration can cause problems)_. + +  _(Network does not support Promiscuous Mode)_. _(Macvlan will not work)_. + :docker_custom_network_type_help: From e2b6e2cf4c77620ef257dd79f570b963182eb5db Mon Sep 17 00:00:00 2001 From: dlandon Date: Wed, 26 Jul 2023 11:13:37 -0500 Subject: [PATCH 225/239] Revert "Add detection of network supporting promiscuous mode and disable macvlan if so," This reverts commit ab56583c71b72dc5ca3b5aeb78a1bc2726bc6dc0. --- emhttp/plugins/dynamix.docker.manager/DockerSettings.page | 8 -------- 1 file changed, 8 deletions(-) diff --git a/emhttp/plugins/dynamix.docker.manager/DockerSettings.page b/emhttp/plugins/dynamix.docker.manager/DockerSettings.page index b12989ec0..1579ab18d 100644 --- a/emhttp/plugins/dynamix.docker.manager/DockerSettings.page +++ b/emhttp/plugins/dynamix.docker.manager/DockerSettings.page @@ -83,10 +83,6 @@ $gw4class = $wide ? 'gw6' : 'gw4'; $unset = array_unique($unset); -/* See if the requirements are met for macvlan to work properly. */ -$flag = exec("/bin/netstat -i | /usr/bin/grep ".escapeshellarg($network)." | /usr/bin/grep -v vir* | /bin/awk '{print $11}'"); -$proniscuous = (strpos($flag, "P") !== false) ? true : false; - function normalize($network) { return strtoupper(str_replace('.','_',$network)); } @@ -261,12 +257,8 @@ _(Template Authoring Mode)_: _(Docker custom network type)_: :  _(Please read the Help carefully)_. _(Misconfiguration can cause problems)_. - -  _(Network does not support Promiscuous Mode)_. _(Macvlan will not work)_. - :docker_custom_network_type_help: From caab0f89595692b7f716e5808eeaf836fbb78839 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Thu, 27 Jul 2023 21:15:31 +0100 Subject: [PATCH 226/239] Reduce number of tar packages tested. --- .../dynamix/include/SysDriversHelpers.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/emhttp/plugins/dynamix/include/SysDriversHelpers.php b/emhttp/plugins/dynamix/include/SysDriversHelpers.php index 6727258b5..af8064552 100644 --- a/emhttp/plugins/dynamix/include/SysDriversHelpers.php +++ b/emhttp/plugins/dynamix/include/SysDriversHelpers.php @@ -109,20 +109,14 @@ $arrModules[$modname] = [ } function modtoplg() { - global $modtoplgfile ; - $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/boot/config/plugins')); - $files = array(); + global $modtoplgfile,$kernel ; - /** @var SplFileInfo $file */ - foreach ($rii as $file) { - if ($file->isDir()){ - continue; - } - if ($file->getExtension() != "tgz" && $file->getExtension() != "txz") continue ; - $files[] = $file->getPathname(); - } + $files = array(); + $kernelsplit = explode('-',$kernel) ; + $kernelvers = trim($kernelsplit[0],"\n") ; $list = array() ; + $files = glob('/boot/config/plugins/*/packages/' . $kernelvers . '/*.{txz,tgz}', GLOB_BRACE); foreach ($files as $f) { $plugin = str_replace("/boot/config/plugins/", "", $f) ; $plugin = substr($plugin,0,strpos($plugin,'/') ) ; From d111e7281436cf1068294b8de40dbb7d80bd0131 Mon Sep 17 00:00:00 2001 From: ljm42 Date: Thu, 27 Jul 2023 14:38:37 -0700 Subject: [PATCH 227/239] add System Drivers helptext --- emhttp/languages/en_US/helptext.txt | 8 ++++++++ emhttp/plugins/dynamix/SysDrivers.page | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/emhttp/languages/en_US/helptext.txt b/emhttp/languages/en_US/helptext.txt index 406af2492..64c863e1f 100644 --- a/emhttp/languages/en_US/helptext.txt +++ b/emhttp/languages/en_US/helptext.txt @@ -2416,3 +2416,11 @@ A keepalive timer will hold the connection open, for most situations a timer val Note that for mobile devices this will use more data and drain your battery faster. :end + +:sysdrivers_intro_help: +This page displays all the drivers available on this system. Filter the list according to whether the driver is Inuse or not, or search for a specific driver if desired. + +Any 3rd party driver installed by a plugin will have a support symbol next to it, click this to get support for the plugin. + +Click the edit button to add/modify/delete any modprobe.d config file in the config/modprobe.d directory on the flash drive. +:end diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index f4b2ef9c0..bf3a1c870 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -164,9 +164,10 @@ $('.tabs').append("_(Select View)_ showDrivers("all",true) ; - +:sysdrivers_intro_help: +

From 922200e8be25aaffba931417fa01530e83fc5e07 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 28 Jul 2023 05:22:57 +0200 Subject: [PATCH 228/239] Network: do not use promiscuous mode for bridging --- etc/rc.d/rc.inet1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.inet1 b/etc/rc.d/rc.inet1 index 6cd2e3bbf..96dcb71e9 100755 --- a/etc/rc.d/rc.inet1 +++ b/etc/rc.d/rc.inet1 @@ -47,6 +47,10 @@ # - fixed ipv4 and ipv6 DNS assignment # - suppress errors +# Adapted by Bergware for use in unRAID - July 2023 +# - reverted iptables and ip6tables and arp-tables inclusion to bridge interfaces +# - removed promiscuous mode setting for bridge interfaces + ############################ # READ NETWORK CONFIG FILE # ############################ @@ -184,7 +188,7 @@ br_up(){ # convert legacy no/yes 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]} nf_call_iptables 1 nf_call_ip6tables 1 nf_call_arptables 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 @@ -196,7 +200,7 @@ br_up(){ run ip link set $BRIF down [[ $IP != ipv6 ]] && run ip -4 addr flush dev $BRIF [[ $IP != ipv4 ]] && run ip -6 addr flush dev $BRIF - run ip link set $BRIF promisc on master $BRIDGE up + run ip link set $BRIF master $BRIDGE up else [[ $DEBUG_ETH_UP == yes ]] && log "interface $BRIF not present, can't add to $BRIDGE" fi @@ -212,7 +216,7 @@ br_down(){ if [[ -e $SYSTEM/$BRIDGE ]]; then # loop thru attached interfaces in bridge for BRIF in $(ls --indicator-style=none $SYSTEM/$BRIDGE/brif); do - run ip link set $BRIF promisc off nomaster + run ip link set $BRIF nomaster done run ip link set $BRIDGE down run ip link del $BRIDGE From 02a6951c144c86ae672984e9435d4a235f94a48c Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 28 Jul 2023 13:30:18 +0200 Subject: [PATCH 229/239] Network settings: fix DNS settings sometimes disappear --- emhttp/plugins/dynamix/Eth0.page | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/emhttp/plugins/dynamix/Eth0.page b/emhttp/plugins/dynamix/Eth0.page index e1add9194..f7e197681 100644 --- a/emhttp/plugins/dynamix/Eth0.page +++ b/emhttp/plugins/dynamix/Eth0.page @@ -225,7 +225,7 @@ function selectProtocol(form,port,index) { } if ($(form).find('select[name="USE_DHCP:'+i+'"]').val()) more4.show(); else more4.hide(); if ($(form).find('select[name="USE_DHCP6:'+i+'"]').val()) more6.show(); else more6.hide(); - checkNetworkSettings(form,i,true); + checkNetworkSettings(form,i); }); } else { var protocol = $(form).find('select[name="PROTOCOL:'+index+'"]').val() || 'ipv4'; @@ -241,16 +241,12 @@ function selectProtocol(form,port,index) { if ($(form).find('select[name="USE_DHCP:'+index+'"]').val()) more4.show(); else more4.hide(); if ($(form).find('select[name="USE_DHCP6:'+index+'"]').val()) more6.show(); else more6.hide(); checkNetworkSettings(form,index); - if (index==0) { - checkDNSSettings(form); - checkDNSSettings6(form); - } } } -function checkNetworkSettings(form,index,start) { +function checkNetworkSettings(form,index) { var disabled4 = $(form).find('select[name="USE_DHCP:'+index+'"]').val()!='no'; var disabled6 = $(form).find('select[name="USE_DHCP6:'+index+'"]').val()!='no'; - var protocol = $(form).find('select[name="PROTOCOL:'+index+'"]').val() || 'ipv4'; + var protocol = $(form).find('select[name="PROTOCOL:'+index+'"]').val() || 'ipv4'; if (protocol != 'ipv6') { $(form).find('input[name="IPADDR:'+index+'"]').prop('disabled',disabled4).prop('required',!disabled4); $(form).find('select[name="NETMASK:'+index+'"]').prop('disabled',disabled4); @@ -264,19 +260,17 @@ function checkNetworkSettings(form,index,start) { privacy.prop('disabled',!disabled6); } if (index==0) { - if (form.DHCP_KEEPRESOLV !== undefined) { - if (!start) form.DHCP_KEEPRESOLV.value = disabled4 ? 'no' : 'yes'; - form.DHCP_KEEPRESOLV.disabled = !disabled4; - checkDNSSettings(form); - } - if (form.DHCP6_KEEPRESOLV !== undefined) { - if (!start) form.DHCP6_KEEPRESOLV.value = disabled6 ? 'no' : 'yes'; - form.DHCP6_KEEPRESOLV.disabled = !disabled6; - checkDNSSettings6(form); - } + if (form.DHCP_KEEPRESOLV !== undefined) checkDNSSettings(form); + if (form.DHCP6_KEEPRESOLV !== undefined) checkDNSSettings6(form); } } function checkDNSSettings(form) { + if ($(form).find('select[name="USE_DHCP:0"]').val()=='no') { + form.DHCP_KEEPRESOLV.value = 'yes'; + form.DHCP_KEEPRESOLV.disabled = true; + } else { + form.DHCP_KEEPRESOLV.disabled = false; + } var disabled = form.DHCP_KEEPRESOLV.value=='no'; var protocol = $(form).find('select[name="PROTOCOL:0"]').val() || 'ipv4'; if (protocol != 'ipv6') { @@ -289,6 +283,12 @@ function checkDNSSettings(form) { } } function checkDNSSettings6(form) { + if ($(form).find('select[name="USE_DHCP6:0"]').val()=='no') { + form.DHCP6_KEEPRESOLV.value = 'yes'; + form.DHCP6_KEEPRESOLV.disabled = true; + } else { + form.DHCP6_KEEPRESOLV.disabled = false; + } var disabled = form.DHCP6_KEEPRESOLV.value=='no'; var protocol = $(form).find('select[name="PROTOCOL:0"]').val() || 'ipv4'; if (protocol != 'ipv4') { From fac2d4e7cfa17da059729c50f9d45436dca7ab07 Mon Sep 17 00:00:00 2001 From: ljm42 Date: Fri, 28 Jul 2023 09:55:14 -0700 Subject: [PATCH 230/239] Add VS Code SFTP config to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index eb7e31812..f7e248e57 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,9 @@ Temporary Items # Sublime text SFTP configuration file sftp-config.json +# VS Code SFTP configuration file +.vscode/sftp.json + # ========================= # Exclude these dirs commonly found in /usr/local bin/ From ebbe7d43b9b3d4c4b3ff41e1bb14eab18d10fa59 Mon Sep 17 00:00:00 2001 From: ljm42 Date: Fri, 28 Jul 2023 11:14:29 -0700 Subject: [PATCH 231/239] diagnostics: anonymize urls in servers.conf --- emhttp/plugins/dynamix/scripts/diagnostics | 1 + 1 file changed, 1 insertion(+) diff --git a/emhttp/plugins/dynamix/scripts/diagnostics b/emhttp/plugins/dynamix/scripts/diagnostics index 21ba9d709..af637ea33 100755 --- a/emhttp/plugins/dynamix/scripts/diagnostics +++ b/emhttp/plugins/dynamix/scripts/diagnostics @@ -695,6 +695,7 @@ newline("/$diag/system/sshd.txt"); // copy servers.conf copy("/etc/nginx/conf.d/servers.conf", "/$diag/system/servers.conf.txt"); maskIP("/$diag/system/servers.conf.txt"); +run("sed -Ei 's/[01234567890abcdef]+\.((my)?unraid\.net)/hash.\\1/gm;t' ".escapeshellarg("/$diag/system/servers.conf.txt")." 2>/dev/null"); newline("/$diag/system/servers.conf.txt"); // BEGIN - third party plugins diagnostics From caf018e0f48640da8132365d531a8481f3c5f973 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Fri, 28 Jul 2023 20:06:50 +0100 Subject: [PATCH 232/239] Fix reboot banner. --- emhttp/plugins/dynamix/SysDrivers.page | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index f4b2ef9c0..703a6dc9c 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -149,9 +149,7 @@ function textsave(module) { if (data.supportpage == true) { if (data.support == true) { document.getElementById("link" + module).innerHTML = "" ; - } else { - document.getElementById("link" + module).innerHTML = "" ; - } + } } } //showDriversupdate() ; From d2ee1c1daf28d6ce1e0223e573b23473fbc1b84a Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Fri, 28 Jul 2023 20:30:53 +0100 Subject: [PATCH 233/239] Fix scroll to top of page on edit. --- emhttp/plugins/dynamix/SysDrivers.page | 4 ++-- emhttp/plugins/dynamix/include/SysDrivers.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 703a6dc9c..11a6435e7 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -130,8 +130,8 @@ function showDriversupdate() { function textedit(module) { var i=module ; $('#text'+module).prop('disabled', false); - $('#save'+module).attr('hidden', false); - $('#text'+module).attr('hidden', false); + $('#save'+module).attr('hidden', false); + $('#text'+module).attr('hidden', false); } diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 9a06aa556..98a28d69b 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -75,8 +75,8 @@ switch ($_POST['table']) { $text = "" ; if (is_array($module["modprobe"])) { $text = implode("\n",$module["modprobe"]) ; - $html .= ""; - } else $html .= ""; + $html .= ""; + } else $html .= ""; } $html .= "" ; From 64ea160d32b8f91ca028c3f017157dc77b77a9c1 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Fri, 28 Jul 2023 21:33:54 +0100 Subject: [PATCH 234/239] Add system modprobe.d files --- emhttp/plugins/dynamix/include/SysDrivers.php | 13 +++++++++++-- .../plugins/dynamix/include/SysDriversHelpers.php | 11 ++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 98a28d69b..d24de90b7 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -57,8 +57,17 @@ switch ($_POST['table']) { if($state !== false) {$state = "Disabled" ;} else $state="Custom" ; $module['state'] = $state ; $module['modprobe'] = $modprobe ; - } - + } else { + if (is_file("/etc/modprobe.d/$modname.conf")) { + $modprobe = file_get_contents("/etc/modprobe.d/$modname.conf") ; + $state = strpos($modprobe, "blacklist"); + $modprobe = explode(PHP_EOL,$modprobe) ; + if($state !== false) {$state = "Disabled" ;} else $state="System" ; + $module['state'] = $state ; + $module['modprobe'] = $modprobe ; + } + } + $html .= "" ; if ($supportpage) { if ($module['support'] == false) { diff --git a/emhttp/plugins/dynamix/include/SysDriversHelpers.php b/emhttp/plugins/dynamix/include/SysDriversHelpers.php index af8064552..51726dad8 100644 --- a/emhttp/plugins/dynamix/include/SysDriversHelpers.php +++ b/emhttp/plugins/dynamix/include/SysDriversHelpers.php @@ -77,7 +77,16 @@ if (is_file("/boot/config/modprobe.d/$modname.conf")) { $modprobe = explode(PHP_EOL,$modprobe) ; if($state !== false) {$state = "Disabled" ;} else $state="Custom" ; - } + } else { + if (is_file("/etc/modprobe.d/$modname.conf")) { + $modprobe = file_get_contents("/etc/modprobe.d/$modname.conf") ; + $state = strpos($modprobe, "blacklist"); + $modprobe = explode(PHP_EOL,$modprobe) ; + if($state !== false) {$state = "Disabled" ;} else $state="System" ; + $module['state'] = $state ; + $module['modprobe'] = $modprobe ; + } + } if ($filename != "(builtin)") { if ($filename != null) { From c30405434a62f53d642a59e0815fa126508f19d6 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Fri, 28 Jul 2023 21:41:57 +0100 Subject: [PATCH 235/239] Add System to filters --- emhttp/plugins/dynamix/SysDrivers.page | 2 +- emhttp/plugins/dynamix/include/SysDrivers.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 11a6435e7..59d321012 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -109,7 +109,7 @@ function showDrivers(options, init = false) { function filterDrivers() { var totalColumns = $('#t1')[0].config.columns; var filter = []; - filter[2] = ($('#select').val() === "inuse") ? "Inuse|Custom|Disabled|'Kernel - Inuse'" : ""; + filter[2] = ($('#select').val() === "inuse") ? "System|Inuse|Custom|Disabled|'Kernel - Inuse'" : ""; filter[totalColumns] = $('#driversearch').val(); // this searches all columns $('#t1').trigger('search', [ filter ]); } diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index d24de90b7..d6d61124a 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -43,7 +43,7 @@ switch ($_POST['table']) { $list = file_get_contents($sysdrvfile) ; $arrModules = json_decode($list,TRUE) ; $init = file_get_contents($sysdrvinit) ; - $html = ""._("Driver").""._("Description").""._("State").""._("Type").""._("Modprobe.d config file").""; + $html = ""._("Driver").""._("Description").""._("State").""._("Type").""._("Modprobe.d config file").""; $html .= "" ; if (is_array($arrModules)) ksort($arrModules) ; @@ -67,7 +67,7 @@ switch ($_POST['table']) { $module['modprobe'] = $modprobe ; } } - + $html .= "" ; if ($supportpage) { if ($module['support'] == false) { From f36e307de08874ebaa3b8ca79f3e8a03e87ed81f Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 29 Jul 2023 09:39:36 +0100 Subject: [PATCH 236/239] Sysdrivers: Updates Add remove button and confirmation Fix sort issues by updating cells Code tidy --- emhttp/plugins/dynamix/SysDrivers.page | 25 ++++++++++++------- emhttp/plugins/dynamix/include/SysDrivers.php | 13 +++++++--- .../dynamix/include/SysDriversHelpers.php | 1 - 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 59d321012..3352024a2 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -135,37 +135,44 @@ function textedit(module) { } -function textsave(module) { +function removecfg(module) +{ + swal({title:"_(Proceed)_?",text:"_(Remove custom modprobe.d configuration?)_: "+module,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(p){if (p) textsave(module, true); else return false;}); +} + +function textsave(module,remove = false) { var i=module ; $('#text'+module).prop('disabled', true); $('#save'+module).attr('hidden', true); - var x = document.getElementById("text" + module).value; + if (remove) x = "" ; else var x = document.getElementById("text" + module).value; $.post('/webGui/include/SysDrivers.php',{table:'update',module:module,conf:x},function(data){ if(data) { formHasUnsavedChanges=false; $('#text'+module).val(data.modprobe) ; $('#status'+module).html(data.state) ; - if (data.modprobe == "") $('#text'+module).attr('hidden', true); else $('#text'+module).attr('rows', 3) + if (data.state == "Custom") { + $('#bin'+module).show(); + } else { + $('#bin'+module).hide(); + } + if (data.modprobe == "") $('#text'+module).attr('hidden', true); else $('#text'+module).attr('rows', 3); if (data.supportpage == true) { if (data.support == true) { document.getElementById("link" + module).innerHTML = "" ; } } } - //showDriversupdate() ; + $('#t1').trigger("updateCell",[document.getElementById('text'+module), false, null]); + $('#t1').trigger("updateCell",[document.getElementById('status'+module), false, null]); var message = "_(System Drivers)_: _(A reboot is required to apply changes)_"; addRebootNotice(message); },"json"); } $('.tabs').append("_(Select View)_:"); - showDrivers("all",true) ; - -

- - + \ No newline at end of file diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index d6d61124a..2d9e91281 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -84,12 +84,19 @@ switch ($_POST['table']) { $text = "" ; if (is_array($module["modprobe"])) { $text = implode("\n",$module["modprobe"]) ; - $html .= ""; - } else $html .= ""; + $html .= "" ; + $hidden = "" ; + if ($module['state'] == "System") $hidden = "hidden" ; + $html .= " " ; + $html .= ""; + } else { + $html .= "" ; + $html .= " " ; + $html .= ""; + } } $html .= "" ; - #if ($init) {unlink($sysdrvinit) ; $init = true ;} $rtn = array() ; $rtn['html'] = $html ; if ($init !== false) {$init = true ; unlink($sysdrvinit) ;} diff --git a/emhttp/plugins/dynamix/include/SysDriversHelpers.php b/emhttp/plugins/dynamix/include/SysDriversHelpers.php index 51726dad8..b85f01cf4 100644 --- a/emhttp/plugins/dynamix/include/SysDriversHelpers.php +++ b/emhttp/plugins/dynamix/include/SysDriversHelpers.php @@ -24,7 +24,6 @@ function getmodules($line) { $modprobe = "" ; $desc = $file = $pluginfile = $option = $filename = $depends = $support = $supporturl = $dir = $state = null ; $name = $line ; - #echo $line ; $modname = shell_exec("modinfo $name > /dev/null") ; if ($modname != null) $modname = trim($modname,"\n") ; $output=null ; From b207e08dbb507bace47f988293a407d698e9d66b Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 29 Jul 2023 09:42:20 +0100 Subject: [PATCH 237/239] Update SysDrivers.page --- emhttp/plugins/dynamix/SysDrivers.page | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/SysDrivers.page b/emhttp/plugins/dynamix/SysDrivers.page index 3352024a2..7b8a6f08d 100644 --- a/emhttp/plugins/dynamix/SysDrivers.page +++ b/emhttp/plugins/dynamix/SysDrivers.page @@ -171,8 +171,11 @@ function textsave(module,remove = false) { $('.tabs').append("_(Select View)_:"); showDrivers("all",true) ; + +

- \ No newline at end of file + + From aac56da2bef41f892b41f85b32507822383d6b76 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 29 Jul 2023 09:55:49 +0100 Subject: [PATCH 238/239] Fix typo --- emhttp/plugins/dynamix/include/SysDrivers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 2d9e91281..ee30b9200 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -91,7 +91,7 @@ switch ($_POST['table']) { $html .= ""; } else { $html .= "" ; - $html .= " " ; + $html .= " " ; $html .= ""; } From 2353f19e22b7342e9804ab0ac9e0c60b68cb2c1b Mon Sep 17 00:00:00 2001 From: Tom Mortensen Date: Sun, 30 Jul 2023 09:23:17 -0700 Subject: [PATCH 239/239] rc.local: add comment to auto-generated /etc/modprobe.d/zfs.conf file --- etc/rc.d/rc.modules.local | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/rc.d/rc.modules.local b/etc/rc.d/rc.modules.local index 6008fb60c..d91fcfca6 100755 --- a/etc/rc.d/rc.modules.local +++ b/etc/rc.d/rc.modules.local @@ -18,7 +18,8 @@ # limetech - set default zfs arc size to 1/8 total memory # (MemTotal is reported in units of 1024, SIZE needs to be bytes) SIZE=$(awk '/MemTotal/{print $(NF-1)*128}' /proc/meminfo) -echo "options zfs zfs_arc_max=$SIZE" > /etc/modprobe.d/zfs.conf +echo "# limetech - Default ARC size is MemTotal/8 (in bytes)" > /etc/modprobe.d/zfs.conf +echo "options zfs zfs_arc_max=$SIZE" >> /etc/modprobe.d/zfs.conf # limetech - grab any user defined module conf files if [ -d /boot/config/modprobe.d ]; then