5 source $(dirname $PWD)/../lib/common.sh
6 source $(dirname $PWD)/../lib/logging.sh
8 if [[ $EUID -ne 0 ]]; then
9 echo "This script must be run as root"
13 if [[ $(lsb_release -d | cut -f2) != $UBUNTU_BIONIC ]]; then
14 echo "Currently Ubuntu 18.04.2 LTS is only supported"
18 function download_essential_packages {
20 for package in crudini curl dnsmasq figlet golang nmap patch psmisc \
21 python3-pip python3-requests python3-setuptools vim wget; do
22 apt-get -d install $package -y
24 update-alternatives --install /usr/bin/python python /usr/bin/python3 1
25 update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
28 function build_baremetal_operator_images {
29 if [ ! -d "$BUILD_DIR/baremetal-operator"]; then
33 pushd $BUILD_DIR/baremetal-operator
34 docker build -t $IRONIC_BAREMETAL_IMAGE . -f build/Dockerfile
35 docker save --output \
36 $CONTAINER_IMAGES_DIR/baremetal-operator.tar $IRONIC_BAREMETAL_IMAGE
39 docker pull $IRONIC_BAREMETAL_SOCAT_IMAGE
40 docker save --output $CONTAINER_IMAGES_DIR/socat.tar $IRONIC_BAREMETAL_SOCAT_IMAGE
43 function build_ironic_images {
44 for images in ironic-image ironic-inspector-image; do
45 if [ -d "$BUILD_DIR/$images" ]; then
46 pushd $BUILD_DIR/$images
47 podman build -t $images .
52 if podman images -q localhost/ironic-inspector-image ; then
53 podman tag localhost/ironic-inspector-image $IRONIC_INSPECTOR_IMAGE
54 podman save --output \
55 $CONTAINER_IMAGES_DIR/ironic-inspector-image.tar \
56 $IRONIC_INSPECTOR_IMAGE
59 if podman images -q localhost/ironic-image ; then
60 podman tag localhost/ironic-inspector-image $IRONIC_IMAGE
61 podman save --output $CONTAINER_IMAGES_DIR/ironic-image.tar \
65 podman pull k8s.gcr.io/pause:3.1
66 podman save --output $CONTAINER_IMAGES_DIR/podman-pause.tar \
69 #build_baremetal_operator_images
73 function download_container_images {
75 pushd $CONTAINER_IMAGES_DIR
76 #docker images for Kubernetes
77 for images in kube-apiserver kube-controller-manager kube-scheduler kube-proxy; do
78 docker pull k8s.gcr.io/$images:v1.15.0;
79 docker save --output $images.tar k8s.gcr.io/$images;
82 docker pull k8s.gcr.io/pause:3.1
83 docker save --output pause.tar k8s.gcr.io/pause
85 docker pull k8s.gcr.io/etcd:3.3.10
86 docker save --output etcd.tar k8s.gcr.io/etcd
88 docker pull k8s.gcr.io/coredns:1.3.1
89 docker save --output coredns.tar k8s.gcr.io/coredns
91 #podman images for Ironic
94 #podman pull $IRONIC_IMAGE
95 #podman save --output ironic.tar $IRONIC_IMAGE
96 #podman pull $IRONIC_INSPECTOR_IMAGE
97 #podman save --output ironic-inspector.tar $IRONIC_INSPECTOR_IMAGE
101 function download_build_packages {
104 if [ ! -f ironic-python-agent.initramfs ]; then
105 curl --insecure --compressed \
106 -L https://images.rdoproject.org/train/rdo_trunk/current-tripleo/ironic-python-agent.tar | tar -xf -
109 if [[ "$BM_IMAGE_URL" && "$BM_IMAGE" ]]; then
110 curl -o ${BM_IMAGE} --insecure --compressed -O -L ${BM_IMAGE_URL}
111 md5sum ${BM_IMAGE} | awk '{print $1}' > ${BM_IMAGE}.md5sum
114 if [ ! -f 87-podman-bridge.conflist ]; then
115 curl --insecure --compressed -O -L $PODMAN_CNI_CONFLIST
118 if [ ! -d baremetal-operator ]; then
119 git clone https://github.com/metal3-io/baremetal-operator.git
120 pushd ./baremetal-operator
121 git checkout -b icn_baremetal_operator 11ea02ab5cab8b3ab14972ae7c0e70206bba00b5
125 if [ ! -d ironic-inspector-image ]; then
126 git clone https://github.com/metal3-io/ironic-inspector-image.git
127 pushd ./ironic-inspector-image
128 git checkout -b icn_ironic_inspector_image 25431bd5b7fc87c6f3cfb8b0431fe66b86bbab0e
132 if [ ! -d ironic-image ]; then
133 git clone https://github.com/metal3-io/ironic-image.git
135 git checkout -b icn_ironic_image 329eb4542f0d8d0f0e9cf0d7e550e33b07efe7fb
141 if ! which pip ; then
142 apt-get install python3-pip -y
144 update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
147 function check_curl {
148 if ! which curl ; then
149 apt-get install curl -y
153 function check_apt_tools {
154 if ! which add-apt-repository ; then
155 apt-get install software-properties-common -y
159 function download_ironic_packages {
160 for package in jq nodejs python3-ironicclient \
161 python3-ironic-inspector-client python3-lxml python3-netaddr \
162 python3-openstackclient unzip genisoimage; do
163 apt-get -d install $package -y
167 pip download lolcat yq -d $PIP_CACHE_DIR
170 function check_docker {
171 if which docker ; then
175 apt-get remove -y docker \
182 for package in apt-transport-https ca-certificates gnupg-agent \
183 software-properties-common; do
184 apt-get -d install $package -y
189 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
191 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
195 apt-get install docker-ce=19.03.15~3-0~ubuntu-bionic -y
198 function check_podman {
199 if which podman; then
203 add-apt-repository -y ppa:projectatomic/ppa
205 apt-get install podman -y
208 function download_docker_packages {
209 apt-get remove -y docker \
216 for package in apt-transport-https ca-certificates gnupg-agent \
217 software-properties-common; do
218 apt-get -d install $package -y
223 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
225 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
229 apt-get -d install docker-ce=19.03.15~3-0~ubuntu-bionic -y
232 function download_podman_packages {
234 add-apt-repository -y ppa:projectatomic/ppa
235 apt-get -d install podman -y
238 function download_kubernetes_packages {
239 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
240 bash -c 'cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
241 deb https://apt.kubernetes.io/ kubernetes-xenial main
244 apt-get install -d kubelet=1.15.0-00 kubeadm=1.15.0-00 kubectl=1.15.0-00 -y
247 function clean_apt_cache {
248 pushd /var/cache/apt/archives
250 if [ $(ls -1q . | wc -l ) -ge 3 ]; then
251 $(rm !("lock"|"partial"))
257 function mv_apt_cache {
258 pushd /var/cache/apt/archives
260 if [ $(ls -1q . | wc -l ) -gt 2 ]; then
261 $(mv !("lock"|"partial") $LOCAL_APT_REPO)
275 if [ $(ls -1q . | wc -l ) -ne 0 ]; then
282 check_dir $LOCAL_APT_REPO
283 clean_dir $LOCAL_APT_REPO
284 check_dir $PIP_CACHE_DIR
285 clean_dir $PIP_CACHE_DIR
288 check_dir $CONTAINER_IMAGES_DIR
289 clean_dir $CONTAINER_IMAGES_DIR
290 download_essential_packages
291 download_ironic_packages
292 download_docker_packages
293 download_podman_packages
294 download_kubernetes_packages
295 download_build_packages
296 download_container_images