-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathopeneuler.sh
executable file
·261 lines (242 loc) · 6.35 KB
/
openeuler.sh
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#!/usr/bin/env bash
set -euo pipefail
cd $(dirname $0)
WORKINGDIR=$(pwd)
function errcho() {
>&2 echo $@;
}
function openeuler_aws {
if [[ -z ${AWS:-} ]]; then
return
fi
if [[ -z "${OPENEULER_VERSION:-}" ]]; then
errcho "--version option not provided"
exit 1
fi
if [[ -z "${OPENEULER_ARCH:-}" ]]; then
OPENEULER_ARCH="x86_64"
echo "--arch option not provided, set to default x86_64"
fi
if [[ -z "${AWS_OWNER_ID:-}" ]]; then
errcho "--aws-owner-id option not provided"
exit 1
fi
if [[ -z "${AWS_BUCKET:-}" ]]; then
errcho "--aws-bucket option not provided"
exit 1
fi
export OPENEULER_VERSION=${OPENEULER_VERSION} \
OPENEULER_ARCH=${OPENEULER_ARCH} \
BUCKET_NAME=${AWS_BUCKET} \
AWS_BASE_AMI_OWNER_ID=${AWS_OWNER_ID} \
OPENEULER_MIRROR=${OPENEULER_MIRROR:-}
${WORKINGDIR}/scripts/openeuler/build-base-image.sh
${WORKINGDIR}/scripts/openeuler/build-base-ami.sh
${WORKINGDIR}/scripts/openeuler/build-ami.sh
}
function openeuler_hwcloud_base {
if [[ -z ${HWCLOUD_BASE:-} ]]; then
return
fi
if [[ -z "${OPENEULER_VERSION:-}" ]]; then
errcho "--version option not provided"
exit 1
fi
if [[ -z "${OPENEULER_ARCH:-}" ]]; then
OPENEULER_ARCH="aarch64"
echo "--arch option not provided, set to default aarch64"
fi
if [[ -z "${OBS_BUCKET:-}" ]]; then
errcho "--obs-bucket option not provided"
exit 1
fi
export OPENEULER_VERSION=${OPENEULER_VERSION} \
OPENEULER_ARCH=${OPENEULER_ARCH} \
BUCKET_NAME=${OBS_BUCKET} \
OPENEULER_MIRROR=${OPENEULER_MIRROR:-}
${WORKINGDIR}/scripts/openeuler/build-base-image.sh
${WORKINGDIR}/scripts/openeuler/build-hwcloud-base-image.sh
}
function openeuler_hwcloud {
if [[ -z ${HWCLOUD:-} ]]; then
return
fi
if [[ -z "${OPENEULER_VERSION:-}" ]]; then
errcho "--version option not provided"
exit 1
fi
if [[ -z "${OPENEULER_ARCH:-}" ]]; then
OPENEULER_ARCH="aarch64"
echo "--arch option not provided, set to default aarch64"
fi
if [[ -z "${SOURCE_IMAGE_ID:-}" ]]; then
errcho "--source option not provided"
exit 1
fi
if [[ -z "${VPC_ID:-}" ]]; then
errcho "--vpc option not provided"
exit 1
fi
if [[ -z "${SUBNET_ID:-}" ]]; then
errcho "--subnet option not provided"
exit 1
fi
export OPENEULER_VERSION=${OPENEULER_VERSION} \
OPENEULER_ARCH=${OPENEULER_ARCH} \
SOURCE_IMAGE_ID=${SOURCE_IMAGE_ID} \
VPC_ID=${VPC_ID} \
SUBNET_ID=${SUBNET_ID}
${WORKINGDIR}/scripts/openeuler/build-hwcloud.sh
}
function openeuler_harvester {
if [[ -z ${HARVESTER:-} ]]; then
return
fi
if [[ -z "${OPENEULER_VERSION:-}" ]]; then
errcho "--version option not provided"
exit 1
fi
if [[ -z "${OPENEULER_ARCH:-}" ]]; then
OPENEULER_ARCH="x86_64"
echo "--arch option not provided, set to default x86_64"
fi
export OPENEULER_VERSION=${OPENEULER_VERSION} \
OPENEULER_ARCH=${OPENEULER_ARCH} \
OPENEULER_MIRROR=${OPENEULER_MIRROR:-}
${WORKINGDIR}/scripts/openeuler/build-base-image.sh
${WORKINGDIR}/scripts/openeuler/build-harvester.sh
}
function usage {
echo "$0 - 构建 openEuler 云镜像"
echo
echo "USAGE: $0 [-h|--help] 显示帮助信息"
echo ' [--aws] 构建 AWS AMI 镜像'
echo ' [--hwcloud-base] 构建华为云基础镜像'
echo ' [--hwcloud] 构建华为云镜像'
echo ' [--harvester] 构建 Harvester 镜像'
echo ' [--version text] openEuler 系统版本号'
echo ' [--arch text] openEuler 系统架构 (x86_64 / aarch64)'
echo ' [--aws-owner-id text] AWS 帐号 Owner ID'
echo ' [--aws-bucket text] AWS S3 存储桶名称'
echo ' [--obs-bucket text] 华为云 OBS 存储桶名称'
echo ' [--mirror text] 下载 openEuler qcow2 镜像源'
echo ' [--debug] 显示调试信息'
echo
echo "Example:"
echo "构建 AWS AMI 镜像:"
echo "$0 \\"
echo " --aws \\"
echo " --aws-owner-id <OWNER_ID> \\"
echo " --version 24.03-LTS \\"
echo " --arch x86_64 \\"
echo " --aws-bucket <BUCKET_NAME>"
echo
echo "构建 HWCloud 基础云镜像 (鲲鹏):"
echo "$0 \\"
echo " --hwcloud-base \\"
echo " --version 24.03-LTS \\"
echo " --arch aarch64 \\"
echo " --obs-bucket <BUCKET_NAME>"
echo
echo "构建 HWCloud 公有云镜像 (鲲鹏):"
echo "$0 \\"
echo " --hwcloud \\"
echo " --version 24.03-LTS \\"
echo " --arch aarch64 \\"
echo " --source <BASE_IMAGE_ID>"
echo
echo "构建 Harvester 镜像:"
echo "$0 \\"
echo " --harvester \\"
echo " --version 24.03-LTS \\"
echo " --arch aarch64"
}
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--aws)
AWS="true"
shift
;;
--hwcloud)
HWCLOUD="true"
shift
;;
--hwcloud-base)
HWCLOUD_BASE="true"
shift
;;
--harvester)
HARVESTER="true"
shift
;;
--version)
OPENEULER_VERSION="$2"
shift
shift
;;
--arch)
OPENEULER_ARCH="$2"
shift
shift
;;
--aws-owner-id)
AWS_OWNER_ID="$2"
shift
shift
;;
--aws-bucket)
AWS_BUCKET="$2"
shift
shift
;;
--obs-bucket)
OBS_BUCKET="$2"
shift
shift
;;
--source)
SOURCE_IMAGE_ID="$2"
shift
shift
;;
--vpc)
VPC_ID="$2"
shift
shift
;;
--subnet)
SUBNET_ID="$2"
shift
shift
;;
--mirror)
OPENEULER_MIRROR="$2"
shift
shift
;;
--debug)
DEBUG_MODE="true"
set -x
shift
;;
-h|--help)
help="true"
shift
;;
*)
errcho "Unrecognized option: $key"
errcho
usage
exit 1
;;
esac
done
if [[ ${help:-} ]]; then
usage
exit 0
fi
openeuler_aws
openeuler_hwcloud_base
openeuler_hwcloud
openeuler_harvester