Skip to content

Instantly share code, notes, and snippets.

@pothos
Created November 26, 2020 12:23
Show Gist options
  • Save pothos/2ffc3b55bc16d82f537af0d69a5a5909 to your computer and use it in GitHub Desktop.
Save pothos/2ffc3b55bc16d82f537af0d69a5a5909 to your computer and use it in GitHub Desktop.
set-flatcar-instance-alias
#!/bin/bash
set -euo pipefail
if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: $0 ALIAS"
echo "To be executed on the Flatcar instance"
exit 1
fi
ALIAS="$1"
SERVER=$(grep SERVER= /etc/flatcar/update.conf /usr/share/flatcar/update.conf | head -n 1 | cut -d = -f 2)
MACHINEID=$(cat /etc/machine-id)
VERSION=$(grep FLATCAR_RELEASE_VERSION= /usr/share/flatcar/release | cut -d = -f 2)
TRACK=$(grep GROUP= /etc/flatcar/update.conf /usr/share/flatcar/update.conf | head -n 1 | cut -d = -f 2)
cat << EOF > /tmp/request
<?xml version="1.0" encoding="UTF-8"?>
<request protocol="3.0" version="update_engine-0.4.10" updaterversion="update_engine-0.4.10" installsource="scheduler" ismachine="1">
<os version="Chateau" platform="CoreOS"></os>
<app appid="e96281a6-d1af-4bde-9a0a-97b76e56dc57" version="$VERSION" track="$TRACK" machineid="$MACHINEID" machinealias="$ALIAS" lang="en-US" board="amd64-usr" delta_okay="false" >
<ping active="1"></ping>
</app>
</request>
EOF
curl -L -d @/tmp/request -H 'Content-Type: text/xml' "$SERVER"
rm /tmp/request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment