diff --git a/emhttp/plugins/dynamix.apcupsd/event/driver_loaded b/emhttp/plugins/dynamix.apcupsd/event/driver_loaded index ab6c7ba10..622033049 100755 --- a/emhttp/plugins/dynamix.apcupsd/event/driver_loaded +++ b/emhttp/plugins/dynamix.apcupsd/event/driver_loaded @@ -6,7 +6,10 @@ cfg=/boot/config/plugins/dynamix.apcupsd/dynamix.apcupsd.cfg [[ -f /var/run/apcupsd.pid || ! -f $cfg ]] && exit # Read settings -source $cfg +. $cfg + +# run & log functions +. /etc/rc.d/rc.runlog # Apply settings sed -i -e '/^NISIP/c\\NISIP 0.0.0.0' $conf @@ -27,4 +30,4 @@ else fi # Start daemon -[[ $SERVICE == enable ]] && /etc/rc.d/rc.apcupsd start |& logger +[[ $SERVICE == enable ]] && /etc/rc.d/rc.apcupsd start |& log diff --git a/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php b/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php index f9a4340c2..8279f31c4 100644 --- a/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php +++ b/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php @@ -368,7 +368,7 @@ class DockerTemplates { @copy($iconRAM,$icon); } if ( !is_file($iconRAM) ) { - exec("/usr/bin/logger -- ".escapeshellarg("$imageName: Could not download icon $imgUrl")); + exec("logger -t webGUI -- \"$imageName: Could not download icon $imgUrl\""); } return (is_file($iconRAM)) ? str_replace($docroot, '', $iconRAM) : ''; diff --git a/emhttp/plugins/dynamix.vm.manager/scripts/libvirt_init b/emhttp/plugins/dynamix.vm.manager/scripts/libvirt_init index b22ec4229..4b98d16f0 100755 --- a/emhttp/plugins/dynamix.vm.manager/scripts/libvirt_init +++ b/emhttp/plugins/dynamix.vm.manager/scripts/libvirt_init @@ -2,9 +2,12 @@ # Intialize libvirt config storage # Invoked by emhttp after mounting libvirt loopback but before starting libvirt. +# run & log functions +. /etc/rc.d/rc.runlog + # missing qemu directory would indicate new libvirt image file created if [ ! -d /etc/libvirt/qemu ]; then - logger -- "initializing /etc/libvirt" + log "initializing /etc/libvirt" # initialize with default settings cp -rp /etc/libvirt-/* /etc/libvirt # check if libvirt image file exists on USB flash diff --git a/emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild b/emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild index 67223a3db..e83cb2413 100755 --- a/emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild +++ b/emhttp/plugins/dynamix/event/driver_loaded/SysDriversBuild @@ -1,3 +1,7 @@ #!/bin/bash -/usr/bin/logger -- "Submitting SysDrivers Build" -/usr/local/emhttp/plugins/dynamix/include/SysDriversInit.php &> /dev/null & \ No newline at end of file + +# run & log functions +. /etc/rc.d/rc.runlog + +log "Submitting SysDrivers Build" +/usr/local/emhttp/plugins/dynamix/include/SysDriversInit.php &>/dev/null & diff --git a/emhttp/plugins/dynamix/include/.login.php b/emhttp/plugins/dynamix/include/.login.php index 3f3f4c4b8..88e1f2be3 100644 --- a/emhttp/plugins/dynamix/include/.login.php +++ b/emhttp/plugins/dynamix/include/.login.php @@ -119,12 +119,12 @@ function verifyTwoFactorToken(string $username, string $token): bool { // This should accept 200 or 204 status codes if ($httpCode !== 200 && $httpCode !== 204) { // Log error to syslog - exec("logger -t webGUI -- ".escapeshellarg("2FA code for {$username} is invalid, blocking access!")); + exec("logger -t webGUI -- \"2FA code for {$username} is invalid, blocking access!\""); return false; } // Log success to syslog - exec("logger -t webGUI -- ".escapeshellarg("2FA code for {$username} is valid, allowing login!")); + exec("logger -t webGUI -- \"2FA code for {$username} is valid, allowing login!\""); // Success return true; @@ -199,7 +199,7 @@ if (!empty($username) && !empty($password)) { // Check if we're limited if ($failCount >= $maxFails) { - if ($failCount == $maxFails) exec("logger -t webGUI -- ".escapeshellarg("Ignoring login attempts for {$username} from {$remote_addr}")); + if ($failCount == $maxFails) exec("logger -t webGUI -- \"Ignoring login attempts for {$username} from {$remote_addr}\""); throw new Exception(_('Too many invalid login attempts')); } @@ -216,7 +216,7 @@ if (!empty($username) && !empty($password)) { $_SESSION['unraid_user'] = $username; session_regenerate_id(true); session_write_close(); - exec("logger -t webGUI -- ".escapeshellarg("Successful login user {$username} from {$remote_addr}")); + exec("logger -t webGUI -- \"Successful login user {$username} from {$remote_addr}\""); // Redirect the user to the start page header("Location: /".$var['START_PAGE']); @@ -226,7 +226,7 @@ if (!empty($username) && !empty($password)) { $error = $exception->getMessage(); // Log error to syslog - exec("logger -t webGUI -- ".escapeshellarg("Unsuccessful login user {$username} from {$remote_addr}")); + exec("logger -t webGUI -- \"Unsuccessful login user {$username} from {$remote_addr}\""); appendToFile($failFile, $time."\n"); } } diff --git a/emhttp/plugins/dynamix/include/.set-password.php b/emhttp/plugins/dynamix/include/.set-password.php index ca07885e1..80c51ae27 100644 --- a/emhttp/plugins/dynamix/include/.set-password.php +++ b/emhttp/plugins/dynamix/include/.set-password.php @@ -35,7 +35,7 @@ if (!empty($_POST['password']) && !empty($_POST['confirmPassword'])) { } // Error when attempting to set password - exec("logger -t webGUI -- ".escapeshellarg($VALIDATION_MESSAGES['saveError']." [REMOTE_ADDR]: {$REMOTE_ADDR}")); + exec("logger -t webGUI -- \"{$VALIDATION_MESSAGES['saveError']} [REMOTE_ADDR]: {$REMOTE_ADDR}\""); return $POST_ERROR = $VALIDATION_MESSAGES['saveError']; } diff --git a/emhttp/plugins/dynamix/include/SysDriversInit.php b/emhttp/plugins/dynamix/include/SysDriversInit.php index 64ed210af..f9a5c3971 100755 --- a/emhttp/plugins/dynamix/include/SysDriversInit.php +++ b/emhttp/plugins/dynamix/include/SysDriversInit.php @@ -1,13 +1,11 @@ #!/usr/bin/php \ No newline at end of file diff --git a/emhttp/plugins/dynamix/include/local_prepend.php b/emhttp/plugins/dynamix/include/local_prepend.php index b443b5018..0f5458f7a 100644 --- a/emhttp/plugins/dynamix/include/local_prepend.php +++ b/emhttp/plugins/dynamix/include/local_prepend.php @@ -10,14 +10,15 @@ */ ?> diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index 65ef81cc6..b04df3320 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -4,9 +4,13 @@ SERVICES="rpc nfsd ntpd nginx sshd avahidaemon samba" if [[ -n $1 ]]; then [[ ! -e $1 ]] && touch $1 || exit 0 fi + +# run & log functions +. /etc/rc.d/rc.runlog + for cmd in $SERVICES; do if /etc/rc.d/rc.$cmd update; then - logger -t network -- "reload service: $cmd" + log "$cmd" /etc/rc.d/rc.$cmd reload >/dev/null 2>&1 fi done diff --git a/emhttp/plugins/dynamix/scripts/update_services b/emhttp/plugins/dynamix/scripts/update_services index a3fb2dee8..e6e6c1c57 100755 --- a/emhttp/plugins/dynamix/scripts/update_services +++ b/emhttp/plugins/dynamix/scripts/update_services @@ -1,7 +1,10 @@ #!/bin/bash lock=/tmp/atlock.tmp -logger -t network -- "update services: ${1:-1}s" +# run & log functions +. /etc/rc.d/rc.runlog + +log "${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 diff --git a/emhttp/plugins/dynamix/scripts/upnp_poller b/emhttp/plugins/dynamix/scripts/upnp_poller index 37bf508a6..319e75959 100755 --- a/emhttp/plugins/dynamix/scripts/upnp_poller +++ b/emhttp/plugins/dynamix/scripts/upnp_poller @@ -1,4 +1,8 @@ #!/bin/bash + +# run & log functions +. /etc/rc.d/rc.runlog + while :; do if [[ -x /usr/bin/upnpc ]]; then UPNP=/var/tmp/upnp @@ -34,7 +38,7 @@ while :; do IP=$(ip -4 addr show dev $LINK|grep -Pom1 'inet \K.[^/]+') PORT=$(wg show $WG listen-port) upnpc -u $XML -m $LINK -e "WireGuard-$WG" -a $IP $PORT $PORT udp >/dev/null 2>&1 - [[ $? -eq 0 ]] && logger -t upnpc -- "Added port $PORT/udp" || logger -t upnpc -- "Failed to add port $PORT/udp" + [[ $? -eq 0 ]] && log "Added port $PORT/udp" || log "Failed to add port $PORT/udp" fi done fi diff --git a/emhttp/plugins/dynamix/scripts/upnp_port b/emhttp/plugins/dynamix/scripts/upnp_port index 978967c75..d5f2c9984 100755 --- a/emhttp/plugins/dynamix/scripts/upnp_port +++ b/emhttp/plugins/dynamix/scripts/upnp_port @@ -9,6 +9,9 @@ LINK=$2 UPNP=/var/tmp/upnp XML=$(cat $UPNP 2>/dev/null) +# run & log functions +. /etc/rc.d/rc.runlog + if [[ -n $XML ]]; then # validate XML timeout 6 stdbuf -o0 upnpc -u $XML -m $LINK -l 2>&1|grep -qm1 'refused' @@ -33,23 +36,23 @@ fi WG=$(wg show interfaces) POLLER=/usr/local/emhttp/webGui/scripts/upnp_poller -case $1 in -add) +case "$1" in +'add') upnpc -u $XML -m $LINK -e $3 -a $4 $5 $6 $7 >/dev/null 2>&1 if [[ $? -eq 0 ]]; then [[ -n $WG ]] && at -M -f ${POLLER}_start now 2>/dev/null - logger -t upnpc -- "Added port $5/$7" + log "Added port $5/$7" else - logger -t upnpc -- "Failed to add port $5/$7" + log "Failed to add port $5/$7" fi ;; -del) +'del') upnpc -u $XML -m $LINK -d $3 $4 >/dev/null 2>&1 if [[ $? -eq 0 ]]; then [[ -z $WG && -n $(pgrep -f $POLLER) ]] && pkill -f $POLLER - logger -t upnpc -- "Deleted port $3/$4" + log "Deleted port $3/$4" else - logger -t upnpc -- "Failed to delete port $3/$4" + log "Failed to delete port $3/$4" fi ;; esac diff --git a/sbin/create_network_ini b/sbin/create_network_ini index f2b9ad8d8..0634866d7 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -17,6 +17,9 @@ CFG=/boot/config/network.cfg declare -A VLANID USE_DHCP IPADDR NETMASK GATEWAY METRIC USE_DHCP6 IPADDR6 NETMASK6 GATEWAY6 PRIVACY6 METRIC6 DESCRIPTION PROTOCOL +# run & log functions +. /etc/rc.d/rc.runlog + mask(){ # convert prefix to netmask set -- $((5-(${1:-0}/8))) 255 255 255 255 $(((255<<(8-(${1:-0}%8)))&255)) 0 0 0 @@ -31,7 +34,7 @@ dns() { if [[ -s $CFG ]]; then # import existing settings - . <(fromdos < $CFG) + . <(fromdos <$CFG) else # import default settings IPADDR= @@ -222,7 +225,7 @@ done # atomically update file mv $INI ${INI%.*} -logger -t network -- "hook services: interface=${interface:-$1}, reason=$reason, protocol=$protocol" +log "hook services: interface=${interface:-$1}, reason=$reason, protocol=$protocol" # delayed execution /usr/local/emhttp/webGui/scripts/update_services 30 diff --git a/sbin/monitor_nchan b/sbin/monitor_nchan index 18d854a43..1e3096a97 100755 --- a/sbin/monitor_nchan +++ b/sbin/monitor_nchan @@ -5,6 +5,9 @@ disk_load=/var/local/emhttp/diskload.ini # disk load statistics nginx=/var/run/nginx.socket # nginx local access status=http://localhost/pub/session?buffer_length=1 # nchan information about GUI subscribers +# run & log functions +. /etc/rc.d/rc.runlog + while :; do # only act when GUI registered nchan processes are running if [[ -e $nchan_pid ]]; then @@ -15,7 +18,7 @@ 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 - logger -t monitor "Stop running nchan processes" + log "Stop running nchan processes" # kill GUI registered nchan processes while IFS=$'\n' read -r running; do pkill -f $docroot/${running/:stop/} diff --git a/sbin/powerdown b/sbin/powerdown index 039d9c9e3..73b56acbd 100755 --- a/sbin/powerdown +++ b/sbin/powerdown @@ -1,5 +1,10 @@ #!/bin/bash -logger "/usr/local/sbin/powerdown has been deprecated" + +# run & log functions +. /etc/rc.d/rc.runlog + +log "/usr/local/sbin/powerdown has been deprecated" + if [[ "$1" == "-r" ]]; then /sbin/reboot else