summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-07-14 15:07:30 +0200
committerSimon Rettberg2016-07-14 15:07:30 +0200
commit8a927da541ff175c2601e54726c642b0d5375b13 (patch)
treec3846e1b7e7f3a04a7afef27a9367c936306572a
parent[rfs-stage32] Add --delete and --sync to slxlog, make spam protection a per-u... (diff)
downloadtm-scripts-8a927da541ff175c2601e54726c642b0d5375b13.tar.gz
tm-scripts-8a927da541ff175c2601e54726c642b0d5375b13.tar.xz
tm-scripts-8a927da541ff175c2601e54726c642b0d5375b13.zip
Update several calls to slxlog with --delete instead of having sleep + rm follow the call
-rwxr-xr-xremote/modules/cron/data/opt/openslx/scripts/cron-sendmail8
-rwxr-xr-xremote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats2
-rwxr-xr-xremote/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm3
-rw-r--r--remote/modules/pam-common-share/data/opt/openslx/scripts/pam_script_mount_common_share9
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc2
-rwxr-xr-xremote/modules/run-virt/data/opt/openslx/scripts/systemd-mount_vm_store5
-rwxr-xr-xremote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl10
7 files changed, 21 insertions, 18 deletions
diff --git a/remote/modules/cron/data/opt/openslx/scripts/cron-sendmail b/remote/modules/cron/data/opt/openslx/scripts/cron-sendmail
index 3ce2a19d..f46c226d 100755
--- a/remote/modules/cron/data/opt/openslx/scripts/cron-sendmail
+++ b/remote/modules/cron/data/opt/openslx/scripts/cron-sendmail
@@ -10,16 +10,14 @@ if [ "x$SLX_CRON_MAIL" = "xslxlog" ]; then
SUBJ=$(grep '^Subject: .*$' "$TMP" | cut -c 10-)
if [ -n "$SUBJ" ]; then
- slxlog "cron" "$SUBJ" "$TMP"
+ slxlog --delete "cron" "$SUBJ" "$TMP"
fi
-
- rm -f -- "$TMP"
elif [ -n "$SLX_CRON_MAIL" ] && [ -x "$SLX_CRON_MAIL" ]; then
# see if SLX_CRON_MAIL is a valid binary and use that
- $SLX_CRON_MAIL $@
+ $SLX_CRON_MAIL "$@"
elif which sendmail 2> /dev/null; then
# fallback to sendmail
- sendmail $@
+ sendmail "$@"
elif which logger 2> /dev/null; then
# nothing worked, write to syslog if logger is present
TMP=$(mktemp /tmp/cron.XXXXXXXX)
diff --git a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
index 94c2094f..eba9c287 100755
--- a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
+++ b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
@@ -66,7 +66,7 @@ fi
CPUMODEL=$(grep -m1 '^model name\s*:' /proc/cpuinfo | sed 's/^model name\s*:\s*//;s/\s\s*/ /g;s/^ //;s/ $//')
# 6) RAM
-RAM=$(grep '^MemTotal:' /proc/meminfo | awk '{print $2}')
+RAM=$(grep -m1 '^MemTotal:' /proc/meminfo | awk '{print $2}')
RAM=$(( $RAM / 1024 ))
if [ -z "$RAM" ] || [ "$RAM" -lt 500 ]; then
# Fallback to dmidecode
diff --git a/remote/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm b/remote/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
index 13e40cb9..69a0b657 100755
--- a/remote/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
+++ b/remote/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
@@ -166,8 +166,7 @@ exit 1
mainret=$?
if [ "x$mainret" == "x7" ]; then
# exit code 7 is our marker to push the logfile to the sat
- slxlog "pam-bwidm" "Internal error during bwIDM authentication" "${LOGFILE}"
- ( sleep 1; rm -f -- "${LOGFILE}" ) &
+ slxlog --delete "pam-bwidm" "Internal error during bwIDM authentication" "${LOGFILE}"
exit 1
fi
exit "${mainret}"
diff --git a/remote/modules/pam-common-share/data/opt/openslx/scripts/pam_script_mount_common_share b/remote/modules/pam-common-share/data/opt/openslx/scripts/pam_script_mount_common_share
index 670943f4..d0bd8842 100644
--- a/remote/modules/pam-common-share/data/opt/openslx/scripts/pam_script_mount_common_share
+++ b/remote/modules/pam-common-share/data/opt/openslx/scripts/pam_script_mount_common_share
@@ -118,12 +118,13 @@ mount_share() {
# check for failures
if [ -e "${SIGNAL}" ]; then
- slxlog "pam-share-mount" "Mount of '${SHARE_PATH}' to '${TARGET_DIR}' failed. (Args: ${MOUNT_OPTS}" "${MOUNT_OUTPUT}"
- rm -f -- "${SIGNAL}"
+ slxlog --delete "pam-share-mount" "Mount of '${SHARE_PATH}' to '${TARGET_DIR}' failed. (Args: '${MOUNT_OPTS}')" "${MOUNT_OUTPUT}"
+ rm -f -- "${SIGNAL}"
elif kill -9 "${MOUNT_PID}" 2>/dev/null; then
- slxlog "pam-share-mount" "Mount of '${SHARE_PATH}' to '${TARGET_DIR}' timed out. (Args: ${MOUNT_OPTS}" "${MOUNT_OUTPUT}"
+ slxlog --delete "pam-share-mount" "Mount of '${SHARE_PATH}' to '${TARGET_DIR}' timed out. (Args: '${MOUNT_OPTS}')" "${MOUNT_OUTPUT}"
+ else
+ rm -f -- "${MOUNT_OUTPUT}"
fi
- ( sleep 2; rm -f -- "${MOUNT_OUTPUT}" ) &
# always unset credentials
unset USER
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc
index 337562dc..3c4ed330 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_image_access.inc
@@ -29,8 +29,6 @@ else
writelog "dnbd3-fuse stopped working (Exit code $RET)"
slxlog "virt-dnbd3-fuse" "dnbd3-fuse stopped/refused serving '${imgrelpath}' from '${SLX_DNBD3_SERVERS}' with error code: $RET" "${dnbd3_tmplog}"
fi
- sleep 2
- rm -f -- "$dnbd3_tmplog" "$dnbd3_exitflag"
) &
# give it a bit of time
usleep 250000
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/systemd-mount_vm_store b/remote/modules/run-virt/data/opt/openslx/scripts/systemd-mount_vm_store
index 363e5253..235cf4be 100755
--- a/remote/modules/run-virt/data/opt/openslx/scripts/systemd-mount_vm_store
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/systemd-mount_vm_store
@@ -31,13 +31,12 @@ fi > "$OUTFILE" 2>&1
if [ "$RET" -ne "0" ]; then
if [ -s "$OUTFILE" ]; then
- slxlog "mount-vmstore-fail" "Mounting '$SLX_VM_NFS' failed. VMs will not boot." "$OUTFILE"
- sleep 1
+ slxlog --delete "mount-vmstore-fail" "Mounting '$SLX_VM_NFS' failed. VMs will not boot." "$OUTFILE"
else
slxlog "mount-vmstore-fail" "Mounting '$SLX_VM_NFS' failed. VMs will not boot."
+ rm -f -- "$OUTFILE"
fi
fi
-rm -f -- "$OUTFILE"
exit $RET
diff --git a/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl b/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl
index 1eef0a23..979fde62 100755
--- a/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl
+++ b/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl
@@ -5,6 +5,7 @@
. /opt/openslx/config
[ -z "$SLX_SMARTCTL_MIN_REALLOC" ] && SLX_SMARTCTL_MIN_REALLOC=0
+DELAY=
FILES=
for dev in /dev/sd?; do
@@ -20,14 +21,21 @@ for dev in /dev/sd?; do
# report if applicable
if [ -n "$OVERALL" ]; then
slxlog "smartctl-fail" "Failed HDD: $dev reports health as $OVERALL" "$FILE"
+ DELAY=yes
fi
if [ -n "$REALLOC" ] && [ "$REALLOC" -gt "$SLX_SMARTCTL_MIN_REALLOC" ]; then
slxlog "smartctl-realloc" "Failing HDD: $dev has $REALLOC reallocated sectors!" "$FILE"
+ DELAY=yes
fi
if [ -n "$SPINRETRY_VAL" ] && [ "$SPINRETRY_VAL" -le "$SPINRETRY_THR" ]; then
slxlog "smartctl-spinretry" "Failing HDD: $dev has bad spin retry count! ($SPINRETRY_VAL/$SPINRETRY_THR)" "$FILE"
+ DELAY=yes
fi
done
-sleep 2 # give slxlog a little time, as it's running async
+
+[ -n "$DELAY" ] && sleep 2 # give slxlog a little time, as it's running async
[ -n "$FILES" ] && rm -f -- $FILES # list, no ""
+# Keep it that way instead of using --delete or --sync sonce it would add up; this way we're doing it just once here
+
+exit 0