flatcar-scripts/core_upload_update
Brandon Philips 5d145c3f49 feat(core_upload_update): set track on cli
move core_update_developer_track.sh to core_upload_update and give it
the ability to update a track via a command line argument.
2013-07-01 22:04:23 -07:00

50 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
usage="
usage: $0 <image.bin> <track> <api key> <public-rsa-key> <private-rsa-key>\n
\n
Setting everything up for use\n
1) Run 'gsutil config' and use project id coreos.com:core-update-storage\n
2) Ensure core-admin is installed, it is a recent addition\n
NOTE: Use the chromiumos_image.bin not a qemu/xen/etc image for generating the
update.
"
FILE=$1
TRACK=$2
APIKEY=$3
PUB=$4
KEY=$5
if [ $# -ne 5 ]; then
echo -e $usage
exit
fi
if [ ! -f $FILE ]; then
echo "ERROR: No such file $FILE"
echo -e $usage
exit
fi
# Generate a payload and sign it with our private key
cros_generate_update_payload --image $FILE --output /tmp/update.gz --private_key $KEY
# Verify that the payload signature is OK
delta_generator -in_file /tmp/update.gz -public_key $PUB || exit
# Generate the metadata payload
delta_generator -out_metadata /tmp/update.metadata -private_key $KEY -in_file /tmp/update.gz || exit
MD5SUM=$(md5sum $FILE | cut -f1 -d" ")
gsutil cp /tmp/update.gz gs://update-storage.core-os.net/$TRACK/$MD5SUM/update.gz
CORE_UPDATE_URL="https://core-api.appspot.com" core-admin new-version \
-k $APIKEY -v 9999.0.0 \
-a {e96281a6-d1af-4bde-9a0a-97b76e56dc57} \
-m /tmp/update.metadata \
-t $TRACK -p $MD5SUM /tmp/update.gz