#!/bin/sh # ----------------------------------------------------------- # Y Library (yjogol) # ----------------------------------------------------------- # ----------------------------------------------------------- # local call to WebServer $1=url (after http://locahost:port/<$1>) # ----------------------------------------------------------- call_webserver() { port=`sed -n /^WebsiteMain.port=/p $y_config_nhttpd | sed -e s/^WebsiteMain.port=//1` tmp=`wget -O - -q "http://localhost:$port/$1"` echo "$tmp" } # =========================================================== # Streaming URL # =========================================================== buildLocalIP() { localIP=`ifconfig eth0|sed -n '/inet addr/p'|sed -e 's/^.*inet addr://g' -e 's/ .*//g'` echo "$localIP" } # ----------------------------------------------------------- # Streaming URL f�r sed # ----------------------------------------------------------- buildStreamingURL() { localIP=`buildLocalIP` pids=`call_webserver "control/yweb?video_stream_pids=0"` echo "http:\/\/$localIP:31339\/0,$pids" } # ----------------------------------------------------------- # Streaming URL # ----------------------------------------------------------- buildStreamingRawURL() { localIP=`buildLocalIP` pids=`call_webserver "control/yweb?video_stream_pids=0"` echo "http://$localIP:31339/0,$pids" } # ----------------------------------------------------------- # Audio: Streaming URL f�r sed # ----------------------------------------------------------- buildStreamingAudioURL() { localIP=`buildLocalIP` Y_APid=`call_webserver "control/yweb?radio_stream_pid"` echo "http:\/\/$localIP:31338\/$Y_APid" } # ----------------------------------------------------------- # Streaming URL # ----------------------------------------------------------- buildStreamingAudioRawURL() { localIP=`buildLocalIP` Y_APid=`call_webserver "control/yweb?radio_stream_pid"` echo "http://$localIP:31338/$Y_APid" } # ----------------------------------- # UNIX ($msg) Text als HTML ausgeben # noch sehr unschoen # ----------------------------------- y_format_message_html() { tmp="" tmp="$tmp " tmp="$tmp " tmp="$tmp " tmp="$tmp
Results
" tmp="$tmp
\n$msg\n
" #tmp="$tmp
\n$msg\n
" echo -e "$tmp" } y_format_message_html2() { tmp="" tmp="$tmp " tmp="$tmp " tmp="$tmp " tmp="$tmp
Results
" tmp="$tmp $msg
" echo "$tmp" } y_format_message_html_plain() { tmp="" tmp="$tmp " tmp="$tmp " tmp="$tmp " tmp="$tmp $msg" echo "$tmp" } # =========================================================== # config-Dateien - lesen / schreiben # (Zeilenformat: VarName=VarValue) # =========================================================== cfg="" # ----------------------------------------------------------- # config-Datei lesen/cachen (Inhalt in $cfg) # $1=config-Filename # ----------------------------------------------------------- config_open() { cfg="" cfg=`cat $1` } # ----------------------------------------------------------- # config-Datei schreiben (Inhalt in $cfg) # $1=config-Filename # ----------------------------------------------------------- config_write() { echo "$cfg" > $1 } # ----------------------------------------------------------- # Variablenwert zurueckgeben (vorher open) # $1=VarName # ----------------------------------------------------------- config_get_value() { cmd="sed -n /^$1=/p" tmp=`echo "$cfg" | $cmd` cmd="sed -e s/^$1=//1" tmp=`echo "$tmp" | $cmd` echo $tmp } # ----------------------------------------------------------- # Variablenwert zurueckgeben (ohne open) # $1=config-Filename # $2=VarName # ----------------------------------------------------------- config_get_value_direct() { config_open $1 config_get_value $2 } # ----------------------------------------------------------- # Variablenwert setzen (vorher open) # $1=VarName) # $2=VarValue # ----------------------------------------------------------- config_set_value() { tmp=`echo "$cfg" | sed -n "/^$1=.*/p"` if [ "$tmp" = "" ] then cfg=`echo -e "$cfg\n$1=$2"` else cmd="sed -e s/^$1=.*/$1=$2/g" cfg=`echo "$cfg" | $cmd` fi } # ----------------------------------------------------------- # Variablenwert zurueckgeben (ohne open) # $1=config-Filename # $2=VarName) # $3=VarValue # ----------------------------------------------------------- config_set_value_direct() { config_open $1 config_set_value $2 $3 config_write $1 } # ----------------------------------------------------------- # Reboot # ----------------------------------------------------------- yreboot() { #reboot call_webserver "control/reboot" } # ----------------------------------------------------------- # Message - nmsg (waiting - press ok on rc) # ----------------------------------------------------------- msg_nmsg() { call_webserver "control/message?nmsg=$1" } # ----------------------------------------------------------- # Message - popup (closes autom.) # ----------------------------------------------------------- msg_popup() { call_webserver "control/message?popup=$1" } # ----------------------------------------------------------- # create yWeb.conf if does not exists # ----------------------------------------------------------- check_yWeb_conf() { if ! [ -e $y_config_yWeb ] then echo "skin=NI_dark" > $y_config_yWeb fi }