- yWeb: add boxinfo extention source

This commit is contained in:
svenhoefer
2014-08-25 11:06:48 +02:00
committed by [CST] Focus
parent 7589a3a9e0
commit 54ac45384a
6 changed files with 545 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
# ===========================================================
# yWeb SDK: Extention Unnstaller Include
# Extention Name: boxinfo
# by yjogol
# -----------------------------------------------------------
# $Date: 2007-12-29 17:08:16 $
# $Revision: 1.2 $
# ===========================================================
yI_updatename="yWeb-Extension boxinfo (08.01.2008)"
yI_Ext_Tag="boxinfo"
yI_Ext_Version="1-0-1"
yI_uninstall_log="$y_path_tmp/uninstall_boxinfo.log"
yI_uninstaller="boxinfo_uninstall.inc"
uninstall()
{
rm $y_ywebover_dir/Y_Ext_BoxInfo.yhtm
rm $y_ywebover_dir/scripts/Y_Ext_BoxInfo.sh
}

View File

@@ -0,0 +1,150 @@
{=include-block:Y_Blocks.txt;head=}
<link rel="STYLESHEET" type="text/css" href="/ywidget.css"/>
<script type="text/javascript" src="/Y_Baselib.js"></script>
<script type="text/javascript" src="/prototype.js"></script>
<script type="text/javascript">
//<![CDATA[
function dbox_exec_bi(_cmd)
{
var __cmd = _cmd.replace(/ /g, "&");
return loadSyncURL("/control/exec?Y_Ext_BoxInfo&"+__cmd);
}
function dbox_exec_bi2(_cmd)
{
var __cmd = _cmd.replace(/ /g, "&");
var res=loadSyncURL("/control/exec?Y_Ext_BoxInfo&"+__cmd);
return res.gsub("\n","<br/>")
}
function do_start()
{
$('statusline').show();
do_mem();
}
function str2A(_str)
{
_str=_str.strip();
_str=_str.replace(/[\t\n]/gi," ");
_str=_str.replace(/[ ]+/gi," ");
return _str.split(" ");
}
function do_mem()
{
var yfree=dbox_exec_bi('free');
yfree=yfree.strip();
yfree = yfree.replace(/[\t\n]/gi,"");
yfree = yfree.replace(/[ ]+/gi," ");
var yfreeA=yfree.split(" ");
$('mtotal').update(yfreeA[6]);
$('mused').update(yfreeA[7]);
$('mfree').update(yfreeA[8]);
$('mswap').update(yfreeA[13]);
$('status').update("getting hardware information");
window.setTimeout("do_hardware()",100)
}
function do_hardware()
{
var res=dbox_exec_bi('avia_version');
$('aviachip').update(res);
$('box').update(dbox_exec_bi('tuxinfo -M'));
$('model').update(dbox_exec_bi('tuxinfo -V'));
var res=dbox_exec_bi('i2c');
var i2cA=res.split("\t");
$('i2c').update(i2cA[2]);
$('avswitch').update(split_left(dbox_exec_bi('avswitch')," "));
var resA=str2A(dbox_exec_bi('cpuinfo'));
$('cpu').update(resA[5]);
$('cpuclock').update(resA[8]);
$('bongomips').update(resA[21]);
$('fb').update(dbox_exec_bi('fb'));
$('status').update("getting OS and Software information");
window.setTimeout("do_sw()",100)
}
function do_sw()
{
// $('linux').update(dbox_exec_command('cat /proc/version'));
$('os').update(dbox_exec_bi('uname -s'));
$('kernel').update(dbox_exec_bi('uname -r'));
$('kerneldate').update(dbox_exec_bi('uname -v'));
$('arch').update(dbox_exec_bi('uname -m'));
var res=dbox_exec_bi('busybox_help');
$('busybox').update(split_left(res,"\n"));
$('busyboxcmd').update(split_right(res,"functions:\n"));
var res=dbox_exec_bi('proc_version');
$('status').update("Filesystem information");
window.setTimeout("do_fs()",100)
}
function do_fs()
{
$('mounts').update(dbox_exec_bi2('do_proc mounts'));
$('mtd').update(dbox_exec_bi('do_proc mtd').gsub("\n","<br/>"));
var res=dbox_exec_bi('do_proc filesystems');
res=res.gsub("nodev","");
res=res.strip();
res=res.gsub("\n",",");
$('filesystems').update(res);
$('mods').update(dbox_exec_bi2('do_proc modules'));
$('statusline').hide();
}
//]]>
</script>
<style>
.line {border-bottom: 1px solid #6D96A9;font-weight:bold}
.y_form tr {vertical-align:top;}
</style>
</head>
<body>
<div class="work_box">
<div class="work_box_head">
<div class="work_box_head_h2">{=var-set:help_url=Help-Extensions-boxinfo=}{=var-set:menu=Box Information [1.0.1]=}{=include-block:Y_Blocks.txt;work_menu=}</div></div>
<div class="work_box_body">
<div id="statusline"><img border="0" src="/images/wait.gif" width="20" height="20" alt="wait"/>
<span id="status">getting memory information</span></div>
<table class="y_form" cellpadding="1" width="100%" style="margin-right:20px">
<tr><td class="y_form_header" colspan="2">Speicher</td></tr>
<tr><td>total:</td><td><span id="mtotal">...</span></td></tr>
<tr><td>used:</td><td><span id="mused">...</span></td></tr>
<tr><td>free:</td><td><span id="mfree">...</span></td></tr>
<tr><td>swap:</td><td><span id="mswap">...</span></td></tr>
<tr><td class="y_form_header" colspan="2">Hardware</td></tr>
<tr><td>avia chip:</td><td><span id="aviachip">...</span></td></tr>
<tr><td>AV chip:</td><td><span id="avswitch">...</span></td></tr>
<tr><td>i2c:</td><td><span id="i2c">...</span></td></tr>
<tr><td>CPU:</td><td><span id="cpu">...</span></td></tr>
<tr><td>CPU Clock:</td><td><span id="cpuclock">...</span></td></tr>
<tr><td>bongomips:</td><td><span id="bongomips">...</span></td></tr>
<tr><td>Box:</td><td><span id="box">...</span></td></tr>
<tr><td>Hersteller:</td><td><span id="model">...</span></td></tr>
<tr><td>Framebuffer:</td><td><span id="fb">...</span></td></tr>
<tr><td class="y_form_header" colspan="2">OS &amp; Software</td></tr>
<tr><td>OS:</td><td><span id="os">...</span></td></tr>
<tr><td>Kernel:</td><td><span id="kernel">...</span></td></tr>
<tr><td>Kernel Date:</td><td><span id="kerneldate">...</span></td></tr>
<tr><td>Architecture:</td><td><span id="arch">...</span></td></tr>
<tr><td>Busybox Version:</td><td><span id="busybox">...</span></td></tr>
<tr><td>Busybox Commands:</td><td><span id="busyboxcmd">...</span></td></tr>
<tr><td class="y_form_header" colspan="2">Filesystem &amp; Modules</td></tr>
<tr><td>Mounts:</td><td><span id="mounts">...</span></td></tr>
<tr><td>mtd:</td><td><span id="mtd">...</span></td></tr>
<tr><td>filesystems:</td><td><span id="filesystems">...</span></td></tr>
<tr><td>modules &amp; dependencies:</td><td><span id="mods">...</span></td></tr>
</table>
</div>
</div>
<script type="text/javascript">
//<![CDATA[
window.setTimeout("do_start();",500);
//]]>
</script>
</body>
</html>

View File

@@ -0,0 +1,76 @@
#!/bin/sh
# -----------------------------------------------------------
# BoxInfo (yjogol)
# $Date: 2007-12-29 17:08:16 $
# $Revision: 1.1 $
# -----------------------------------------------------------
do_line()
{
echo "------------------------------------------------------------------------------------"
}
do_dline()
{
echo "===================================================================================="
}
do_header()
{
do_line
echo " $1"
do_line
}
do_proc()
{
do_header "$1"
cat /proc/$2
}
do_cmd()
{
do_header "$1"
shift 1
$*
}
case "$1" in
# $2=l (long)
proc)
do_proc Kernel version
if [ "$2" == "l" ]; then
do_proc CPU cpuinfo
do_proc 'Memory usage overview' meminfo
do_proc Partitions partitions
do_proc 'mtd list' mtd
do_proc 'installed Filesystems' filesystems
do_proc 'loaded modules' modules
do_proc 'system uptime' uptime
do_cmd "kernel stack" dmesg
fi
do_cmd 'free space' df
do_cmd 'running processes' ps
do_cmd 'busybox version and installed commands' busybox --help
if [ "$2" == "l" ]; then
do_cmd 'Commands in /bin' ls /bin
do_cmd 'Commands in /sbin' ls /sbin
do_cmd 'mounts' cat /etc/fstab
if [ -e /etc/smb.conf ]; then
do_cmd 'Samba Server configuration' cat /etc/smb.conf
fi
if [ -e /etc/auto.net ]; then
do_cmd 'auto mounter configuration' cat /etc/auto.net
fi
fi
;;
avia_version) cat /proc/bus/avia_version ;;
tuxinfo) shift 1; tuxinfo $* ;;
i2c) cat /proc/bus/i2c ;;
free) free ;;
avswitch) /bin/switch ;;
cpuinfo) cat /proc/cpuinfo ;;
fb) cat /proc/fb ;;
uname) shift 1; uname $* ;;
busybox_help) busybox --help ;;
proc_version) cat /proc/version ;;
do_proc) cat /proc/$2 ;;
*)
echo "[Y_BoxInfo.sh] Parameter falsch: $*" ;;
esac

View File

@@ -0,0 +1,20 @@
# ===========================================================
# yWeb SDK: Extention Installer Include
# Extention Name: boxinfo
# by yjogol
# -----------------------------------------------------------
# $Date: 2007-12-29 10:11:37 $
# $Revision: 1.1 $
# ===========================================================
yI_updatename="yWeb-Extension boxinfo (08.01.2008)"
yI_Ext_Tag="boxinfo"
yI_Ext_Version="1-0-1"
yI_install_log="$y_path_tmp/install_boxinfo.log"
yI_uninstaller="boxinfo_uninstall.sh"
install()
{
cp -r /tmp/files/httpd/* $y_ywebover_dir
chmod 755 $y_ywebover_dir/scripts/*.sh
}

View File

@@ -0,0 +1,143 @@
# ===========================================================
# yWeb Extension: Install an Extension
# by yjogol
# -----------------------------------------------------------
# $Date: 2007-12-29 10:11:37 $
# $Revision: 1.3 $
# -----------------------------------------------------------
# Script starts in /tmp
# ===========================================================
# -----------------------------------------------------------
# Installer Configs
# -----------------------------------------------------------
yI_Version="$Revision: 1.3 $"
# -----------------------------------------------------------
# Dirs
# -----------------------------------------------------------
y_path_usrbin="/var/bin"
y_path_config="/var/tuxbox/config"
y_path_tmp="/tmp"
y_ywebover_dir="/var/httpd"
y_ext_conf_dir="$y_path_config/ext"
# -----------------------------------------------------------
# Files
# -----------------------------------------------------------
y_config_Y_Web="$y_path_config/Y-Web.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"
# ===========================================================
# 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
}
# ===========================================================
# Initialization
# ===========================================================
. ./install.inc
hp=`config_get_value_direct "$y_config_nhttpd" "WebsiteMain.override_directory"`
if [ "$hp" != "" ]; then
y_ywebover_dir=`echo "$hp"`
fi
mkdir -p $y_ywebover_dir
chmod -R oug+rw $y_ywebover_dir
# -----------------------------------------------------------
# prepare log
# -----------------------------------------------------------
date +%y%m%d_%H%M%S >"$yI_install_log"
echo "" >>yI_install_log
echo "installing $yI_updatename [$yI_Ext_Tag/$yI_Ext_Version]" >>"yI_install_log"
echo "installdir: $y_ywebover_dir"
# -----------------------------------------------------------
# Install (from install.inc)
# -----------------------------------------------------------
install
# -----------------------------------------------------------
# finishing
# -----------------------------------------------------------
mkdir -p $y_ext_conf_dir
chmod oug+rw $y_ext_conf_dir
chmod 755 ./uninstall*
cp ./uninstall.sh "$y_ext_conf_dir/"
cp ./*uninstall.inc "$y_ext_conf_dir/"
# -----------------------------------------------------------
# Clean Up
# -----------------------------------------------------------
cd /tmp
rm -r /tmp/files

View File

@@ -0,0 +1,136 @@
# ===========================================================
# yWeb Extension: Unnstall an Extension
# by yjogol
# -----------------------------------------------------------
# $Date: 2007-12-29 17:08:16 $
# $Revision: 1.4 $
# -----------------------------------------------------------
# Script starts in /tmp
# ===========================================================
# -----------------------------------------------------------
# Installer Configs
# -----------------------------------------------------------
yI_Version="$Revision: 1.4 $"
# -----------------------------------------------------------
# Dirs
# -----------------------------------------------------------
y_path_usrbin="/var/bin"
y_path_config="/var/tuxbox/config"
y_path_tmp="/tmp"
y_ywebover_dir="/var/httpd"
y_ext_conf_dir="$y_path_config/ext"
# -----------------------------------------------------------
# Files
# -----------------------------------------------------------
y_config_Y_Web="$y_path_config/Y-Web.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"
# ===========================================================
# 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
}
# ===========================================================
# Initialization
# ===========================================================
. $y_ext_conf_dir/$1
hp=`config_get_value_direct "$y_config_nhttpd" "WebsiteMain.override_directory"`
if [ "$hp" != "" ]; then
y_ywebover_dir=`echo "$hp"`
fi
mkdir -p $y_ywebover_dir
# -----------------------------------------------------------
# prepare log
# -----------------------------------------------------------
date +%y%m%d_%H%M%S >"$yI_uninstall_log"
echo "" >>"$yI_uninstall_log"
echo "uninstalling $yI_updatename [$yI_Ext_Tag/$yI_Ext_Version]" >>"$yI_uninstall_log"
#echo "installdir: $y_ywebover_dir"
# -----------------------------------------------------------
# Uninstall (from uninstal_<tag>.inc)
# -----------------------------------------------------------
uninstall
# -----------------------------------------------------------
# finishing
# -----------------------------------------------------------
rm $y_ext_conf_dir/$1
# -----------------------------------------------------------
# Clean Up
# -----------------------------------------------------------