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 python-pip python-requests python-setuptools vim wget; do
22 apt-get -d install $package -y
26 function build_baremetal_operator_images() {
27 if [ ! -d "$BUILD_DIR/baremetal-operator"]; then
31 pushd $BUILD_DIR/baremetal-operator
32 docker build -t $IRONIC_BAREMETAL_IMAGE . -f build/Dockerfile
33 docker save --output \
34 $CONTAINER_IMAGES_DIR/baremetal-operator.tar $IRONIC_BAREMETAL_IMAGE
37 docker pull $IRONIC_BAREMETAL_SOCAT_IMAGE
38 docker save --output $CONTAINER_IMAGES_DIR/socat.tar $IRONIC_BAREMETAL_SOCAT_IMAGE
41 function build_ironic_images() {
42 for images in ironic-image ironic-inspector-image; do
43 if [ -d "$BUILD_DIR/$images" ]; then
44 pushd $BUILD_DIR/$images
45 podman build -t $images .
50 if podman images -q localhost/ironic-inspector-image ; then
51 podman tag localhost/ironic-inspector-image $IRONIC_INSPECTOR_IMAGE
52 podman save --output \
53 $CONTAINER_IMAGES_DIR/ironic-inspector-image.tar \
54 $IRONIC_INSPECTOR_IMAGE
57 if podman images -q localhost/ironic-image ; then
58 podman tag localhost/ironic-inspector-image $IRONIC_IMAGE
59 podman save --output $CONTAINER_IMAGES_DIR/ironic-image.tar \
63 podman pull k8s.gcr.io/pause:3.1
64 podman save --output $CONTAINER_IMAGES_DIR/podman-pause.tar \
67 #build_baremetal_operator_images
71 function download_container_images() {
73 pushd $CONTAINER_IMAGES_DIR
74 #docker images for Kubernetes
75 for images in kube-apiserver kube-controller-manager kube-scheduler kube-proxy; do
76 docker pull k8s.gcr.io/$images:v1.15.0;
77 docker save --output $images.tar k8s.gcr.io/$images;
80 docker pull k8s.gcr.io/pause:3.1
81 docker save --output pause.tar k8s.gcr.io/pause
83 docker pull k8s.gcr.io/etcd:3.3.10
84 docker save --output etcd.tar k8s.gcr.io/etcd
86 docker pull k8s.gcr.io/coredns:1.3.1
87 docker save --output coredns.tar k8s.gcr.io/coredns
89 #podman images for Ironic
92 #podman pull $IRONIC_IMAGE
93 #podman save --output ironic.tar $IRONIC_IMAGE
94 #podman pull $IRONIC_INSPECTOR_IMAGE
95 #podman save --output ironic-inspector.tar $IRONIC_INSPECTOR_IMAGE
99 function download_build_packages() {
102 if [ ! -f ironic-python-agent.initramfs ]; then
103 curl --insecure --compressed \
104 -L https://images.rdoproject.org/master/rdo_trunk/current-tripleo-rdo/ironic-python-agent.tar | tar -xf -
107 if [[ "$BM_IMAGE_URL" && "$BM_IMAGE" ]]; then
108 curl -o ${BM_IMAGE} --insecure --compressed -O -L ${BM_IMAGE_URL}
109 md5sum ${BM_IMAGE} | awk '{print $1}' > ${BM_IMAGE}.md5sum
112 if [ ! -f 87-podman-bridge.conflist ]; then
113 curl --insecure --compressed -O -L $PODMAN_CNI_CONFLIST
116 if [ ! -d baremetal-operator ]; then
117 git clone https://github.com/metal3-io/baremetal-operator.git
118 pushd ./baremetal-operator
119 git checkout -b icn_baremetal_operator 11ea02ab5cab8b3ab14972ae7c0e70206bba00b5
123 if [ ! -d ironic-inspector-image ]; then
124 git clone https://github.com/metal3-io/ironic-inspector-image.git
125 pushd ./ironic-inspector-image
126 git checkout -b icn_ironic_inspector_image 25431bd5b7fc87c6f3cfb8b0431fe66b86bbab0e
130 if [ ! -d ironic-image ]; then
131 git clone https://github.com/metal3-io/ironic-image.git
133 git checkout -b icn_ironic_image 329eb4542f0d8d0f0e9cf0d7e550e33b07efe7fb
138 function check_pip() {
139 if ! which pip ; then
140 apt-get install python-pip -y
144 function check_curl() {
145 if ! which curl ; then
146 apt-get install curl -y
150 function check_apt_tools() {
151 if ! which add-apt-repository ; then
152 apt-get install software-properties-common -y
156 function download_ironic_packages() {
157 for package in jq nodejs python-ironicclient \
158 python-ironic-inspector-client python-lxml python-netaddr \
159 python-openstackclient unzip genisoimage; do
160 apt-get -d install $package -y
164 pip download lolcat yq -d $PIP_CACHE_DIR
167 function check_docker() {
168 if which docker ; then
172 apt-get remove -y docker \
179 for package in apt-transport-https ca-certificates gnupg-agent \
180 software-properties-common; do
181 apt-get -d install $package -y
186 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
188 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
192 apt-get install docker-ce=18.06.0~ce~3-0~ubuntu -y
195 function check_podman() {
196 if which podman; then
200 add-apt-repository -y ppa:projectatomic/ppa
202 apt-get install podman -y
205 function download_docker_packages() {
206 apt-get remove -y docker \
213 for package in apt-transport-https ca-certificates gnupg-agent \
214 software-properties-common; do
215 apt-get -d install $package -y
220 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
222 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
226 apt-get -d install docker-ce=18.06.0~ce~3-0~ubuntu -y
229 function download_podman_packages() {
231 add-apt-repository -y ppa:projectatomic/ppa
232 apt-get -d install podman -y
235 function download_kubernetes_packages() {
236 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
237 bash -c 'cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
238 deb https://apt.kubernetes.io/ kubernetes-xenial main
241 apt-get install -d kubelet=1.15.0-00 kubeadm=1.15.0-00 kubectl=1.15.0-00 -y
244 function clean_apt_cache() {
245 pushd /var/cache/apt/archives
247 if [ $(ls -1q . | wc -l ) -ge 3 ]; then
248 $(rm !("lock"|"partial"))
254 function mv_apt_cache() {
255 pushd /var/cache/apt/archives
257 if [ $(ls -1q . | wc -l ) -gt 2 ]; then
258 $(mv !("lock"|"partial") $LOCAL_APT_REPO)
263 function check_dir() {
269 function clean_dir() {
272 if [ $(ls -1q . | wc -l ) -ne 0 ]; then
279 check_dir $LOCAL_APT_REPO
280 clean_dir $LOCAL_APT_REPO
281 check_dir $PIP_CACHE_DIR
282 clean_dir $PIP_CACHE_DIR
285 check_dir $CONTAINER_IMAGES_DIR
286 clean_dir $CONTAINER_IMAGES_DIR
287 download_essential_packages
288 download_ironic_packages
289 download_docker_packages
290 download_podman_packages
291 download_kubernetes_packages
292 download_build_packages
293 download_container_images