+check_url() {
+ if [[ $DOWNLOADER_NAME == 'wget' ]]; then
+ if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then
+ return 0
+ else
+ return 1
+ fi
+ elif [[ $DOWNLOADER_NAME == 'curl' ]]; then
+ code=`curl -sL -w "%{http_code}\\n" "$1" -o /dev/null`
+ if [[ $code -eq 200 ]]; then return 0; else return 1; fi
+ else
+ $ECHO "error: wget or curl required in check_url"
+ exit_script 12
+ fi
+}
+
+# If we are on a branch, first try to get a boot image for that branch.
+# Otherwise, just use `master`
+set_boot_image_vars() {
+ set_current_branch
+ url="http://downloads.factorcode.org/images/${CURRENT_BRANCH}/checksums.txt"
+ check_url $url
+ if [[ $? -eq 0 ]]; then
+ CHECKSUM_URL="http://downloads.factorcode.org/images/${CURRENT_BRANCH}/checksums.txt"
+ BOOT_IMAGE_URL="http://downloads.factorcode.org/images/${CURRENT_BRANCH}/${BOOT_IMAGE}"
+ else
+ CHECKSUM_URL="http://downloads.factorcode.org/images/master/checksums.txt"
+ BOOT_IMAGE_URL="http://downloads.factorcode.org/images/master/${BOOT_IMAGE}"
+ fi
+}
+
+set_current_branch() {