Fixing for LINUX
authorKristian <jkkn@tv2.dk>
Mon, 13 Feb 2017 18:17:53 +0000 (19:17 +0100)
committerKristian Kræmmer Nielsen <jkkn@tv2.dk>
Mon, 13 Feb 2017 18:17:53 +0000 (19:17 +0100)
monitor-dai.sh

index 5ef4954fd75fe5267d0ebb55880d31f7cce1b9ce..2b4a3ad9731d99b6163a61894e0ab0e017229b39 100755 (executable)
@@ -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