diff options
| author | Jonathan Bauer | 2016-07-15 13:33:31 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2016-07-15 13:33:31 +0200 |
| commit | e95317dc5caf6907f1b8d8a900320480dc3ab17e (patch) | |
| tree | 3e865f54c5a34724bd1a79fd8b1d062c48f5999d /remote | |
| parent | [dnbd3] fix missing dependency on fusermount for dnbd3-fuse (diff) | |
| parent | Update several calls to slxlog with --delete instead of having sleep + rm fol... (diff) | |
| download | tm-scripts-e95317dc5caf6907f1b8d8a900320480dc3ab17e.tar.gz tm-scripts-e95317dc5caf6907f1b8d8a900320480dc3ab17e.tar.xz tm-scripts-e95317dc5caf6907f1b8d8a900320480dc3ab17e.zip | |
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
Diffstat (limited to 'remote')
8 files changed, 64 insertions, 33 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 diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog index 52320c1a..09cb9b79 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog @@ -13,13 +13,29 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/o . /opt/openslx/config [ -z "$SLX_REMOTE_LOG" ] && exit 3 -LOGCHECK="/tmp/remote_log_check" +USER=$(whoami) +LOGCHECK="/tmp/remote_log_check-$USER" NOW=$(date +%s) +DELFILE= +SYNC= -if [ "x$1" = "x-e" -o "x$1" = "x--echo" ]; then +while [ $# -gt 0 ]; do + case "$1" in + -e|--echo) + echo "$@" + ;; + -d|--delete) + DELFILE=yes + ;; + -s|--sync) + SYNC=yes + ;; + *) + break + ;; + esac shift - echo "$@" -fi +done [ $# -eq 0 ] && exit 0 @@ -42,14 +58,13 @@ if [ -r "$LOGCHECK" ]; then fi fi echo "$NOW $TYPE" >> "$LOGCHECK" -chmod 0666 "$LOGCHECK" 2>/dev/null +chmod 0600 "$LOGCHECK" 2>/dev/null if [ $# -lt 2 ]; then MSG="Missing text for $@" else MSG="$2" fi -USER=$(whoami) MSG="[$USER] $MSG" if [ $# -gt 2 ]; then @@ -62,15 +77,28 @@ else CURLLOG="/dev/null" fi -if [ -n "$EXTRA" ] && [ -r "$EXTRA" -a -s "$EXTRA" ] && [ "$(stat -c %s "$EXTRA")" -lt "10000" ]; then # valid file attachment - curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc@$EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 & -elif [ -z "$EXTRA" ]; then # no attachment - curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 & -elif [ -s "$EXTRA" ]; then # empty attachment file (or missing) - curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Attachment too large: $EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 & -else # attachment file to big (more than 10k) - curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Attachment missing/empty: $EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 & +UUID= +if [ -s /run/system-uuid ]; then + UUID=$(cat /run/system-uuid) +fi + +submitlog () { + if [ -n "$EXTRA" ] && [ -r "$EXTRA" -a -s "$EXTRA" ] && [ "$(stat -c %s "$EXTRA")" -lt "10000" ]; then # valid file attachment + curl --data-urlencode "uuid=$UUID" --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc@$EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 + elif [ -z "$EXTRA" ]; then # no attachment + curl --data-urlencode "uuid=$UUID" --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 + elif [ -s "$EXTRA" ]; then # attachment file to big (more than 10k) + curl --data-urlencode "uuid=$UUID" --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Attachment too large: $EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 + else # empty attachment file (or missing) + curl --data-urlencode "uuid=$UUID" --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Attachment missing/empty: $EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 + fi + [ -n "$DELFILE" ] && [ -n "$EXTRA" ] && rm -f -- "$EXTRA" +} + +if [ -z "$SYNC" ]; then + submitlog & + exit 0 fi -exit 0 +submitlog |
