Browse files

Refactored update_cmdline() with updated curl 7.27.0

  • Loading branch information...
1 parent e7eb33a commit a9cf9ab1630b5b07624ddd6c7e42997ece7f3d26 @kaihendry kaihendry committed Oct 4, 2012
Showing with 10 additions and 26 deletions.
  1. +9 −25 etc/webc/live-config.sh
  2. +1 −1 etc/webc/webc.conf
  3. BIN usr/bin/curl
  4. BIN usr/lib/libcurl.so.4.2.0
View
34 etc/webc/live-config.sh
@@ -127,32 +127,15 @@ sub_literal 'var aboutwebc = "";' "var aboutwebc = \"$(echo ${install_qa_url} |
} # end of process_options
update_cmdline() {
- SECONDS=0
- while true
- do
- wget --timeout=5 -t 1 -q -O /etc/webc/cmdline.tmp "$config_url" && break
- test $? = 8 && break # 404
- test $SECONDS -gt 15 && break
- logs "Failed to download configuration, trying again..."
- sleep 1
- done
-
- # A configuration file always has a homepage
- if ! [ -e "/etc/webc/cmdline.tmp" ] || ! grep -qs homepage /etc/webc/cmdline.tmp
+ if curl -f -o /etc/webc/cmdline.tmp --retry 5 "$config_url"
then
- # No (valid) file downloaded, just keep running with
- # what we have
- logs "Failed to download (valid) configuration, using existing config"
- return
+ # curl has a bug where it doesn't write an empty file
+ touch /etc/webc/cmdline.tmp
+ # This file can be empty in the case of an invalidated configuration
+ mv /etc/webc/cmdline.tmp /etc/webc/cmdline
+ # Replace persistent copy
+ cp /etc/webc/cmdline /live/image/live/webc-cmdline
fi
-
- # Apply the new config
- mv /etc/webc/cmdline.tmp /etc/webc/cmdline
-
- # Copy the cmdline outside to a persistent spot, in case we
- # can't reach the config server on next boot and to allow
- # detecting changes in the config.
- cp /etc/webc/cmdline /live/image/live/webc-cmdline
}
wait_for $live_config_pipe 2>/dev/null
@@ -163,7 +146,8 @@ wait_for $live_config_pipe 2>/dev/null
# copy that to /etc/webc, so we can compare the new version with
# it to detect changes and/or use it in case the new download
# fails.
-if [ -e "/live/image/live/webc-cmdline" ]; then
+if test -s /live/image/live/webc-cmdline
+then
cp /live/image/live/webc-cmdline /etc/webc/cmdline
else
touch /etc/webc/cmdline
View
2 etc/webc/webc.conf
@@ -20,5 +20,5 @@ config_url="${install_base_url}/install-config/${webc_id}"
# triggers live-config.sh - this gets config from config.webconverger.com
live_config_pipe="/tmp/live-config.pipe" # needs to be writable by xinitrc
-# trigger /etc/etc/webc/upgrade.sh
+# triggering upgrade.sh from live-config.sh atm
upgrade_pipe="/tmp/upgrade.pipe"
View
BIN usr/bin/curl
Binary file not shown.
View
BIN usr/lib/libcurl.so.4.2.0
Binary file not shown.

0 comments on commit a9cf9ab

Please sign in to comment.