blob: e654d6bfc9d69a15eb8fadb59472822adc1a4403 [file] [log] [blame]
garciadeblas93c61312016-09-28 15:12:48 +02001#!/bin/bash
garciadeblas38d91ee2019-11-07 16:31:23 +01002#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
garciadeblas2ffcab92025-11-27 10:32:37 +010015
16DEVOPS_GERRIT_REFSPEC="master"
garciadeblas931a5122023-10-03 17:52:02 +020017DOCKER_TAG="testing-daily"
garciadeblas93c61312016-09-28 15:12:48 +020018
garciadeblas38d91ee2019-11-07 16:31:23 +010019function usage(){
garciadeblas212165a2025-11-25 15:10:44 +010020 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
garciadeblas38d91ee2019-11-07 16:31:23 +010021 echo -e "usage: $0 [OPTIONS]"
garciadeblas81077ae2023-07-03 19:31:15 +020022 echo -e "Install OSM"
garciadeblas38d91ee2019-11-07 16:31:23 +010023 echo -e " OPTIONS"
garciadeblas7f1e1042020-11-30 14:07:03 +000024 echo -e " -h / --help: print this help"
25 echo -e " -y: do not prompt for confirmation, assumes yes"
garciadeblas2ffcab92025-11-27 10:32:37 +010026 echo -e " -S <gerrit refspec>: use a specific devops gerrit refspec (branch, tag, commit), default is master"
garciadeblas96155042022-06-22 16:26:22 +020027 echo -e " -a <apt proxy url>: use this apt proxy url when downloading apt packages (air-gapped installation)"
garciadeblas8d8cd992024-05-21 16:04:14 +020028 echo -e " -c <kubernetes engine>: use a specific kubernetes engine (options: kubeadm, k3s), default is kubeadm"
29 echo -e " -t <docker tag> specify osm docker tag (default is latest)"
30 echo -e " -M <KUBECONFIG_FILE>: Kubeconfig of an existing cluster to be used as mgmt cluster instead of OSM cluster"
31 echo -e " -G <KUBECONFIG_FILE>: Kubeconfig of an existing cluster to be used as auxiliary cluster instead of OSM cluster"
garciadeblascf603f52025-06-04 11:57:28 +020032 echo -e " -O <KUBECONFIG_FILE>: Kubeconfig of an existing cluster to be used as OSM cluster instead of creating a new one from scratch"
garciadeblas8d8cd992024-05-21 16:04:14 +020033 echo -e " --no-mgmt-cluster: Do not provision a mgmt cluster for cloud-native gitops operations in OSM (NEW in Release SIXTEEN) (by default, it is installed)"
34 echo -e " --no-aux-cluster: Do not provision an auxiliary cluster for cloud-native gitops operations in OSM (NEW in Release SIXTEEN) (by default, it is installed)"
garciadeblas212165a2025-11-25 15:10:44 +010035 echo -e " -s <namespace> namespace where OSM helm chart will be deployed (default is osm)"
garciadeblas7f1e1042020-11-30 14:07:03 +000036 echo -e " -d <docker registry URL> use docker registry URL instead of dockerhub"
37 echo -e " -p <docker proxy URL> set docker proxy URL as part of docker CE configuration"
garciadeblas0b1c75c2025-11-11 23:04:39 +010038 echo -e " -m <MODULE>: module to test a specific docker image (NG-UI, NBI, LCM, RO, MON) (can be used several times)"
39 echo -e " -T <docker tag> use specific docker tag for the module specified with option -m"
garciadeblas212165a2025-11-25 15:10:44 +010040 echo -e " -U <docker user>: specify docker user to use when pulling images from a private registry"
41 echo -e " -D <devops path>: use particular devops installation path"
42 echo -e " -e <external IP>: set the external IP address of the OSM cluster (default is empty, which means autodetect)"
garciadeblas96155042022-06-22 16:26:22 +020043 echo -e " --debug: debug mode"
garciadeblas212165a2025-11-25 15:10:44 +010044 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
garciadeblas38d91ee2019-11-07 16:31:23 +010045}
46
garciadeblas0bc87522021-10-20 22:16:17 +020047function configure_apt_proxy() {
48 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
49 OSM_APT_PROXY=$1
50 OSM_APT_PROXY_FILE="/etc/apt/apt.conf.d/osm-apt"
51 echo "Configuring apt proxy in file ${OSM_APT_PROXY_FILE}"
52 if [ ! -f ${OSM_APT_PROXY_FILE} ]; then
53 sudo bash -c "cat <<EOF > ${OSM_APT_PROXY}
54Acquire::http { Proxy \"${OSM_APT_PROXY}\"; }
55EOF"
56 else
57 sudo sed -i "s|Proxy.*|Proxy \"${OSM_APT_PROXY}\"; }|" ${OSM_APT_PROXY_FILE}
58 fi
garciadeblas5f420b12022-02-10 01:43:59 +010059 sudo apt-get -y update || FATAL "Configured apt proxy, but couldn't run 'apt-get update'. Check ${OSM_APT_PROXY_FILE}"
garciadeblas0bc87522021-10-20 22:16:17 +020060 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
61}
62
garciadeblas2ffcab92025-11-27 10:32:37 +010063while getopts ":a:c:e:S:D:s:t:U:d:p:m:T:M:G:O:-: hy" o; do
garciadeblas38d91ee2019-11-07 16:31:23 +010064 case "${o}" in
garciadeblas2ffcab92025-11-27 10:32:37 +010065 S)
66 DEVOPS_GERRIT_REFSPEC="${OPTARG}"
garciadeblas38d91ee2019-11-07 16:31:23 +010067 ;;
68 t)
garciadeblas25e87d22020-01-31 14:27:29 +010069 DOCKER_TAG="${OPTARG}"
garciadeblas38d91ee2019-11-07 16:31:23 +010070 ;;
garciadeblas72399e32019-11-22 10:09:40 +010071 -)
72 [ "${OPTARG}" == "help" ] && usage && exit 0
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010073 ;;
garciadeblas25e87d22020-01-31 14:27:29 +010074 :)
75 echo "Option -$OPTARG requires an argument" >&2
76 usage && exit 1
77 ;;
78 \?)
79 echo -e "Invalid option: '-$OPTARG'\n" >&2
80 usage && exit 1
81 ;;
82 h)
83 usage && exit 0
84 ;;
garciadeblas38d91ee2019-11-07 16:31:23 +010085 *)
86 ;;
87 esac
88done
89
garciadeblas5f420b12022-02-10 01:43:59 +010090sudo DEBIAN_FRONTEND=noninteractive apt-get -qy update
garciadeblas2ffcab92025-11-27 10:32:37 +010091sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git
92DEVOPS_PATH=$(mktemp -d /tmp/osm-devops-XXXXXX)
93git clone https://osm.etsi.org/gerrit/osm/devops.git $DEVOPS_PATH
garciadeblasccc73142025-12-15 12:47:55 +010094git -C $DEVOPS_PATH fetch "https://osm.etsi.org/gerrit/osm/devops" $DEVOPS_GERRIT_REFSPEC
95git -C $DEVOPS_PATH checkout FETCH_HEAD
garciadeblas2ffcab92025-11-27 10:32:37 +010096$DEVOPS_PATH/installers/full_install_osm.sh -t $DOCKER_TAG "$@"