summaryrefslogtreecommitdiffstats
path: root/remote/rootfs
diff options
context:
space:
mode:
authorSimon Rettberg2013-08-22 12:11:21 +0200
committerSimon Rettberg2013-08-22 12:11:21 +0200
commit7199f8b6f00dbc904c92b6bfe1bad8d99c78c083 (patch)
tree48352a608c7ef2c0a9fa48af6d69987e986186bf /remote/rootfs
parent[rootfs-stage31] Make MAC addresses lowercase, as udev fails to match a rule ... (diff)
downloadtm-scripts-7199f8b6f00dbc904c92b6bfe1bad8d99c78c083.tar.gz
tm-scripts-7199f8b6f00dbc904c92b6bfe1bad8d99c78c083.tar.xz
tm-scripts-7199f8b6f00dbc904c92b6bfe1bad8d99c78c083.zip
[rootfs-stage31] Make download timeouts shorter, properly use drop_shell in the calling function/context, not in download()
Diffstat (limited to 'remote/rootfs')
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/bin/setup_stage322
-rw-r--r--remote/rootfs/rootfs-stage31/data/etc/functions.inc47
2 files changed, 24 insertions, 25 deletions
diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32
index bc00b830..cf20fbf5 100755
--- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32
+++ b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32
@@ -34,7 +34,7 @@ STAGE32_TARGET_PATH="/stage32.sqfs"
STAGE32_MOUNT_POINT="/rorootfs"
# try to download it
-download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || return 1
+download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || drop_shell "Could not download stage32!"
# try to mount it at STAGE32_MOUNT_POINT
echo "Mounting stage 3.2 as SquashFS..."
diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions.inc b/remote/rootfs/rootfs-stage31/data/etc/functions.inc
index 362943ae..ce510aac 100644
--- a/remote/rootfs/rootfs-stage31/data/etc/functions.inc
+++ b/remote/rootfs/rootfs-stage31/data/etc/functions.inc
@@ -11,9 +11,9 @@
# drop_shell "This is your error message."
#
drop_shell() {
- [ $# -gt 0 ] && echo $@
- echo "CTRL + D will continue booting."
- setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
+ [ $# -gt 0 ] && echo $@
+ echo "CTRL + D will continue booting."
+ setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
}
#########################################################################
@@ -28,7 +28,7 @@ read_from_cmdline(){
local OPTION="$1"
local VALUE=""
-
+
VALUE="$(grep -o -E "${OPTION}=\S+" /proc/cmdline | cut -c $((${#OPTION}+2))-)"
if [ -z "$VALUE" ]; then
echo "Error - '${OPTION}=' not found in command line, or empty"
@@ -40,7 +40,7 @@ read_from_cmdline(){
#########################################################################
#
-# Helper function to download given FILE_URL from servers in 'slxsrv'
+# Helper function to download given FILE_URL from servers in 'slxsrv'
# as given through the kernel command line. File will be saved under TARGET_PATH
#
# Usage:
@@ -53,8 +53,8 @@ read_from_cmdline(){
# FILE_URL can have subpath, e.g. "ubuntu-13.04-x64/config"
#
download() {
- [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1
-
+ [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1
+
if [ -e "${FUTURE_ROOT}/opt/openslx/config" ]; then
. "${FUTURE_ROOT}/opt/openslx/config" || echo "Error - could not source '${FUTURE_ROOT}/opt/openslx/config'"
else
@@ -62,31 +62,30 @@ download() {
SLX_KCL_SERVERS="$(read_from_cmdline "slxsrv" | tr ',' ' ')"
echo "SLX_KCL_SERVERS='$SLX_KCL_SERVERS'" >> "${FUTURE_ROOT}/opt/openslx/config"
fi
-
- local FILE_URL="$1"
- local TARGET_PATH="$2"
-
+
+ local FILE_URL="$1"
+ local TARGET_PATH="$2"
+
+ # Shuffle server list
local SERVERS=$(for SERVER in $SLX_CONFIG_SERVERS $SLX_KCL_SERVERS; do echo "$RANDOM $SERVER"; done | sort -u | sed -r 's/^[0-9]+ //')
-
- for TIMEOUT in 1 2 3 4 5; do
+
+ for TIMEOUT in 1 1 4 4 10; do
for SERVER in $SERVERS; do
+ rm -f "$TARGET_PATH"
wget -T 5 -q -O "$TARGET_PATH" "http://${SERVER}/${FILE_URL}"
RET=$?
- if [ "x$RET" != "x0" ]; then
+ if [ "x$RET" != "x0" -o ! -e "$TARGET_PATH" ]; then
echo "Error - downloading 'http://$SERVER/$FILE_URL' via wget failed. Exit Code: $RET"
- echo "Trying again in $(($TIMEOUT * 500)) ms..."
- [ $TIMEOUT -eq 5 ] && drop_shell "Max timeouts reached. Dropping shell..."
- usleep $(($TIMEOUT * 500000))
+ usleep 50000 # 50ms
else
- [ "x$DEBUG" != "x" ] && echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'."
+ echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'."
return 0
fi
done
+ echo "Trying again in $(($TIMEOUT * 250)) ms..."
+ usleep $(($TIMEOUT * 250000))
done
-
- # check if it actually worked
- if [ ! -e $TARGET_PATH ]; then
- echo "Error - $TARGET_PATH does not exists. Downloading '$FILE_URL' from '$SERVER_LIST' failed."
- return 1
- fi
+ # Max retries reached, no success :-(
+ return 1
}
+