summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Schmelzer2009-06-09 21:22:30 +0200
committerSebastian Schmelzer2009-06-09 21:22:30 +0200
commit467c466b7121a6c2fc62e5de1e538f3b1d95d562 (patch)
tree36c6aa3aad54ba84b741d709d06147b7dd31ea9b
parent* oops - should never have been checked in of course - thanks Michael. (diff)
downloadcore-467c466b7121a6c2fc62e5de1e538f3b1d95d562.tar.gz
core-467c466b7121a6c2fc62e5de1e538f3b1d95d562.tar.xz
core-467c466b7121a6c2fc62e5de1e538f3b1d95d562.zip
add dialog based download script to preboot-scripts
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2946 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r--boot-env/preboot/preboot-scripts/dialog.functions81
1 files changed, 81 insertions, 0 deletions
diff --git a/boot-env/preboot/preboot-scripts/dialog.functions b/boot-env/preboot/preboot-scripts/dialog.functions
new file mode 100644
index 00000000..a9e76bdd
--- /dev/null
+++ b/boot-env/preboot/preboot-scripts/dialog.functions
@@ -0,0 +1,81 @@
+# Copyright (c) 2009 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# dialog.functions
+# provides shell scripts for dialog handling
+# -----------------------------------------------------------------------------
+
+# set -x
+
+if [ "x" == "x$DIALOG_HEIGHT" ]; then
+ DIALOG_HEIGHT="10"
+fi
+
+if [ "x" == "x$DIALOG_WIDTH" ]; then
+ DIALOG_WIDTH="40"
+fi
+
+_ddownload_checkpercentage () {
+ local lf=$1
+ percentage=$(tail -n 5 $lf | sed 's/\.//g' | awk '{print $2}'| sed -n "s/%//p"| tail -n 1)
+ return $percentage
+}
+
+ddownload () {
+ local dl_url=$1
+ local dl_titel=$2
+ local dl_outfile=$3
+ local dl_logfile=$4
+
+ local dl_server=$(dirname $dl_url)
+ local dl_file=$(basename $dl_url)
+
+ local dl_count
+
+ if [ "x" == "x$dl_logfile" ]; then
+ dl_logfile="/tmp/logfile.$$"
+ fi
+
+ if [ "x" == "x$dl_outfile" ]; then
+ dl_outfile="$dl_file"
+ fi
+
+ if [ "x" == "x$dl_title" ]; then
+ dl_title="Downloading $dl_file .."
+ fi
+
+ if [ -f "$dl_logfile" ]; then
+ rm $dl_logfile
+ fi
+
+ # start wget in background
+ wget -v -b $dl_url -o "$dl_logfile" -O $dl_outfile
+
+ sleep 0.1;
+ _ddownload_checkpercentage "$dl_logfile"
+
+ dl_count=$?
+
+ while [ $dl_count -le 99 ];
+ do
+ echo $dl_count |dialog --gauge "$dl_title" $DIALOG_HEIGHT $DIALOG_WIDTH
+ sleep 0.5
+ _ddownload_checkpercentage "$dl_logfile"
+ dl_count=$?
+ done
+
+ local finished=0
+ while [ ! $finished ]; do
+ finished=$(tail -n 4 $dl_logfile | grep -c "$dl_file");
+ done
+
+ echo 100 | dialog --gauge "$dl_title" $DIALOG_HEIGHT $DIALOG_WIDTH;
+
+}