"
# 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 "
y_format_message_html
if [ "$simulate" = "false" ]
then
busybox reboot -d10
fi
else
msg="Upload-Problem. Try again, please."
msg="$msg "
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. 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 next file"
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="ro,soft,udp"
options2="nolock,rsize=8192,wsize=8192"
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
res=$res view Mounts; $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 "$i: $mountname ($share) "
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 ''
echo ''
}
# -----------------------------------------------------------
# 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 ''
echo ""
echo "If automatic forwarding does not go."
echo ''
# cat $y_out_html
else
echo ''
echo ''
echo "$o"
echo ''
fi
else
msg="$y_install not found"
y_format_message_html
fi
else
msg="Upload-Problem. 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="/var/tuxbox/config/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="proc: $1
$msg"
y_format_message_html
}
# -----------------------------------------------------------
# wake up $1=MAC
# -----------------------------------------------------------
wol()
{
if [ -e /bin/ether-wake ]; then
msg=`ether-wake $1`
fi
msg="Wake on LAN $1