From: Kristian Date: Mon, 13 Feb 2017 18:17:53 +0000 (+0100) Subject: Fixing for LINUX X-Git-Url: https://git.jkkn.net/?a=commitdiff_plain;h=0094e4986e03baebe9e11708e1dbd9d01d587461;p=dai-monitor.git Fixing for LINUX --- diff --git a/monitor-dai.sh b/monitor-dai.sh index 5ef4954..2b4a3ad 100755 --- a/monitor-dai.sh +++ b/monitor-dai.sh @@ -27,7 +27,7 @@ SCRIPT_NAME=$(basename "$0") DATE_BSD="date -r " DATE_LINUX="date -d @" -DATE="$DATE_BSD" +DATE="$DATE_LINUX" # Used as default 10 seconds pause before retrying TARGET_DURATION=10 @@ -71,7 +71,7 @@ function fatal() { # Extract first stream from HLS Master-Playlist function resolveFirstStream() { local hls="$1" - TMPFILE=$(mktemp -t "$SCRIPT_NAME") || fatal "Can not write tmp-file" + TMPFILE=$(mktemp "$SCRIPT_NAME.XXXXXXXX") || fatal "Can not write tmp-file" url=$(curl $BASIC_CURL_PARAMS -o "$TMPFILE" "$hls" -w "%{url_effective}") if [ $? -eq 0 ]; then while IFS="" read line; do @@ -100,7 +100,7 @@ function monitorStream() { real_time=$(date +%s) stream_time=$(($real_time - $STREAM_TIME_SCREW)) - pretty_time=$($DATE ${stream_time%.*} +"%Y-%m-%d %H:%M:%S") + pretty_time=$($DATE${stream_time%.*} +"%Y-%m-%d %H:%M:%S") echo "NOTICE: Using time-offset of -$STREAM_TIME_SCREW seconds so time is $pretty_time, real time is $(date ${realtime} +"%Y-%m-%d %H:%M:%S")" echo "$pretty_time: Started monitoring using: $stream" @@ -109,7 +109,7 @@ function monitorStream() { starttime=$(date +%s) warn_not_a_playlist=1 - TMPFILE=$(mktemp -t "$SCRIPT_NAME") || fatal "Can not write tmp-file" + TMPFILE=$(mktemp "$SCRIPT_NAME.XXXXXXXX") || fatal "Can not write tmp-file" curl $BASIC_CURL_PARAMS -o "$TMPFILE" "$stream" if [ $? -eq 0 ]; then while IFS="" read line; do @@ -127,7 +127,7 @@ function monitorStream() { if [[ $curSeq -ge $nextSeq ]]; then # later sequence than we need curLength=$(echo "$nextSegmentLength + $curLength" | bc) stream_time=$(echo "$stream_time + $nextSegmentLength" | bc) - pretty_time=$($DATE ${stream_time%.*} +"%Y-%m-%d %H:%M:%S") + pretty_time=$($DATE${stream_time%.*} +"%Y-%m-%d %H:%M:%S") if [[ $curSeq -ne $nextSeq ]]; then echo >&2 "$pretty_time: Skipped a segment by mistake ($curSeq > $nextSeq)" fi