Conflicts:
	configure.ac


Origin commit data
------------------
Branch: ni/coolstream
Commit: 624691ea0d
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-12-15 (Thu, 15 Dec 2016)



------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2016-12-15 14:12:33 +01:00
284 changed files with 47 additions and 440 deletions

View File

@@ -0,0 +1,15 @@
installdir = $(PRIVATE_HTTPDDIR)/scripts
install_DATA= api.sh _Y_Globals.sh _Y_Library.sh Y_Live.sh Y_Tools.sh
# file manager
install_DATA += Y_NAS.sh
# NI-yWeb
install_DATA += Y_NI_Camd-control.sh \
Y_NI_Plugin-control.sh \
Y_NI_Tools.sh
install-data-hook:
chmod 0755 $(DESTDIR)$(PRIVATE_HTTPDDIR)/scripts/api.sh
chmod 0755 $(DESTDIR)$(PRIVATE_HTTPDDIR)/scripts/Y_*.sh

117
data/y-web/scripts/Y_Live.sh Executable file
View File

@@ -0,0 +1,117 @@
#!/bin/sh
# -----------------------------------------------------------
# Live (yjogol)
# $Date$
# $Revision$
# -----------------------------------------------------------
. ./_Y_Globals.sh
. ./_Y_Library.sh
# -----------------------------------------------------------
live_lock()
{
call_webserver "control/rc?lock" >/dev/null
call_webserver "control/zapto?stopplayback" >/dev/null
}
# -----------------------------------------------------------
live_unlock()
{
call_webserver "control/rc?unlock" >/dev/null
call_webserver "control/zapto?startplayback" >/dev/null
}
# -----------------------------------------------------------
prepare_tv()
{
# SPTS on
if [ "$boxtype" != "coolstream" ]; then
call_webserver "control/system?setAViAExtPlayBack=spts" >/dev/null
fi
}
# -----------------------------------------------------------
prepare_radio()
{
# SPTS off
if [ "$boxtype" != "coolstream" ]; then
call_webserver "control/system?setAViAExtPlayBack=pes" >/dev/null
fi
}
# -----------------------------------
# Main
# -----------------------------------
# echo "$1" >/tmp/debug.txt
echo "$*"
case "$1" in
zapto)
if [ "$2" != "" ]
then
call_webserver "control/zapto?$2" >/dev/null
fi
;;
switchto)
if [ "$2" = "Radio" ]
then
call_webserver "control/setmode?radio" >/dev/null
else
call_webserver "control/setmode?tv" >/dev/null
fi
;;
url)
url=`buildStreamingRawURL`
echo "$url" ;;
audio-url)
url=`buildStreamingAudioRawURL`
echo "$url" ;;
live_lock)
live_lock ;;
live_unlock)
live_unlock ;;
dboxIP)
buildLocalIP ;;
prepare_radio)
prepare_radio
Y_APid=`call_webserver "control/yweb?radio_stream_pid"`
url="http://$2:31338/$Y_APid"
echo "$url" > $y_tmp_m3u
echo "$url" > $y_tmp_pls
;;
prepare_tv)
prepare_tv
;;
udp_stream)
if [ "$2" = "start" ]
then
shift 2
killall streamts
killall streampes
killall udpstreamts
if [ -e $y_path_varbin/udpstreamts ]
then
$y_path_varbin/udpstreamts $* &
else
udpstreamts $* &
fi
pidof udpstreamts >/tmp/udpstreamts.pid
fi
if [ "$2" = "stop" ]
then
killall udpstreamts
fi
;;
*)
echo "Parameter wrong: $*" ;;
esac

72
data/y-web/scripts/Y_NAS.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/sh
# -----------------------------------------------------------
# yWeb Extension: Filemgr (by yjogol)
# yCVS: $Date: 2007-12-29 08:20:30 $
# yCVS: $Revision: 1.1 $
# -----------------------------------------------------------
# -----------------------------------------------------------
# Main
# -----------------------------------------------------------
case "$1" in
list_users)
cat $fpasswd|sed 's/^\([^:]*\).*/<input type=radio name=users value=\1>\1<br>/' ;;
filemgr_list)
shift 1
ls -al $* ;;
filemgr_chmod)
shift 1
chmod $*
;;
filemgr_mkdir)
shift 1
mkdir $*
;;
filemgr_rm)
shift 1
rm -f $*
;;
filemgr_rmdir)
shift 1
rm -rf $*
;;
filemgr_upload)
shift 1
mv /tmp/upload.tmp "$1/$2"
rm -f /tmp/upload.tmp
;;
filemgr_ren)
shift 1
mv -f $1 $2
;;
filemgr_copy)
shift 1
cp -r -f $1 $2
;;
nhttpd_can_sendall)
grep sendAll=true %(CONFIGDIR)/nhttpd.conf
;;
filemgr_check_movieplayer_xml)
shift 1
grep "neutrino commandversion" $*
;;
filemgr_vlc_file)
shift 1
echo "$*" >/tmp/vlc.m3u
;;
*)
echo "[Y_NAS.sh] Parameter falsch: $*" ;;
esac

View File

@@ -0,0 +1,124 @@
#!/bin/sh
. %(PRIVATE_HTTPDDIR)/scripts/_Y_Globals.sh
. %(PRIVATE_HTTPDDIR)/scripts/_Y_Library.sh
BNAME=${0##*/}
case "$1" in
start)
echo "[$BNAME] softcamd-start"
/etc/init.d/emu reset >/dev/console
;;
stop)
echo "[$BNAME] softcamd-stop"
/etc/init.d/emu stop >/dev/console
;;
reset)
echo "[$BNAME] softcamd-reset"
/etc/init.d/emu reset >/dev/console
;;
mgcamd_start)
echo "[$BNAME] mgcamd-start"
touch /var/etc/.mgcamd
/etc/init.d/emu start mgcamd >/dev/console
;;
mgcamd_stop)
echo "[$BNAME] mgcamd-stop"
/etc/init.d/emu stop mgcamd >/dev/console
rm -rf /var/etc/.mgcamd
;;
mgcamd_reset)
echo "[$BNAME] mgcamd-reset"
/etc/init.d/emu reset mgcamd >/dev/console
;;
gbox_start)
echo "[$BNAME] gbox-start"
touch /var/etc/.gbox
/etc/init.d/emu start gbox >/dev/console
;;
gbox_stop)
echo "[$BNAME] gbox-stop"
rm -rf /var/etc/.gbox
/etc/init.d/emu stop gbox >/dev/console
;;
gbox_reset)
echo "[$BNAME] gbox-reset"
/etc/init.d/emu reset gbox >/dev/console
;;
cs2gbox_start)
echo "[$BNAME] cs2gbox-start"
touch /var/etc/.cs2gbox
/etc/init.d/emu start cs2gbox >/dev/console
;;
cs2gbox_stop)
echo "[$BNAME] cs2gbox-stop"
rm -rf /var/etc/.cs2gbox
/etc/init.d/emu stop cs2gbox >/dev/console
;;
cs2gbox_reset)
echo "[$BNAME] cs2gbox-reset"
/etc/init.d/emu reset cs2gbox >/dev/console
;;
osemu_start)
echo "[$BNAME] osemu-start"
touch /var/etc/.osemu
/etc/init.d/emu start osemu >/dev/console
;;
osemu_stop)
echo "[$BNAME] osemu-stop"
rm -rf /var/etc/.osemu
/etc/init.d/emu stop osemu >/dev/console
;;
osemu_reset)
echo "[$BNAME] osemu-reset"
/etc/init.d/emu reset osemu >/dev/console
;;
oscam_start)
echo "[$BNAME] oscam-start"
touch /var/etc/.oscam
/etc/init.d/emu start oscam >/dev/console
;;
oscam_stop)
echo "[$BNAME] oscam-stop"
rm -rf /var/etc/.oscam
/etc/init.d/emu stop oscam >/dev/console
;;
oscam_reset)
echo "[$BNAME] oscam-reset"
/etc/init.d/emu reset oscam >/dev/console
;;
doscam_start)
echo "[$BNAME] doscam-start"
touch /var/etc/.doscam
/etc/init.d/emu start doscam >/dev/console
;;
doscam_stop)
echo "[$BNAME] doscam-stop"
rm -rf /var/etc/.doscam
/etc/init.d/emu stop doscam >/dev/console
;;
doscam_reset)
echo "[$BNAME] doscam-reset"
/etc/init.d/emu reset doscam >/dev/console
;;
newcs_start)
echo "[$BNAME] newcs-start"
touch /var/etc/.newcs
/etc/init.d/emu start newcs >/dev/console
;;
newcs_stop)
echo "[$BNAME] newcs-stop"
rm -rf /var/etc/.newcs
/etc/init.d/emu stop newcs >/dev/console
;;
newcs_reset)
echo "[$BNAME] newcs-reset"
/etc/init.d/emu reset newcs >/dev/console
;;
*)
echo "[$BNAME] Parameter wrong: $*"
;;
esac
exit 0

View File

@@ -0,0 +1,130 @@
#!/bin/sh
. %(PRIVATE_HTTPDDIR)/scripts/_Y_Globals.sh
. %(PRIVATE_HTTPDDIR)/scripts/_Y_Library.sh
BNAME=${0##*/}
case "$1" in
start)
;;
stop)
;;
reset)
;;
fcm_start)
echo "[$BNAME] fritzcallmonitor start"
touch /var/etc/.fritzcallmonitor
$y_path_sbin/service fritzcallmonitor start >/dev/console
;;
fcm_stop)
echo "[$BNAME] fritzcallmonitor stop"
$y_path_sbin/service fritzcallmonitor stop >/dev/console
rm -f /var/etc/.fritzcallmonitor
;;
nfs_start)
echo "[$BNAME] nfs-server start"
touch /var/etc/.nfsd
$y_path_sbin/service nfsd start >/dev/console
;;
nfs_stop)
echo "[$BNAME] nfs-server stop"
$y_path_sbin/service nfsd stop >/dev/console
rm -f /var/etc/.nfsd
;;
smb_start)
echo "[$BNAME] samba-server start"
touch /var/etc/.samba
$y_path_sbin/service samba start >/dev/console
;;
smb_stop)
echo "[$BNAME] samba-server stop"
$y_path_sbin/service samba stop >/dev/console
rm -f /var/etc/.samba
;;
txc_start)
echo "[$BNAME] tuxcal start"
touch /var/etc/.tuxcald
$y_path_sbin/service tuxcald start >/dev/console
;;
txc_stop)
echo "[$BNAME] tuxcal stop"
$y_path_sbin/service tuxcald stop >/dev/console
rm -f /var/etc/.tuxcald
;;
txm_start)
echo "[$BNAME] tuxmail start"
touch /var/etc/.tuxmaild
$y_path_sbin/service tuxmaild start >/dev/console
;;
txm_stop)
echo "[$BNAME] tuxmail stop"
$y_path_sbin/service tuxmaild stop >/dev/console
rm -f /var/etc/.tuxmaild
;;
ina_start)
echo "[$BNAME] inadyn start"
touch /var/etc/.inadyn
$y_path_sbin/service inadyn start >/dev/console
;;
ina_stop)
echo "[$BNAME] inadyn stop"
$y_path_sbin/service inadyn stop >/dev/console
rm -f /var/etc/.inadyn
;;
drop_start)
echo "[$BNAME] dropbear start"
touch /var/etc/.dropbear
$y_path_sbin/service dropbear start >/dev/console
;;
drop_stop)
echo "[$BNAME] dropbear stop"
$y_path_sbin/service dropbear stop >/dev/console
rm -f /var/etc/.dropbear
;;
ush_start)
echo "[$BNAME] ushare start"
touch /var/etc/.ushare
$y_path_sbin/service ushare start >/dev/console
;;
ush_stop)
echo "[$BNAME] ushare stop"
$y_path_sbin/service ushare stop >/dev/console
rm -f /var/etc/.ushare
;;
djm_start)
echo "[$BNAME] djmount start"
touch /var/etc/.djmount
$y_path_sbin/service djmount start >/dev/console
;;
djm_stop)
echo "[$BNAME] djmount stop"
$y_path_sbin/service djmount stop >/dev/console
rm -f /var/etc/.djmount
;;
xud_start)
echo "[$BNAME] xupnpd start"
touch /var/etc/.xupnpd
$y_path_sbin/service xupnpd start >/dev/console
;;
xud_stop)
echo "[$BNAME] xupnpd stop"
$y_path_sbin/service xupnpd stop >/dev/console
rm -f /var/etc/.xupnpd
;;
cro_start)
echo "[$BNAME] crond start"
touch /var/etc/.crond
$y_path_sbin/service crond start >/dev/console
;;
cro_stop)
echo "[$BNAME] crond stop"
$y_path_sbin/service crond stop >/dev/console
rm -f /var/etc/.crond
;;
*)
echo "[$BNAME] Parameter wrong: $*"
;;
esac
exit 0

View File

@@ -0,0 +1,553 @@
#!/bin/sh
# -----------------------------------------------------------
# Y NI Tools (NI-Team)
# -----------------------------------------------------------
if echo "$@" | grep -q "%20"; then
$0 ${@//%20/ }
exit
fi
. %(PRIVATE_HTTPDDIR)/scripts/_Y_Globals.sh
. %(PRIVATE_HTTPDDIR)/scripts/_Y_Library.sh
BNAME=${0##*/}
PLUGIN_DIRS="%(PLUGINDIR) %(PLUGINDIR_VAR) %(PLUGINDIR_MNT) $(config_get_value_direct $y_config_neutrino 'plugin_hdd_dir')"
getLanguage()
{
Y_LANG=$(cat %(CONFIGDIR)/nhttpd.conf | grep "^Language.selected=" | cut -d= -f2)
}
file2msg() # $1 = file to show; $2 = short description; $3 = maketable or empty
{
if [ -e $1 ]; then
echo "ok ($1 found)"
msg=$(cat $1)
if [ ! "$msg" ]; then
msg="no $2 available"
y_format_message_html
exit
fi
if [ "$3" == "maketable" ]; then
maketable $1
else
y_format_message_html
fi
else
echo "failed ($1 not found)"
fi
}
maketable() # $1 = file to format
{
# header
echo "<div class='work_box'><div class='work_box_head'>"
echo "<div class='work_box_head_h2'>Formatted results</div></div>"
echo "<div class='work_box_body' style='overflow: auto; font-family: monospace'>"
# body
echo "<table style='border: 0 none;'>"
while read _a _b _c _d _e _f _g _h _i _j _k _l _m _n _o _p
do
cat << eo_tbody
<tr>
<td>$_a</td>
<td>$_b</td>
<td>$_c</td>
<td>$_d</td>
<td>$_e</td>
<td>$_f</td>
<td>$_g</td>
<td>$_h</td>
<td>$_i</td>
<td>$_j</td>
<td>$_k</td>
<td>$_l</td>
<td>$_m</td>
<td>$_n</td>
<td>$_o</td>
<td>$_p</td>
</tr>
eo_tbody
done < $1
echo "</table>"
# footer
echo "</div>"
}
is_mount()
{
M=$1
test -e "$M" && cd "$M" && M=$(pwd -P)
while read _DEV _MTPT _FSTYPE _OPTS _REST
do
case "$M" in
"netfs")
if [ "$_FSTYPE" == "nfs" ] || [ "$_FSTYPE" == "cifs" ]; then
RET=0; break
else
RET=1; continue
fi
;;
"$_DEV"|"$_MTPT")
if [ "$_FSTYPE" == "autofs" ]; then
RET=1; continue
else
RET=0; break
fi
;;
*)
RET=1; continue
;;
esac
done < /etc/mtab
return $RET
}
is_exec()
{
F=$1
test -x $y_path_varbin/$F
return $?
}
is_running()
{
D=$1
pidof $D >/dev/null 2>&1
return $?
}
action=$1; shift
case "$action" in
getline)
FILE=$1
LINE=${2:-1}
if [ -f $FILE ]; then
tmp=$(sed -ne ''"${LINE}"'p' $FILE)
printf "%s" "$tmp"
fi
;;
is_exec)
FILE=$1
is_exec $FILE && printf "%s" "true" || printf "%s" "false"
;;
is_running)
DEAMON=$1
is_running $DEAMON && printf "%s" "true" || printf "%s" "false"
;;
get_update_txt)
version="n/a"
wget -O /tmp/NI_release.txt "http://neutrino-images.de/neutrino-images/release/release.txt"
test -e /tmp/NI_release.txt && version=$(cat /tmp/NI_release.txt | grep ".img" | cut -d" " -f2)
echo "version=${version// /}" > /tmp/NI_update.txt
rm -f /tmp/NI_release.txt
;;
rm_update_txt)
rm -f /tmp/NI_update.txt
;;
get_flash_info)
MTPT=""
case "$1" in
"var") MTPT="/var" ;;
"root"|*) MTPT="/" ;;
esac
df ${MTPT} | while read fs total used free used_percent mtpt; do
case ${mtpt} in
${MTPT})
used_percent=${used_percent//\%/}
free_percent=$(($free*100/$total))
total=$(($total/1024))
used=$(($used/1024))
free=$(($free/1024))
case $2 in
used_percent) printf "%d" "$used_percent";;
free_percent) printf "%d" "$free_percent";;
total) printf "%d" "$total";;
used) printf "%d" "$used";;
free) printf "%d" "$free";;
esac
break
;;
esac
done
;;
get_mem_info)
while read _desc _size _unit; do
case $_desc in
"MemTotal:") total=$_size ;;
"MemFree:") free=$_size ;;
"Buffers:") buffers=$_size ;;
"Cached:") cached=$_size ;;
esac
done < /proc/meminfo
free=$(($free+$buffers+$cached))
used=$(($total-$free))
#used_percent=$(($used*100/$total))
used_percent=$((($used*200+total)/2/$total))
free_percent=$(($free*100/$total))
total=$(($total/1024))
used=$(($used/1024))
free=$(($free/1024))
case $1 in
used_percent) printf "%d" "$used_percent";;
free_percent) printf "%d" "$free_percent";;
total) printf "%d" "$total";;
used) printf "%d" "$used";;
free) printf "%d" "$free";;
esac
;;
get_mtd_info)
while read dev size erasesize name; do
case ${dev:0:3} in
mtd)
test "$1" = "dev" && printf "%s<br/>" "$dev"
test "$1" = "name" && printf "%s<br/>" "${name//\"/}"
;;
esac
done < /proc/mtd
;;
get_cpu_info)
for i in 1 2; do
while read _cpu _user _nice _system _idle _rest; do
case $_cpu in
cpu)
case $i in
1)
fst_all=$(($_user + $_nice + $_system + $_idle))
fst_idle=$_idle
;;
2)
snd_all=$(($_user + $_nice + $_system + $_idle))
snd_idle=$_idle
;;
esac
;;
esac
done < /proc/stat
test $i = 1 && sleep 1
done
diff_all=$(($snd_all - $fst_all))
diff_idle=$(($snd_idle - $fst_idle))
_idle_percent=$(($diff_idle * 100 / $diff_all))
_used_percent=$((100 - $_idle_percent))
case $1 in
used_percent) printf "%s" "$_used_percent";;
esac
;;
# camd-control
#softcamstop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh stop;;
#softcamstart) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh start;;
softcamreset) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh reset;;
mgcamdstop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh mgcamd_stop;;
mgcamdstart) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh mgcamd_start;;
mgcamdreset) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh mgcamd_reset;;
gboxstop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh gbox_stop;;
gboxstart) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh gbox_start;;
gboxreset) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh gbox_reset;;
cs2gboxstop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh cs2gbox_stop;;
cs2gboxstart) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh cs2gbox_start;;
cs2gboxreset) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh cs2gbox_reset;;
osemustop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh osemu_stop;;
osemustart) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh osemu_start;;
osemureset) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh osemu_reset;;
oscamstop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh oscam_stop;;
oscamstart) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh oscam_start;;
oscamreset) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh oscam_reset;;
doscamstop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh doscam_stop;;
doscamstart) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh doscam_start;;
doscamreset) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh doscam_reset;;
newcsstop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh newcs_stop;;
newcsstart) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh newcs_start;;
newcsreset) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Camd-control.sh newcs_reset;;
vinfo)
if ! [ -x $y_path_varbin/$1 ]; then
printf "%s" "n/a"
exit
fi
CAM=$(echo $1 | tr [:lower:] [:upper:])
if [ "$CAM" = "GBOX" ]; then
CAM=GBOX.NET
fi
V=$($y_path_bin/vinfo $CAM $y_path_varbin/$1)
printf "%s" "${V//keine Informationen gefunden/}"
;;
# syntax file2msg file "short-description" (maketable)
mgshareinfo) file2msg /tmp/mgshare.info "n-lines" maketable;;
mginfo) file2msg /tmp/mg.info "cs-info" maketable;;
cccamdinfo) file2msg /tmp/cccamd.info "c-lines" maketable;;
cs2gboxinfo) file2msg /tmp/cs2gbox.info "cs2gbox-info";;
shareonl) file2msg /tmp/share.onl "online-share-info" maketable;;
shareinfo) file2msg /tmp/share.info "cs-info" maketable;;
sc01info) file2msg /tmp/sc01.info "slot1-info";;
sc02info) file2msg /tmp/sc02.info "slot2-info";;
ecminfo) file2msg /tmp/ecm.info "ecm-info";;
pidinfo) file2msg /tmp/pid.info "pid-info";;
oscamversion) file2msg /tmp/.oscam/oscam.version "oscam-info";;
doscamversion) file2msg /tmp/.doscam/doscam.version "doscam-info";;
get_oscam_webif_port)
if [ -e %(CONFIGDIR)/oscam.conf ]; then
_port=$(grep -m 1 -i "^[:space:]*httpport" %(CONFIGDIR)/oscam.conf | cut -d'=' -f2)
_port=$(echo $_port | dos2unix -u)
fi
printf "%s" ${_port:-8080}
;;
get_doscam_webif_port)
if [ -e %(CONFIGDIR)/doscam.cfg ]; then
_port=$(grep -m 1 -i "^[:space:]*httpport" %(CONFIGDIR)/doscam.cfg | cut -d'=' -f2)
_port=$(echo $_port | dos2unix -u)
fi
printf "%s" ${_port:-8080}
;;
get_xupnpd_webif_port)
if [ -e /share/xupnpd/xupnpd.lua ]; then
_port=$(grep -m 1 "^[:space:]*cfg.http_port" /share/xupnpd/xupnpd.lua | cut -d'=' -f2)
_port=$(echo $_port | dos2unix -u)
fi
printf "%s" $_port
;;
countcards)
getLanguage
if [ "$Y_LANG" == "Deutsch" ]
then
Y_L_count="Karten sind online."
Y_L_recount="können weitergegeben werden."
else
Y_L_count="cards online."
Y_L_recount="can be shared."
fi
FILE=$1
COUNT=0
_DIST=""
_LEV=""
if [ -f $FILE ]; then
COUNT=$(cat $FILE | wc -l | sed 's/^ *//')
echo "<b>$COUNT</b> $Y_L_count"
test $COUNT = 0 && exit
RECOUNT=$(cat $FILE | grep -v Lev:0 | wc -l | sed 's/^ *//')
echo "<b>$RECOUNT</b> $Y_L_recount"
for i in $(seq 0 9); do
DIST=$(cat $FILE | grep -H dist:$i | wc -l | sed 's/^ *//')
test $DIST = 0 || _DIST=$(echo -e "$_DIST\n\tDist. $i: $DIST")
done
for i in $(seq 0 9); do
LEV=$(cat $FILE | grep -H Lev:$i | wc -l | sed 's/^ *//')
test $LEV = 0 || _LEV=$(echo -e "$_LEV\n\tLevel $i: $LEV")
done
echo "<pre>$_LEV<br/>$_DIST</pre>"
else
echo "failed ($FILE not found)"
exit
fi
test $COUNT = 0 && echo "Es sind derzeit keine Karten online!"
;;
# zapit-control
resolution) pzapit --${1} && echo "ok" || echo "failed";;
43mode) pzapit -vm43 ${1} && echo "ok" || echo "failed";;
reload_channellists) pzapit -c && echo "ok" || echo "failed";;
reset_tuner) E=0
pzapit -esb; E=$(($E+$?)); sleep 1
pzapit -lsb; E=$(($E+$?)); sleep 1
pzapit -rz; E=$(($E+$?))
test $E = 0 && echo "ok" || echo "failed"
;;
# netfs-control
is_mount)
MTPT=$1
is_mount $MTPT && printf "%s" "true" || printf "%s" "false"
;;
do_mount_all)
msg=$(/etc/init.d/fstab start_netfs)
y_format_message_html
;;
do_umount_all)
msg=$(/etc/init.d/fstab stop_netfs)
y_format_message_html
;;
do_mount)
MTPT=$1
test $MTPT || exit 1
test -d $MTPT || mkdir -p $MTPT;
FLAG="/var/etc/.srv"
if OUT=$(mount $MTPT 2>&1 >/dev/null); then
RET=$?
msg="mount: $MTPT - success ($RET)"
test -e $FLAG || touch $FLAG
else
RET=$?
msg="mount: $MTPT - failed ($RET)<br>$OUT"
fi
y_format_message_html
;;
do_umount)
MTPT=$1
test $MTPT || exit 1
FLAG="/var/etc/.srv"
rm -f $FLAG
if OUT=$(umount $MTPT 2>&1 >/dev/null); then
RET=$?
msg="umount: $MTPT - success ($RET)"
else
RET=$?
msg="umount: $MTPT - failed ($RET)<br>$OUT"
fi
is_mount netfs && touch $FLAG
y_format_message_html
;;
# automounter-control
do_autofs)
case $1 in
start|stop|restart|reload)
msg=$(service autofs $1)
y_format_message_html
;;
esac
;;
# infoicons-control
rm_icons_flag)
while [ $1 ]; do
if [ -e $1 ]; then
rm -f $1 && echo "ok ($1 removed)<br />" || echo "failed (can't remove $1)<br />"
else
echo "nothing to do ($1 not found)<br />"
fi
shift
done
;;
touch_icons_flag)
while [ $1 ]; do
if [ ! -e $1 ]; then
touch $1 && echo "ok ($1 created)<br />" || echo "failed (can't create $1)<br />"
else
echo "nothing to do ($1 always exist)<br />"
fi
shift
done
;;
read_icons_flag)
test -z $1 && exit 1
test -e $1 && S=$(cat $1)
printf "%s" "$S"
;;
# plugin-control
p_fcm_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh fcm_start;;
p_fcm_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh fcm_stop;;
p_nfs_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh nfs_start;;
p_nfs_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh nfs_stop;;
p_smb_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh smb_start;;
p_smb_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh smb_stop;;
p_txc_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh txc_start;;
p_txc_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh txc_stop;;
p_txm_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh txm_start;;
p_txm_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh txm_stop;;
p_ina_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh ina_start;;
p_ina_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh ina_stop;;
p_drop_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh drop_start;;
p_drop_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh drop_stop;;
p_ush_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh ush_start;;
p_ush_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh ush_stop;;
p_djm_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh djm_start;;
p_djm_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh djm_stop;;
p_xud_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh xud_start;;
p_xud_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh xud_stop;;
p_cro_start) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh cro_start;;
p_cro_stop) %(PRIVATE_HTTPDDIR)/scripts/Y_NI_Plugin-control.sh cro_stop;;
# plugins on blue-button
p_show)
PLUGIN=$1
for PLUGIN_DIR in $PLUGIN_DIRS
do
cd $PLUGIN_DIR
test -w "$PLUGIN" || continue
echo "[$BNAME] modifying $PLUGIN_DIR/$PLUGIN"
sed -i "s/^\(hide=\).*$/\1"0"/" $PLUGIN
done
;;
p_hide)
PLUGIN=$1
for PLUGIN_DIR in $PLUGIN_DIRS
do
cd $PLUGIN_DIR
test -w "$PLUGIN" || continue
echo "[$BNAME] modifying $PLUGIN_DIR/$PLUGIN"
# fix for missing trailing linefeed in cfg-file
test "$(tail -c1 $PLUGIN)" != "" && echo "" >> $PLUGIN
if grep -q "^hide=" $PLUGIN
then
sed -i "s/^\(hide=\).*$/\1"1"/" $PLUGIN
else
echo "hide=1" >> $PLUGIN
fi
done
;;
p_list)
getLanguage
if [ "$Y_LANG" == "Deutsch" ]
then
Y_L_show="Anzeigen"
Y_L_hide="Verstecken"
else
Y_L_show="Show"
Y_L_hide="Hide"
fi
for PLUGIN_DIR in $PLUGIN_DIRS
do
test -e $PLUGIN_DIR || continue
cd $PLUGIN_DIR
PLUGINS=$(ls -1 *.cfg 2>/dev/null)
for PLUGIN in $PLUGINS
do
if [ "$1" == "lua" ]
then
# lua-plugins don't need the executable flag
test -e ${PLUGIN%%.*}.${1} || continue
else
test -x ${PLUGIN%%.*}.${1} || continue
fi
NAME=$(cat $PLUGIN | grep "^name=" | cut -d= -f2)
HIDE=$(cat $PLUGIN | grep "^hide=" | cut -d= -f2)
case $HIDE in
1)
IMG="<img src='images/x_red.png' class='status'>"
INP="<input type='button' value='$Y_L_show' onclick='Y_NI_Tools(\"p_show $PLUGIN\", 1000);' />"
;;
*)
IMG="<img src='images/check_green.png' class='status'>"
INP="<input type='button' value='$Y_L_hide' onclick='Y_NI_Tools(\"p_hide $PLUGIN\", 1000);' />"
;;
esac
cat << eoPLUGIN
<!-- $NAME -->
<tr class="list">
<td>
$IMG
<span title="$PLUGIN_DIR/${PLUGIN%%.*}.${1}">
$NAME
</span>
</td>
<td>
$INP
</td>
</tr>
eoPLUGIN
done
done
;;
*)
echo "[$BNAME] Parameter wrong: $action $*"
;;
esac

670
data/y-web/scripts/Y_Tools.sh Executable file
View File

@@ -0,0 +1,670 @@
#!/bin/sh
# -----------------------------------------------------------
# Tools (yjogol)
# $Date$
# $Revision$
# -----------------------------------------------------------
. ./_Y_Globals.sh
. ./_Y_Library.sh
# ===========================================================
# Settings : Styles
# ===========================================================
# -----------------------------------------------------------
# Style List
# -----------------------------------------------------------
style_get()
{
check_Y_Web_conf
active_style=$(config_get_value_direct $y_config_Y_Web 'style')
y_path_directory=$(config_get_value_direct $y_config_nhttpd 'WebsiteMain.directory')
y_path_override_directory=$(config_get_value_direct $y_config_nhttpd 'WebsiteMain.override_directory')
style_list=""
style_list="$style_list $(find $y_path_override_directory/styles -name 'Y_Dist-*')"
style_list="$style_list $(find $y_path_directory/styles -name 'Y_Dist-*')"
f_list=""
html_option_list=""
for f in $style_list
do
echo $f_list | grep ${f##*/}
if [ $? == 0 ]; then
continue
fi
f_list="$f_list ${f##*/}"
style=$(echo "$f" | sed -e s/^.*Y_Dist-//g | sed -e s/.css//g)
if [ "$style" = "$active_style" ]
then
sel="selected='selected'"
else
sel=""
fi
opt="<option value='$style' $sel>${style//_/ }</option>"
html_option_list="$html_option_list $opt"
done
echo "$html_option_list"
}
# -----------------------------------------------------------
# Set Style: override Y_Main.css $1=Style-Name
# -----------------------------------------------------------
style_set()
{
# This function should be called one time after installing a new image
# to get sure, the right skin is installed too
style=${1:-$(config_get_value_direct $y_config_Y_Web 'style')}
test -n "$style" || return
y_path_directory=$(config_get_value_direct $y_config_nhttpd 'WebsiteMain.directory')
y_path_override_directory=$(config_get_value_direct $y_config_nhttpd 'WebsiteMain.override_directory')
cd $y_path_directory
if [ -e $y_path_override_directory/styles/Y_Dist-$style.css ]; then
cp $y_path_override_directory/styles/Y_Dist-$style.css Y_Dist.css
elif [ -e $y_path_directory/styles/Y_Dist-$style.css ]; then
cp $y_path_directory/styles/Y_Dist-$style.css Y_Dist.css
else
config_set_value_direct $y_config_Y_Web 'style'
fi
}
# -----------------------------------------------------------
# Image Backup - build form
# -----------------------------------------------------------
image_upload()
{
if [ -s "$y_upload_file" ]
then
msg="<b>Image upload ok</b><br>"
msg="$msg <script language='JavaScript' type='text/javascript'>window.setTimeout('parent.do_image_upload_ready()',1000)</script>"
else
msg="Upload-Problem.<br>Please, try again."
msg="$msg <script language='JavaScript' type='text/javascript'>window.setTimeout('parent.do_image_upload_ready_error()',1000)</script>"
fi
y_format_message_html
}
# ===========================================================
# Flashimage
# ===========================================================
# -----------------------------------
# Flash-Backup ($1=mtd Nummer)
# -----------------------------------
image_backup_mtd()
{
rm /tmp/*.img
cat /dev/mtd/$1 > /tmp/flash_mtd$1.img
}
# -----------------------------------
# Sende Download-Page ($1=mtd Nummer)
# -----------------------------------
# -----------------------------------
image_delete_download_page()
{
rm -r /tmp/*.img
# msg="<div class='y_work_box'><b>The image file in tmp was extinguished.</b></div>"
# y_format_message_html
}
# -----------------------------------------------------------
# Flash ($1=mtd Nummer) Upload-File $2=true/false =simulate
# -----------------------------------------------------------
flash_mtd()
{
simulate="true"
if [ "$2" = "false" ]
then
simulate="false"
fi
rm /tmp/*.img
if [ -s "$y_upload_file" ]
then
echo "" >/tmp/e.txt
msg_nmsg "Image%20%20flashing!"
if [ "$simulate" = "false" ]
then
umount /hdd #yet: fixed setting
fcp -v "$y_upload_file" /dev/mtd/$1 >/tmp/e.txt
else #simulation/DEMO
i="0"
while test $i -le 10
do
p=`expr $i \* 10`
b=`expr $i \* 63`
b=`expr $b / 10`
echo -e "\rDEMO: Erasing blocks: $b/63 ($p%)" >>/tmp/e.txt
i=`expr $i + 1`
sleep 1
done
i="0"
while test $i -le 20
do
p=`expr $i \* 5`
b=`expr $i \* 8064`
b=`expr $b / 20`
echo -e "\rDEMO: Writing data: $b k/8064k ($p%)" >>/tmp/e.txt
i=`expr $i + 1`
sleep 2
done
i="0"
while test $i -le 5
do
p=`expr $i \* 20`
b=`expr $i \* 8064`
b=`expr $b / 5`
echo -e "\rDEMO: Verifying data: $b k/8064k ($p%)" >>/tmp/e.txt
i=`expr $i + 1`
sleep 1
done
fi
msg_nmsg "flashing%20ready.%20Reboot..."
msg="flashing done ... please reboot box now ..."
msg="$msg <script language='JavaScript' type='text/javascript'>window.setTimeout('parent.do_image_flash_ready()',1000)</script>"
y_format_message_html
if [ "$simulate" = "false" ]
then
busybox reboot -d10
fi
else
msg="Upload-Problem.<br>Try again, please."
msg="$msg <script language='JavaScript' type='text/javascript'>window.setTimeout('parent.do_image_flash_ready()',1000)</script>"
y_format_message_html
fi
}
# -----------------------------------------------------------
# copies Uploadfile to $1
# -----------------------------------------------------------
upload_copy()
{
if [ -s "$y_upload_file" ]
then
cp "$y_upload_file" "$1"
else
msg="Upload-Problem.<br>Try again, please."
fi
}
# -----------------------------------------------------------
bootlogo_upload()
{
msg="Boot-Logo installed"
upload_copy "$y_boot_logo"
y_format_message_html
}
# -----------------------------------------------------------
bootlogo_lcd_upload()
{
msg="Boot-Logo-LCD installed"
upload_copy "$y_boot_logo_lcd"
y_format_message_html
}
# -----------------------------------------------------------
zapit_upload()
{
msg="$1 hochgeladen<br><a href='/Y_Settings_zapit.yhtm'><u>next file</u></a>"
upload_copy "$y_path_zapit/$1"
y_format_message_html
}
# -----------------------------------------------------------
# Mount from Neutrino-Settings $1=nr
# -----------------------------------------------------------
do_mount()
{
config_open $y_config_neutrino
fstype=`config_get_value "network_nfs_type_$1"`
ip=`config_get_value "network_nfs_ip_$1"`
local_dir=`config_get_value "network_nfs_local_dir_$1"`
dir=`config_get_value "network_nfs_dir_$1"`
options1=`config_get_value "network_nfs_mount_options1_$1"`
options2=`config_get_value "network_nfs_mount_options2_$1"`
username=`config_get_value "network_nfs_username_$1"`
password=`config_get_value "network_nfs_password_$1"`
# check options
if [ "$options1" = "" ]
then
options1=options2
options2=""
fi
# default options
if [ "$options1" = "" ]
then
if [ "$options2" = "" ]
then
if [ "$fstype" = "0" ]
then
options1="soft"
options2="nolock"
fi
if [ "$fstype" = "1" ]
then
options1="ro"
fi
fi
fi
# build mount command
case "$fstype" in
0) #nfs
cmd="mount -t nfs $ip:$dir $local_dir -o $options1"
;;
1)
cmd="mount -t cifs $ip/$dir $local_dir -o username=$username,password=$password,unc=//$ip/$dir,$options1";
;;
2)
cmd="lufsd none $local_dir -o fs=ftpfs,username=$username,password=$password,host=$ip,root=/$dir,$options1";
;;
default)
echo "mount type not supported"
esac
if [ "$options2" != "" ]
then
cmd="$cmd,$options2"
fi
res=`$cmd`
echo "$cmd" >/tmp/mount.log
echo "$res" >>/tmp/mount.log
echo "$res"
echo "view mounts"
m=`mount`
msg="mount cmd:$cmd<br><br>res=$res<br>view Mounts;<br>$m"
y_format_message_html
}
# -----------------------------------------------------------
# unmount $1=local_dir
# -----------------------------------------------------------
do_unmount()
{
umount $1
}
# -----------------------------------------------------------
# AutoMount
# deactivate mount "#" replaces "---" and "=" replaced ",,"
# -----------------------------------------------------------
do_automount_list()
{
i="1"
sel="checked='checked'"
cat $1|sed /#/d|sed -n /-fstype/p|\
while read mountname options share
do
mountvalue=`echo "$mountname"|sed -e "s/#/---/g"`
echo "<input type='radio' name='R1' value='$mountvalue' $sel/>$i: $mountname ($share)<br/>"
sel=""
i=`expr $i + 1`
done
}
# -----------------------------------------------------------
do_automount_getline()
{
mountname=`echo "$2"|sed -e "s/---/#/g"`
cat $1|sed -n "/^[#]*$mountname[^a-zA-Z0-9]/p"
}
# -----------------------------------------------------------
# $1:filename, $2:mountname, $3-*:mountstring
# -----------------------------------------------------------
do_automount_setline()
{
if ! [ -e $1 ]; then
cp /etc/auto.net $1
fi
filename=$1
mountname=`echo "$2"|sed -e "s;---;;g"`
shift 2
mountset=`echo "$*"|sed -e "s;---;#;g" -e "s;,,;=;g"`
cp $filename "$filename.old"
chmod ou+rwss $filename
ex=`cat $filename|sed -n "/^$mountname[^a-zA-Z0-9].*$/p"`
if [ "$ex" = "" ]; then
echo "$mountset" >>$filename
else
tmp=`cat "$filename"|sed -e "s;^$mountname[^a-zA-Z0-9].*$;$mountset;g"`
echo "$tmp" >$filename
fi
kill -HUP `cat /var/run/automount.pid`
}
# -----------------------------------------------------------
# Execute shell command
# 1: directory 2: append [true|false] 3+: cmd
# -----------------------------------------------------------
do_cmd()
{
cd $1
pw1="$1"
app="$2"
shift 2
if [ "$1" = "cd" ]
then
cd $2
else
tmp=`$*` #Execute command
fi
pw=`pwd`
echo '<html><body><form name="o"><textarea name="ot">'
echo "$pw1>$*"
echo "$tmp"
echo '</textarea></form>'
echo '<script language="JavaScript" type="text/javascript">'
if [ "$app" = "true" ]
then
echo 'parent.document.co.cmds.value += document.o.ot.value;'
else
echo 'parent.document.co.cmds.value = document.o.ot.value;'
fi
echo "parent.set_pwd('$pw');"
echo 'parent.setCaretToEnd(parent.document.co.cmds);'
echo 'parent.document.f.cmd.focus();'
echo '</script></body></html>'
}
# -----------------------------------------------------------
# yInstaller
# un-tar uploaded file to /tmp. Execute included install.sh
# -----------------------------------------------------------
do_installer()
{
# clean up
if [ -s "$y_out_html" ]
then
rm $y_out_html
fi
if [ -s "$y_upload_file" ]
then
# unpack /tmp/upload.tmp
cd $y_path_tmp
tar -xf "$y_upload_file"
rm $y_upload_file
if [ -s "$y_install" ] #look for install.sh
then
chmod 755 $y_install
o=`$y_install` # execute
rm -f $y_install # clean up
if [ -s "$y_out_html" ] #html - output?
then
echo '<html><head>'
echo '<link rel="stylesheet" type="text/css" href="/Y_Main.css">'
echo '<link rel="stylesheet" type="text/css" href="/Y_Dist.css">'
echo '<link rel="stylesheet" type="text/css" href="/Y_User.css">'
echo "<meta http-equiv='refresh' content='0; $y_out_html'>"
echo '</head>'
echo "<body><a href='$y_out_html'>If automatic forwarding does not go.</a>"
echo '</body></html>'
# cat $y_out_html
else
echo '<html><head>'
echo '<link rel="stylesheet" type="text/css" href="/Y_Main.css">'
echo '<link rel="stylesheet" type="text/css" href="/Y_Dist.css">'
echo '<link rel="stylesheet" type="text/css" href="/Y_User.css">'
echo '</head>'
echo '<body>'
echo "$o"
echo '</body></html>'
fi
else
msg="$y_install not found"
y_format_message_html
fi
else
msg="Upload-Problem.<br>Try again, please."
y_format_message_html
fi
}
# -----------------------------------------------------------
# extention Installer $1=URL
# -----------------------------------------------------------
do_ext_installer()
{
if [ -e $y_upload_file ]; then
rm $y_upload_file
fi
wgetlog=`wget -O $y_upload_file $1 2>&1`
if [ -s "$y_upload_file" ];then
cd $y_path_tmp
tar -xf "$y_upload_file"
rm $y_upload_file
if [ -s "$y_install" ] #look for install.sh
then
chmod 755 $y_install
o=`$y_install` # execute
rm -f $y_install # clean up
echo "ok: wget=$wgetlog"
fi
else
e=`cat /tmp/err.log`
echo "error: $y_install not found. wget=$wgetlog $e"
fi
}
do_ext_uninstaller()
{
uinst="%(CONFIGDIR)/ext/uninstall.sh"
if [ -e "$uinst" ]; then
chmod 755 "$uinst"
`$uinst $1_uninstall.inc`
fi
}
# -----------------------------------------------------------
# view /proc/$1 Informations
# -----------------------------------------------------------
proc()
{
msg=`cat /proc/$1`
msg="<b>proc: $1</b><br><br>$msg"
y_format_message_html
}
# -----------------------------------------------------------
# wake up $1=MAC
# -----------------------------------------------------------
wol()
{
if [ -e $y_path_bin/ether-wake ]; then
msg=`ether-wake $1`
fi
msg="<b>Wake on LAN $1</b><br><br>$msg"
y_format_message_html
}
# -----------------------------------------------------------
# lcd shot
# $1= optionen | leer
# -----------------------------------------------------------
do_lcshot()
{
if [ -e "$y_path_varbin/lcshot" ]; then
$y_path_varbin/lcshot $*
else
$y_path_bin/lcshot $*
fi
}
# -----------------------------------------------------------
# osd shot
# $1= fb | dbox bzw. leer
# -----------------------------------------------------------
do_fbshot()
{
if [ "$1" = "fb" ]; then
shift 1
if [ -e "$y_path_varbin/fbshot" ]; then
$y_path_varbin/fbshot $*
else
fbshot $*
fi
else
shift 1
if [ -e "$y_path_varbin/dboxshot" ]; then
$y_path_varbin/dboxshot $*
else
dboxshot $*
fi
fi
}
# -----------------------------------------------------------
# delete fbshot created graphics
# -----------------------------------------------------------
do_fbshot_clear()
{
rm /tmp/*.bmp
rm /tmp/*.png
}
# -----------------------------------------------------------
# delete screenshots
# -----------------------------------------------------------
do_screenshot_clear()
{
rm -f /tmp/*.png
}
# -----------------------------------------------------------
# Settings Backup/Restore
# -----------------------------------------------------------
do_settings_backup_restore()
{
now=$(date +%Y-%m-%d_%H-%M-%S)
workdir="$y_path_tmp/y_save_settings/$now"
case "$1" in
backup)
rm -rf $workdir
mkdir -p $workdir
$y_path_bin/backup.sh $workdir >/dev/null
filename=$(ls -1 -tr $workdir/settings_* | tail -1)
echo "$filename"
;;
restore)
if [ -s "$y_upload_file" ]
then
msg=$($y_path_bin/restore.sh "$y_upload_file")
else
msg="error: no upload file"
fi
y_format_message_html
;;
esac
}
restart_neutrino()
{
echo "fixme"
# kill -HUP `pidof neutrino`
}
# -----------------------------------------------------------
# Main
# -----------------------------------------------------------
#debug
# echo "call:$*" >> "/tmp/debug.txt"
case "$1" in
style_set) style_set $2 ;;
style_get) style_get ;;
image_upload) image_upload ;;
image_backup) image_backup_mtd $2; echo "/tmp/flash_mtd$2.img" ;;
image_flash) shift 1; flash_mtd $* ;;
image_flash_free_tmp) rm -r /tmp/*.img ;;
image_delete) image_delete_download_page ;;
bootlogo_upload) bootlogo_upload ;;
bootlogo_lcd_upload) bootlogo_lcd_upload ;;
zapit_upload) zapit_upload $2 ;;
kernel-stack) msg=`dmesg`; y_format_message_html ;;
ps) msg=`ps aux`; y_format_message_html ;;
free) f=`free`; p=`df -h`; msg="RAM Memory use\n-------------------\n$f\n\nPartitions\n-------------------\n$p"
y_format_message_html ;;
yreboot) reboot; echo "Reboot..." ;;
check_yWeb_conf) check_Y_Web_conf ;;
rcsim) rcsim $2 >/dev/null ;;
domount) shift 1; do_mount $* ;;
dounmount) shift 1; do_unmount $* ;;
cmd) shift 1; do_cmd $* ;;
installer) shift 1; do_installer $* 2>&1 ;;
ext_uninstaller) shift 1; do_ext_uninstaller $* 2>&1 ;;
ext_installer) shift 1; do_ext_installer $* 2>&1 ;;
proc) shift 1; proc $* ;;
wol) shift 1; wol $* ;;
lcshot) shift 1; do_lcshot $* ;;
fbshot) shift 1; do_fbshot $* ;;
fbshot_clear) do_fbshot_clear ;;
screenshot_clear) do_screenshot_clear ;;
get_update_version) wget -O /tmp/version.txt "http://raw.github.com/tuxbox-neutrino/gui-neutrino/master/src/nhttpd/web/Y_Version.txt" ;;
settings_backup_restore) shift 1; do_settings_backup_restore $* ;;
exec_cmd) shift 1; $* ;;
automount_list) shift 1; do_automount_list $* ;;
automount_getline) shift 1; do_automount_getline $* ;;
automount_setline) shift 1; do_automount_setline $* ;;
restart_neutrino) restart_neutrino ;;
have_plugin_scripts) find %(PLUGINDIR_VAR) -name '*.sh' ;;
timer_get_tvinfo)
shift 1
rm -r /tmp/tvinfo.xml
res=$(wget -O /tmp/tvinfo.xml "http://www.tvinfo.de/share/openepg/schedule.php?username=$1&password=$2" 2>&1)
if ! [ -s /tmp/tvinfo.xml ]
then
res="$res File empty!"
fi
echo "$res"
;;
timer_get_klack)
config_open $y_config_Y_Web
url=`config_get_value "klack_url"`
klack_url=`echo "$url"|sed -e 's/;/\&/g'`
securitycode=`config_get_value "klack_securitycode"`
klack_url=`echo "$klack_url&secCode=$securitycode"`
wget -O /tmp/klack.xml "$klack_url" 2>&1 ;;
restart_sectionsd)
killall sectionsd
sectionsd >/dev/null 2>&1
msg="sectionsd reboot. ok."
y_format_message_html
;;
get_synctimer_channels)
if [ -e "$y_path_config/channels.txt" ]
then
cat $y_path_config/channels.txt
else
cat $y_path_httpd/channels.txt
fi
;;
get_extension_list)
if [ -e "$y_path_config/extentions.txt" ]
then
cat $y_path_config/extentions.txt
else
cat $y_path_httpd/extentions.txt
fi
;;
write_extension_list)
shift 1
echo "$*" >$y_path_config/extentions.txt
;;
url_get)
shift 1
res=`wget -O /tmp/$2 "$1" >/tmp/url.log 2>&1`
cat /tmp/$2
;;
mtd_space|var_space)
df | while read fs rest; do
case ${fs:0:3} in
mtd)
echo "$fs" "$rest"
break
;;
esac
done
;;
tmp_space)
df /tmp|grep /tmp
;;
# //NI
get_hostname)
echo -n $(hostname)
;;
*)
echo "[Y_Tools.sh] Parameter wrong: $*" ;;
esac

View File

@@ -0,0 +1,46 @@
#!/bin/sh
# -----------------------------------------------------------
# Y Globals (yjogol)
# $Date$
# $Revision$
# -----------------------------------------------------------
# -----------------------------------------------------------
# Definitions
# -----------------------------------------------------------
boxtype="coolstream"
# -----------------------------------------------------------
# Paths
# -----------------------------------------------------------
#y_path_httpd="%(PRIVATE_HTTPDDIR)"
y_path_httpd=".."
y_path_scripts="$y_path_httpd/scripts"
y_path_bin="/bin"
y_path_varbin="/var/bin"
y_path_sbin="/sbin"
y_path_config="%(CONFIGDIR)"
y_path_tmp="/tmp"
y_path_zapit="$y_path_config/zapit"
y_path_plugin_tuxnew="$y_path_config/tuxnews"
y_url_control="http://localhost/control"
# -----------------------------------------------------------
# Files
# -----------------------------------------------------------
y_config_Y_Web="$y_path_config/Y-Web.conf"
y_config_vnc="$y_path_config/vnc.conf"
y_config_nhttpd="$y_path_config/nhttpd.conf"
y_config_neutrino="$y_path_config/neutrino.conf"
y_upload_file="$y_path_tmp/upload.tmp"
y_boot_logo="/var/tuxbox/boot/logo-fb"
y_boot_logo_lcd="/var/tuxbox/boot/logo-lcd"
y_tmp="$y_path_tmp/y.tmp"
y_wait_live="$y_path_httpd/Y_Live_Wait.yhtm"
y_tmp_m3u="$y_path_tmp/y.m3u"
y_tmp_pls="$y_path_tmp/y.pls"
y_out_html="$y_path_tmp/y_out.yhtm"
y_install="$y_path_tmp/install.sh"

213
data/y-web/scripts/_Y_Library.sh Executable file
View File

@@ -0,0 +1,213 @@
#!/bin/sh
# -----------------------------------------------------------
# Y Library (yjogol)
# $Date$
# $Revision$
# -----------------------------------------------------------
# -----------------------------------------------------------
# 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="<html><head><meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>"
tmp="$tmp <link rel='stylesheet' type='text/css' href='/Y_Main.css'>"
tmp="$tmp <link rel='stylesheet' type='text/css' href='/Y_Dist.css'>"
tmp="$tmp <link rel='stylesheet' type='text/css' href='/Y_User.css'></head>"
tmp="$tmp <body><div class='work_box'><div class='work_box_head'><div class='work_box_head_h2'>Results</div></div><div class='work_box_body' style='overflow:auto'>"
tmp="$tmp <pre>\n$msg\n</pre></div></div></body></html>"
# tmp="$tmp <body><div class='y_work_box'><pre>\n$msg\n</pre></div></body></html>"
echo -e "$tmp"
}
y_format_message_html2()
{
tmp="<html><head><meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>"
tmp="$tmp <link rel='stylesheet' type='text/css' href='/Y_Main.css'>"
tmp="$tmp <link rel='stylesheet' type='text/css' href='/Y_Dist.css'>"
tmp="$tmp <link rel='stylesheet' type='text/css' href='/Y_User.css'></head>"
tmp="$tmp <body><div class='work_box'><div class='work_box_head'><div class='work_box_head_h2'>Results</div></div><div class='work_box_body'>"
tmp="$tmp $msg</div></div></body></html>"
echo "$tmp"
}
y_format_message_html_plain()
{
tmp="<html><head><meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>"
tmp="$tmp <link rel='stylesheet' type='text/css' href='/Y_Main.css'>"
tmp="$tmp <link rel='stylesheet' type='text/css' href='/Y_Dist.css'>"
tmp="$tmp <link rel='stylesheet' type='text/css' href='/Y_User.css'></head>"
tmp="$tmp <body>$msg</body></html>"
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 Y_Web.conf if does not exists
# -----------------------------------------------------------
check_Y_Web_conf()
{
if ! [ -e $y_config_Y_Web ]
then
echo "skin=Tuxbox" >$y_config_Y_Web
echo "slavebox=" >>$y_config_Y_Web
echo "live_resolution_w=384" >>$y_config_Y_Web
echo "live_resolution_wh=288" >>$y_config_Y_Web
fi
}

89
data/y-web/scripts/api.sh Executable file
View File

@@ -0,0 +1,89 @@
#!/bin/sh
# -----------------------------------------------------------
# API Script (yjogol)
# for yWeb independent shell calls
# $Date$
# $Revision$
# -----------------------------------------------------------
API_VERSION_MAJOR="1"
API_VERSION_MINOR="0"
API_VERSION_TEXT="$API_VERSION_MAJOR.$API_VERSION_MINOR"
#path_httpd="%(PRIVATE_HTTPDDIR)"
path_httpd=".."
path_scripts="$path_httpd/scripts"
path_bin="/bin"
path_varbin="/var/bin"
path_sbin="/sbin"
path_config="%(CONFIGDIR)"
path_tmp="/tmp"
streaming_client_status="$path_tmp/streaming_client"
# -----------------------------------------------------------
# udp control for neutrinoTV and yWeb LiveTV
do_udp_stream()
{
up="no"
if [ -e $path_varbin/udpstreamts ]; then
up="$path_varbin/udpstreamts"
else
if [ -e $path_sbin/udpstreamts ]; then
up="$path_sbin/udpstreamts"
fi
fi
case "$1" in
installed)
echo "$up" ;;
start)
shift 1
killall streamts
killall udpstreamts
echo $* > $streaming_client_status
trap "" 1;$up $* &
;;
stop)
killall udpstreamts
rm $streaming_client_status
echo "ok"
;;
kill_all_streams)
killall streamts
killall streampes
killall udpstreamts
rm $streaming_client_status
echo "ok"
;;
esac
}
# -----------------------------------------------------------
# Main
# -----------------------------------------------------------
case "$1" in
version)
echo $API_VERSION_TEXT ;;
udp_stream)
shift 1
do_udp_stream $*
;;
streaming_status)
if [ -e $streaming_client_status ]; then
cat $streaming_client_status
else
echo "Streams: "
ps | grep stream | grep -v grep | grep -v sh | cut -d " " -f 15
fi
;;
streaming_lock)
shift 1
echo $* > $streaming_client_status # first parameter should always be the ip of the client
echo "ok"
;;
streaming_unlock)
rm $streaming_client_status
echo "ok"
;;
*)
echo "[api.sh] Parameter wrong: $*" ;;
esac