-
-
Save am11/5f1702de2ce5474670da4e4604856891 to your computer and use it in GitHub Desktop.
amd64 zone on illumos
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
#!/bin/bash | |
# Variables | |
ZONE_ALIAS="amd64-zone" | |
ZONE_HOSTNAME="amd64-zone" | |
ZONE_DNS_DOMAIN="local" | |
ZONE_RESOLVERS="8.8.8.8 8.8.4.4" | |
ZONE_MEMORY=2048 # Memory in MB | |
ZONE_SWAP=2048 # Swap in MB | |
NIC_TAG="admin" # Adjust if needed | |
# Query for the latest amd64 image UUID | |
echo "Querying for the latest amd64 image UUID..." | |
IMAGE_UUID=$(imgadm avail | grep "base-64-lts" | tail -n 1 | awk '{print $1}') | |
if [ -z "${IMAGE_UUID}" ]; then | |
echo "Failed to find the latest amd64 image UUID" | |
exit 1 | |
fi | |
echo "Found image UUID: ${IMAGE_UUID}" | |
# Import the image to ensure it's available | |
echo "Importing the image..." | |
imgadm import "${IMAGE_UUID}" | |
if [ $? -ne 0 ]; then | |
echo "Failed to import the image UUID ${IMAGE_UUID}" | |
exit 1 | |
fi | |
# Verify if the image UUID is valid | |
echo "Verifying the image UUID..." | |
imgadm info "${IMAGE_UUID}" | |
# Create a JSON configuration file for the zone | |
cat << EOF > ${ZONE_ALIAS}.json | |
{ | |
"brand": "joyent", | |
"image_uuid": "${IMAGE_UUID}", | |
"autoboot": true, | |
"alias": "${ZONE_ALIAS}", | |
"hostname": "${ZONE_HOSTNAME}", | |
"dns_domain": "${ZONE_DNS_DOMAIN}", | |
"resolvers": ["${ZONE_RESOLVERS// /\",\"}"], | |
"max_physical_memory": ${ZONE_MEMORY}, | |
"max_swap": ${ZONE_SWAP}, | |
"nics": [ | |
{ | |
"nic_tag": "${NIC_TAG}", | |
"ip": "dhcp", | |
"primary": true | |
} | |
] | |
} | |
EOF | |
# Create the zone | |
echo "Creating the zone..." | |
vmadm create -f ${ZONE_ALIAS}.json | |
if [ $? -ne 0 ]; then | |
echo "Failed to create the zone" | |
exit 1 | |
fi | |
# Wait for the zone to boot up | |
echo "Waiting for the zone to boot up..." | |
sleep 20 | |
# Get the UUID of the newly created zone | |
ZONE_UUID=$(vmadm list -o uuid,alias | grep ${ZONE_ALIAS} | awk '{print $1}') | |
if [ -z "${ZONE_UUID}" ]; then | |
echo "Failed to find the zone UUID" | |
exit 1 | |
fi | |
# Log into the zone | |
echo "Logging into the zone..." | |
zlogin ${ZONE_UUID} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment