Last active
May 25, 2016 22:46
-
-
Save trentster/4545916 to your computer and use it in GitHub Desktop.
PURPOSE: turn a SmartOS zone vm into a dataset
This file contains hidden or 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 | |
# | |
# SCRIPT: do-smartmachine-dataset.sh | |
# AUTHOR: Mark Slatem | |
# DATE: 16 January 2013 | |
# REV: 1.0 | |
# | |
# PLATFORM: SmartOS | |
# REQUIREMENTS: SmartOS | |
# | |
# PURPOSE: turn a zone vm into a dataset | |
# USAGE: do-smartmachine-dataset.sh UUID TARGET | |
UUID="$1" | |
GENUUID=`uuid` | |
CLOUDNAME="smartos" | |
DATE=`date +%FT%H:%M:%S.0Z` | |
echo -n "What do you want to call the new dataset: " | |
read -e DNAME | |
echo -n "Enter a 3 letter abbreviation for the dataset name: " | |
read -e DNAMABBR | |
echo -n "What is the version number you want to use: " | |
read -e VERSION | |
echo -n "Enter a short description for the dataset: " | |
read -e DESCR | |
echo -n "creator name: " | |
read -e CREATOR | |
#lets do the actual snapshots | |
zfs snapshot zones/$UUID@prepare | |
echo "Creating zfs archive ($GENUUID.$DNAME.$VERSION.zfs.gz)..." | |
#lets do the actual zfs send | |
zfs send zones/$UUID@prepare | gzip > $GENUUID.$DNAME.$VERSION.zfs.gz | |
SIZE=`ls -l $GENUUID.$DNAME.$VERSION.zfs.gz | awk '{ print $5 }'` | |
CHKSUM=`cksum -xsha1 $GENUUID.$DNAME.$VERSION.zfs.gz | awk '{ print $1 }'` | |
echo "Creating manifest ($DNAME.$VERSION.dsmanifest)..." | |
cat smartmachine.tpl |\ | |
sed -e "s/#DNAME/$DNAME/g" |\ | |
sed -e "s/#VERSION/$VERSION/g" |\ | |
sed -e "s/#DESCR/$DESCR/g" |\ | |
sed -e "s/#DATE/$DATE/g" |\ | |
sed -e "s/#GENUUID/$GENUUID/g" |\ | |
sed -e "s/#CHKSUM/$CHKSUM/g" |\ | |
sed -e "s/#SIZE/$SIZE/g" |\ | |
sed -e "s/#CLOUDNAME/$CLOUDNAME/g" |\ | |
sed -e "s/#CREATOR/$CREATOR/g" |\ | |
sed -e "s/#DNAMABBR/$DNAMABBR/g" > $DNAME.$VERSION.dsmanifest | |
#lets delete the snapshot | |
zfs destroy zones/$UUID@prepare | |
##optional | |
#echo "Installing New Dataset ($DNAME.$VERSION uuid: $GENUUID)..." | |
#imgadm install -m $DNAME.$VERSION.dsmanifest -f $GENUUID.$DNAME.$VERSION.zfs.gz | |
exit 0 | |
This file contains hidden or 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
{ | |
"name": "#DNAME", | |
"version": "#VERSION", | |
"type": "zone-dataset", | |
"description": "#DESCR", | |
"published_at": "#DATE", | |
"os": "smartos", | |
"files": [ | |
{ | |
"path": "#GENUUID.#DNAME.#VERSION.zfs.gz", | |
"sha1": "#CHKSUM", | |
"size": #SIZE, | |
"url": "#GENUUID.#DNAME.#VERSION.zfs.gz" | |
} | |
], | |
"requirements": { | |
"networks": [ | |
{ | |
"name": "net0", | |
"description": "public" | |
} | |
] | |
}, | |
"uuid": "#GENUUID", | |
"creator_uuid": "3952e6b6-b61a-11e1-9a8a-2f58dc6d1291", | |
"cloud_name": "#CLOUDNAME", | |
"creator_name": "#CREATOR", | |
"platform_type": "smartos", | |
"urn": "smartos:mts:#DNAMABBR:#VERSION", | |
"created_at": "#DATE", | |
"updated_at": "#DATE" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment