mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-24 15:11:19 +02:00
oem/azure: add unreplicate-image.sh
This commit is contained in:
parent
998c7e0939
commit
9cd1553286
51
oem/azure/unreplicate-image.sh
Executable file
51
oem/azure/unreplicate-image.sh
Executable file
@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script will un-replicate the given image. It needs to be run in an
|
||||
# environment where the azure-xplat-cli has been installed and configured with
|
||||
# the production credentials and (optionally) SUBSCRIPTION_ID is defined,
|
||||
# containing the subscription GUID.
|
||||
|
||||
DIR=$(dirname $0)
|
||||
. $DIR/common.sh
|
||||
|
||||
set -e
|
||||
|
||||
GROUP="${1^}"
|
||||
VERSION=$2
|
||||
|
||||
if [[ -z $GROUP || -z $VERSION ]]; then
|
||||
echo "Usage: $0 <group> <version>"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
image_name="CoreOS-${GROUP}-${VERSION}"
|
||||
|
||||
subscription_id=$SUBSCRIPTION_ID
|
||||
if [ -z $subscription_id ]; then
|
||||
subscription_id=$(getSubscriptionId)
|
||||
fi
|
||||
|
||||
url="$(getManagementEndpoint)/${subscription_id}/services/images/${image_name}/unreplicate"
|
||||
|
||||
workdir=$(mktemp --directory)
|
||||
trap "rm --force --recursive ${workdir}" SIGINT SIGTERM EXIT
|
||||
|
||||
azure account cert export \
|
||||
--file="${workdir}/cert" \
|
||||
--subscription="${subscription_id}" > /dev/null
|
||||
|
||||
result=$(curl \
|
||||
--silent \
|
||||
--request PUT \
|
||||
--header "x-ms-version: 2014-10-01" \
|
||||
--header "Content-Type: application/xml" \
|
||||
--header "Content-Length: 0" \
|
||||
--cert "${workdir}/cert" \
|
||||
--url "${url}" \
|
||||
--write-out "%{http_code}" \
|
||||
--output "${workdir}/out")
|
||||
|
||||
if [[ $result != 200 ]]; then
|
||||
echo "${result} - $(< ${workdir}/out)"
|
||||
exit 1
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user