#!/bin/bash -xe

# Keep fetching until this uuid to appear in the logs before uploading
END_UUID=$(cat /proc/sys/kernel/random/uuid)

echo "Grabbing consoleLog ($END_UUID)"

# Get the plain text version (does not contain links or timestamps)
console_log_path='consoleText'
while ! grep -q "$END_UUID" /tmp/console.txt; do
    sleep 3
    wget -c -O /tmp/console.txt --no-check-certificate $BUILD_URL$console_log_path
done

# Grab the HTML version of the log (includes timestamps)
console_log_path='logText/progressiveHtml'
while ! grep -q "$END_UUID" /tmp/console.html; do
    sleep 3
    wget -c -O /tmp/console.html --no-check-certificate $BUILD_URL$console_log_path
done

# We need to add <pre> tags around the output for log-osanalyze to not escape
# the content

sed -i '1s/^/<pre>\n/' /tmp/console.html
echo "</pre>" >> /tmp/console.html

#!/bin/bash -xe

# Keep fetching until this uuid to appear in the logs before uploading
END_UUID=$(cat /proc/sys/kernel/random/uuid)

echo "Grabbing consoleLog ($END_UUID)"

# Since we are appending to fetched logs, remove any possibly old runs
rm -f /tmp/console.txt /tmp/console.html

# Get the plain text version (does not contain links or timestamps)
console_log_path='consoleText'
while ! grep -q "$END_UUID" /tmp/console.txt; do
    sleep 3
    wget -c -O /tmp/console.txt --no-check-certificate $BUILD_URL$console_log_path
done

# Grab the HTML version of the log (includes timestamps)
console_log_path='logText/progressiveHtml'
while ! grep -q "$END_UUID" /tmp/console.html; do
    sleep 3
    wget -c -O /tmp/console.html --no-check-certificate $BUILD_URL$console_log_path
done

# We need to add <pre> tags around the output for log-osanalyze to not escape
# the content

sed -i '1s/^/<pre>\n/' /tmp/console.html
echo "</pre>" >> /tmp/console.html

Remove old log fetches in case of conflict
Remove old log fetches in case of conflict

Since we are appending to logs we should make sure the fetch
destination is clean before downloading in case we are on a
non-ephemerial node.

Change-Id: I315fda50ab98de5dd243eec745c702877069c646
