Created
November 19, 2024 20:56
-
-
Save sneal/54a314fb2f07b240651510fcbe1b45a1 to your computer and use it in GitHub Desktop.
BASH script replacement for tile-injector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
set -u | |
set -o pipefail | |
# Crack the tile open into the tasw directory | |
tasw_tiles=(./pas-windows-*.pivotal) | |
tasw_tile="${tasw_tiles=[0]}" | |
unzip "$tasw_tile" -d ./tasw | |
# Build the hydrator | |
pushd ./tasw/embed/windowsfs-release/src/code.cloudfoundry.org/hydrator | |
GOPATH="$(pwd)" go install code.cloudfoundry.org/hydrator/cmd/hydrate | |
popd | |
# Download all the image layers from Docker and Microsoft into the blobs directory as a tgz | |
# Note - the hydrator is hardcoded to use https://registry.hub.docker.com | |
pushd tasw/embed/windowsfs-release | |
if [ `uname` == "Linux" ]; then | |
TAG="$(cat ./config/blobs.yml | grep 'windows2019fs/windows2016fs-' | grep -oP '\d*\.\d*\.\d*')" | |
else | |
TAG="$(cat ./config/blobs.yml | grep 'windows2019fs/windows2016fs-' | grep -o '\d*\.\d*\.\d*')" | |
fi | |
./src/code.cloudfoundry.org/hydrator/bin/hydrate download -image cloudfoundry/windows2016fs -tag "$TAG" -outputDir ./blobs/windows2019fs | |
# Update the bosh blobstore to be local and not use S3 | |
cat << EOF > ./config/final.yml | |
--- | |
name: windows2019fs | |
blobstore: | |
provider: local | |
options: | |
blobstore_path: /tmp/windowsfs | |
EOF | |
# Create a dev release | |
bosh create-release --force --tarball "../../releases/windows2019fs-$TAG.tgz" | |
popd | |
# Remove our working content so we don't bloat the tile | |
pushd ./tasw | |
rm -rf ./embed | |
# Add the windows2019fs release to the tile's list of releases | |
cat << EOF > /tmp/metadata-ops.yml | |
- type: replace | |
path: /releases/- | |
value: | |
file: windows2019fs-$TAG.tgz | |
name: windows2019fs | |
version: $TAG | |
EOF | |
bosh interpolate ./metadata/metadata.yml --ops-file /tmp/metadata-ops.yml > ./metadata/metadata-new.yml | |
mv -f ./metadata/metadata-new.yml ./metadata/metadata.yml | |
# Repackage the tile with rootfs fully hydrated | |
zip -r "../pas-windows-injected.pivotal" . | |
popd | |
# Cleanup | |
rm -rf ./tasw | |
rm /tmp/metadata-ops.yml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment