Remove usage of deprecated ifconfig, bridge-utils
[icn.git] / env / metal3 / 01_install_package.sh
1 #!/usr/bin/env bash
2 set -eux -o pipefail
3
4 LIBDIR="$(dirname "$PWD")"
5
6 source $LIBDIR/lib/common.sh
7 source $LIBDIR/lib/logging.sh
8
9 if [[ $EUID -ne 0 ]]; then
10     echo "This script must be run as root"
11     exit 1
12 fi
13
14 function install_essential_packages {
15     apt-get update
16     apt-get -y install \
17     crudini \
18     curl \
19     dnsmasq \
20     figlet \
21     nmap \
22     patch \
23     psmisc \
24     python3-pip \
25     python3-requests \
26     python3-setuptools \
27     vim \
28     wget \
29     git \
30     software-properties-common
31
32     update-alternatives --install /usr/bin/python python /usr/bin/python3 1
33     update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
34
35     add-apt-repository -y ppa:longsleep/golang-backports
36     apt-get update
37     apt-get install golang-go -y
38 }
39
40 function install_ironic_packages {
41     apt-get update
42     apt-get -y install \
43     jq \
44     nodejs \
45     python3-ironicclient \
46     python3-ironic-inspector-client \
47     python3-lxml \
48     python3-netaddr \
49     python3-openstackclient \
50     unzip \
51     genisoimage \
52     whois
53
54     if [ "$1" == "offline" ]; then
55     pip install --no-index
56         --find-links=file:$PIP_CACHE_DIR locat yq
57     return
58     fi
59
60     pip install \
61     lolcat \
62     yq
63 }
64
65 install() {
66     install_essential_packages
67     install_ironic_packages $1
68 }
69
70 if [ "$#" -eq 0 ]; then
71     install online
72 elif [ "$1" == "-o" ]; then
73     install offline
74 else
75     exit 1
76 fi