From f8fbbaef577d9a2837d8db10396692d343f6aae1 Mon Sep 17 00:00:00 2001 From: deajan Date: Tue, 21 May 2019 00:38:59 +0200 Subject: [PATCH] Unexpanded ofunctions --- dev/RELEASES | 1 + dev/ofunctions.sh | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/dev/RELEASES b/dev/RELEASES index b569c64..dfe4282 100644 --- a/dev/RELEASES +++ b/dev/RELEASES @@ -10,6 +10,7 @@ Run program and then use declare -p to find any leaked variables that should not - ./shellcheck.sh ../install.sh - ./shellcheck.sh ../osync-batch.sh - ./shellcheck.sh ../ssh_filter.sh +- Unexpansion of main and subprograms must be done - Arch repo must be updated - Source must be put to download on www.netpower.fr/osync - Tests must be run against all supported operating systems via run_tests.sh diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index 385f953..2334c08 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -149,17 +149,17 @@ function PoorMansRandomGenerator { fi } function PoorMansRandomGenerator { - local digits="${1}" # The number of digits to generate - local number - - # Some read bytes can't be used, se we read twice the number of required bytes - dd if=/dev/urandom bs=$digits count=2 2> /dev/null | while read -r -n1 char; do - number=$number$(printf "%d" "'$char") - if [ ${#number} -ge $digits ]; then - echo ${number:0:$digits} - break; - fi - done + local digits="${1}" # The number of digits to generate + local number + + # Some read bytes can't be used, se we read twice the number of required bytes + dd if=/dev/urandom bs=$digits count=2 2> /dev/null | while read -r -n1 char; do + number=$number$(printf "%d" "'$char") + if [ ${#number} -ge $digits ]; then + echo ${number:0:$digits} + break; + fi + done } #### PoorMansRandomGenerator SUBSET END #### @@ -491,15 +491,15 @@ function SendAlert { return 0 fi - if [ $attachment == true ]; then - attachmentFile="$LOG_FILE" - if type "$COMPRESSION_PROGRAM" > /dev/null 2>&1; then - eval "cat \"$LOG_FILE\" \"$COMPRESSION_PROGRAM\" > \"$ALERT_LOG_FILE\"" - if [ $? -eq 0 ]; then - attachmentFile="$ALERT_LOG_FILE" - fi - fi - fi + if [ $attachment == true ]; then + attachmentFile="$LOG_FILE" + if type "$COMPRESSION_PROGRAM" > /dev/null 2>&1; then + eval "cat \"$LOG_FILE\" \"$COMPRESSION_PROGRAM\" > \"$ALERT_LOG_FILE\"" + if [ $? -eq 0 ]; then + attachmentFile="$ALERT_LOG_FILE" + fi + fi + fi body="$MAIL_ALERT_MSG"$'\n\n'"Last 1000 lines of current log"$'\n\n'"$(tail -n 1000 "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP.log")"