Skip to content

Commit

Permalink
Script to populate a lab host with images (#1281)
Browse files Browse the repository at this point in the history
Script to populate a lab host with images from a local http server.

Co-authored-by: Alan Hanson <[email protected]>
  • Loading branch information
leftwo and Alan Hanson authored Jun 28, 2022
1 parent 2b3a30b commit c18a8fe
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions tools/populate/populate-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
# Populate an Oxide lab host running Omicron with images from server catacomb.

set -eu
CATACOMB_TUNNEL="[fd00:1122:3344:101::1]:8080"
res=0
echo "Populating debian"
oxide api /images --method POST --input - <<EOF
{
"name": "debian",
"description": "debian",
"block_size": 512,
"distribution": {
"name": "debian",
"version": "11"
},
"source": {
"type": "url",
"url": "http://${CATACOMB_TUNNEL}/media/debian/debian-11-nocloud-amd64-20220503-998.raw"
}
}
EOF

echo "Populating focal"
oxide api /images --method POST --input - <<EOF
{
"name": "focal",
"description": "focal",
"block_size": 512,
"distribution": {
"name": "focal",
"version": "1"
},
"source": {
"type": "url",
"url": "http://${CATACOMB_TUNNEL}/media/cloud/focal-server-cloudimg-amd64.raw"
}
}
EOF

echo "Populating ubuntu"
oxide api /images --method POST --input - <<EOF
{
"name": "ubuntu",
"description": "ubuntu",
"block_size": 512,
"distribution": {
"name": "ubuntu",
"version": "22.04"
},
"source": {
"type": "url",
"url": "http://${CATACOMB_TUNNEL}/media/ubuntu/ubuntu-22.04-live-server-amd64.iso"
}
}
EOF

# A sanity check to see if access is working to catacomb
curl_test=$(curl -w '%{http_code}\n' -s -o /dev/null http://${CATACOMB_TUNNEL}/media/test.txt)
if [[ $curl_test -eq 200 ]]; then
echo "✔ Curl test to catacomb worked"
else
echo "To use these images, you need to have network access"
echo "to the catacomb lab system at ${CATACOMB_TUNNEL}"
echo ""
echo "For example, I run this from the system \"sock\" to set up a tunnel:"
echo "ssh -L ${CATACOMB_TUNNEL}:catacomb:80 catacomb"
echo "Leave that running in a different window while access is required"
echo ""
echo "Test of curl to catacomb failed"
echo "curl http://${CATACOMB_TUNNEL}/media/test.txt"
res=1
fi
exit $res

0 comments on commit c18a8fe

Please sign in to comment.