-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcreate-base-images
executable file
·108 lines (97 loc) · 2.14 KB
/
create-base-images
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
set -eu
usage()
{
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Supported options:"
echo " -b Branch name (e.g. 2019Q4, trunk)"
echo " -d Date stamp to use for trunk releases"
echo " -r Release version (e.g. 19.4.0)"
echo " -s Suffix to add to image filenames (e.g. lts, trunk)"
echo ""
echo "Examples:"
echo " # Create 2019Q3/19.3.0 non-LTS release"
echo " $0 -b 2019Q3 -r 19.3.0"
echo ""
echo " # Create 2019Q4/19.4.0 LTS release"
echo " $0 -b 2019Q4 -r 19.4.0 -s lts"
echo ""
echo " # Create 20200124 snapshot trunk release"
echo " $0 -b trunk -d 20200124 -r 20200124 -s trunk"
}
bflag=false
dflag=""
rflag=false
suffix=""
while getopts ":b:d:hr:s:" flag; do
case "${flag}" in
b) bflag=true; branch=$OPTARG ;;
d) dflag="-d $OPTARG" ;;
h) usage; exit ;;
r) rflag=true release=$OPTARG ;;
s) suffix="-$OPTARG" ;;
*) usage >&2; exit 2 ;;
esac
done
shift $((OPTIND - 1))
#
# Sanity checks.
#
if ! ${bflag} || ! ${rflag}; then
usage >&2
exit 2
fi
case "${branch}" in
201[0-5]Q[1-4]|2016Q[1-3])
# 20141030
seed_uuid="d135c918-0558-11e5-bccb-9bb2e57508ee"
;;
trunk|2016Q4|201[7-9]Q[1-4]|20[2-9][0-9]Q[1-4])
# 20141030u1 (DATASET-1240)
seed_uuid="88a04a6c-d413-11e6-8341-ff5fa45bf3e9"
;;
esac
createimage()
{
arch=$1; shift
image=$1; shift
uuid=$(vmadm lookup -1 alias=proto-zone 2>/dev/null || true)
if [ -n "${uuid}" ]; then
echo "ERROR: proto-zone ${uuid} already exists" >&2
exit 1
fi
echo "Creating proto zone."
vmadm create <<-EOF
{
"brand": "joyent",
"image_uuid": "${seed_uuid}",
"max_physical_memory": 512,
"alias": "proto-zone",
"resolvers": [
"8.8.8.8"
],
"nics": [
{
"nic_tag": "admin",
"ip": "dhcp"
}
]
}
EOF
uuid=$(vmadm lookup -1 alias=proto-zone)
echo "Creating ${image} zone."
./install-base \
-c ${branch}-${arch} \
${dflag} \
-n ${image} \
-r ${release} \
-z ${uuid}
echo "Creating ${image}-${release} image."
./create-image ${image}-${release} ${uuid}
echo "Deleting proto zone."
vmadm delete ${uuid}
}
createimage x86_64 minimal-64${suffix}
createimage x86_64 base-64${suffix}
createimage x86_64 pkgbuild${suffix}