Infosatepg.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
Zeile 1: Zeile 1:
 
  #!/bin/sh
 
  #!/bin/sh
 
  #
 
  #
  # infosatepg.sh - v.0.2
+
  # infosatepg.sh - v.0.3
 
  #
 
  #
 
  # add this lines to your [[commands.conf]]:
 
  # add this lines to your [[commands.conf]]:
Zeile 7: Zeile 7:
 
  #
 
  #
 
  # Run infosatepg                  : /usr/local/bin/infosatepg.sh
 
  # Run infosatepg                  : /usr/local/bin/infosatepg.sh
  # Run infosatepg (inc osd status) : /usr/local/bin/infosatepg.sh status
+
  # Run infosatepg (inc osd status) : /usr/local/bin/infosatepg.sh -status
 
  #
 
  #
 
  # Edit the config.pl:
 
  # Edit the config.pl:
Zeile 13: Zeile 13:
 
  # - our $infosaturl="/video/received_data";
 
  # - our $infosaturl="/video/received_data";
 
  # + our $infosaturl="/tmp/received_data";
 
  # + our $infosaturl="/tmp/received_data";
#
 
# history
 
# --------
 
# 20050113,ronny: added osd status
 
 
   
 
   
 
  # CONFIG START
 
  # CONFIG START
   INFOSAT_OPT="-c VIVA -v"         # Options
+
   INFOSAT_OPT="-v"                 # options
   INFOSAT_OUT="/tmp/received_data" # Store infosatepg in...
+
   INFOSAT_OUT="/tmp/received_data" # store infosatepg in
 +
  CHANNEL="VIVA"                  # which channel, e.g: <NUM> or <NAME>
 +
  SYMBOL="|"                      # e.g: <|> or <#>
 
  # CONFIG END
 
  # CONFIG END
 
   
 
   
 
  PATH=$PATH:/usr/local/bin
 
  PATH=$PATH:/usr/local/bin
 
   
 
   
  test "$(ps axc|awk "{if (\$5==\"infosatepg\") print \$1}")" && {
+
  if [ "$(ps axc|awk "{if (\$5==\"infosatepg\") print \$1}")" ] ; then
     echo 'infosatepg is always running ?'
+
     echo "infosatepg is always running..."
     exit 1
+
else
}
+
    at now <<EOF
 
+
    svdrpsend.pl CHAN ${CHANNEL}|grep -e '^250.*'
mkdir -p "${INFOSAT_OUT}"
+
     if [ ! \$? -eq 0 ] ; then
 
+
        sleep 2s
at now <<EOF
+
        svdrpsend.pl MESG "switch to ${CHANNEL} failed..."
infosatepg ${INFOSAT_OPT} -o "${INFOSAT_OUT}" > "${INFOSAT_OUT}/status" &
+
    else
PID=\$!
+
        mkdir -p "${INFOSAT_OUT}"
test "${1}" && {
+
        infosatepg ${INFOSAT_OPT} -o "${INFOSAT_OUT}" > "${INFOSAT_OUT}/status" &
    until ! ps -p \${PID} >/dev/null ; do
+
        PID=\$!
        test -s "${INFOSAT_OUT}/status" && {
+
        until ! ps -p \${PID} >/dev/null ; do
            STATUS=\$(gawk '/^[0-9]:/ { gsub("/"," ") ; W4 = W4 + \$4; W5 = W5 + \$5 } END { printf "%d\n", W4*100/W5 }' < "${INFOSAT_OUT}/status")
+
            if [ -s "${INFOSAT_OUT}/status" -a "${1}" ] ; then
            GAUGE=\$(perl -l -e "printf '#' x \$((\${STATUS:-0}*2/10))")
+
                STATUS=\$(gawk '/^[0-9]:/ { gsub("/"," ") ; W4 = W4 + \$4 ; W5 = W5 + \$5 } END { printf "%d\n", W4*100/W5 }' < "${INFOSAT_OUT}/status")
            svdrpsend.pl MESG "infosatepg status ~ \${STATUS:-0}% \$(printf "%-21s%-0s\n" "[\${GAUGE:-#}" "]")"
+
                GAUGE=\$(perl -l -e "printf '${SYMBOL}' x \$((\${STATUS:-0}*2/10))")
        }
+
                svdrpsend.pl MESG "infosatepg status ~ \${STATUS:-0}% \$(printf "%-21s%-0s\n" "[\${GAUGE:-${SYMBOL}}" "]")"
        sleep 15s
+
            fi
    done
+
            sleep 15s
}
+
        done
 +
        svdrpsend.pl MESG "infosatepg done..."
 +
    fi
 
  EOF
 
  EOF
 +
fi
  
 
[[Kategorie:Scripts]]
 
[[Kategorie:Scripts]]

Version vom 18. Januar 2005, 04:21 Uhr

#!/bin/sh
#
# infosatepg.sh - v.0.3
#
# add this lines to your commands.conf:
# folgende zeilen in die commands.conf eintragen:
#
# Run infosatepg                  : /usr/local/bin/infosatepg.sh
# Run infosatepg (inc osd status) : /usr/local/bin/infosatepg.sh -status
#
# Edit the config.pl:
#
# - our $infosaturl="/video/received_data";
# + our $infosaturl="/tmp/received_data";

# CONFIG START
  INFOSAT_OPT="-v"                 # options
  INFOSAT_OUT="/tmp/received_data" # store infosatepg in
  CHANNEL="VIVA"                   # which channel, e.g: <NUM> or <NAME>
  SYMBOL="|"                       # e.g: <|> or <#>
# CONFIG END

PATH=$PATH:/usr/local/bin

if [ "$(ps axc|awk "{if (\$5==\"infosatepg\") print \$1}")" ] ; then
    echo "infosatepg is always running..."
else
    at now <<EOF
    svdrpsend.pl CHAN ${CHANNEL}|grep -e '^250.*'
    if [ ! \$? -eq 0 ] ; then
        sleep 2s
        svdrpsend.pl MESG "switch to ${CHANNEL} failed..."
    else
        mkdir -p "${INFOSAT_OUT}"
        infosatepg ${INFOSAT_OPT} -o "${INFOSAT_OUT}" > "${INFOSAT_OUT}/status" &
        PID=\$!
        until ! ps -p \${PID} >/dev/null ; do
            if [ -s "${INFOSAT_OUT}/status" -a "${1}" ] ; then
                STATUS=\$(gawk '/^[0-9]:/ { gsub("/"," ") ; W4 = W4 + \$4 ; W5 = W5 + \$5 } END { printf "%d\n", W4*100/W5 }' < "${INFOSAT_OUT}/status")
                GAUGE=\$(perl -l -e "printf '${SYMBOL}' x \$((\${STATUS:-0}*2/10))")
                svdrpsend.pl MESG "infosatepg status ~ \${STATUS:-0}% \$(printf "%-21s%-0s\n" "[\${GAUGE:-${SYMBOL}}" "]")"
            fi
            sleep 15s
        done
        svdrpsend.pl MESG "infosatepg done..."
    fi
EOF
fi