| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| garciadeblas | 38d91ee | 2019-11-07 16:31:23 +0100 | [diff] [blame] | 2 | # |
| 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 | # |
| garciadeblas | 2ffcab9 | 2025-11-27 10:32:37 +0100 | [diff] [blame] | 15 | |
| 16 | DEVOPS_GERRIT_REFSPEC="master" |
| garciadeblas | 931a512 | 2023-10-03 17:52:02 +0200 | [diff] [blame] | 17 | DOCKER_TAG="testing-daily" |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 18 | |
| garciadeblas | 38d91ee | 2019-11-07 16:31:23 +0100 | [diff] [blame] | 19 | function usage(){ |
| garciadeblas | 212165a | 2025-11-25 15:10:44 +0100 | [diff] [blame] | 20 | [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function |
| garciadeblas | 38d91ee | 2019-11-07 16:31:23 +0100 | [diff] [blame] | 21 | echo -e "usage: $0 [OPTIONS]" |
| garciadeblas | 81077ae | 2023-07-03 19:31:15 +0200 | [diff] [blame] | 22 | echo -e "Install OSM" |
| garciadeblas | 38d91ee | 2019-11-07 16:31:23 +0100 | [diff] [blame] | 23 | echo -e " OPTIONS" |
| garciadeblas | 7f1e104 | 2020-11-30 14:07:03 +0000 | [diff] [blame] | 24 | echo -e " -h / --help: print this help" |
| 25 | echo -e " -y: do not prompt for confirmation, assumes yes" |
| garciadeblas | 2ffcab9 | 2025-11-27 10:32:37 +0100 | [diff] [blame] | 26 | echo -e " -S <gerrit refspec>: use a specific devops gerrit refspec (branch, tag, commit), default is master" |
| garciadeblas | 9615504 | 2022-06-22 16:26:22 +0200 | [diff] [blame] | 27 | echo -e " -a <apt proxy url>: use this apt proxy url when downloading apt packages (air-gapped installation)" |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 28 | 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" |
| garciadeblas | cf603f5 | 2025-06-04 11:57:28 +0200 | [diff] [blame] | 32 | echo -e " -O <KUBECONFIG_FILE>: Kubeconfig of an existing cluster to be used as OSM cluster instead of creating a new one from scratch" |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 33 | 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)" |
| garciadeblas | 212165a | 2025-11-25 15:10:44 +0100 | [diff] [blame] | 35 | echo -e " -s <namespace> namespace where OSM helm chart will be deployed (default is osm)" |
| garciadeblas | 7f1e104 | 2020-11-30 14:07:03 +0000 | [diff] [blame] | 36 | 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" |
| garciadeblas | 0b1c75c | 2025-11-11 23:04:39 +0100 | [diff] [blame] | 38 | 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" |
| garciadeblas | 212165a | 2025-11-25 15:10:44 +0100 | [diff] [blame] | 40 | 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)" |
| garciadeblas | 9615504 | 2022-06-22 16:26:22 +0200 | [diff] [blame] | 43 | echo -e " --debug: debug mode" |
| garciadeblas | 212165a | 2025-11-25 15:10:44 +0100 | [diff] [blame] | 44 | [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function |
| garciadeblas | 38d91ee | 2019-11-07 16:31:23 +0100 | [diff] [blame] | 45 | } |
| 46 | |
| garciadeblas | 0bc8752 | 2021-10-20 22:16:17 +0200 | [diff] [blame] | 47 | function 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} |
| 54 | Acquire::http { Proxy \"${OSM_APT_PROXY}\"; } |
| 55 | EOF" |
| 56 | else |
| 57 | sudo sed -i "s|Proxy.*|Proxy \"${OSM_APT_PROXY}\"; }|" ${OSM_APT_PROXY_FILE} |
| 58 | fi |
| garciadeblas | 5f420b1 | 2022-02-10 01:43:59 +0100 | [diff] [blame] | 59 | sudo apt-get -y update || FATAL "Configured apt proxy, but couldn't run 'apt-get update'. Check ${OSM_APT_PROXY_FILE}" |
| garciadeblas | 0bc8752 | 2021-10-20 22:16:17 +0200 | [diff] [blame] | 60 | [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function |
| 61 | } |
| 62 | |
| garciadeblas | 2ffcab9 | 2025-11-27 10:32:37 +0100 | [diff] [blame] | 63 | while getopts ":a:c:e:S:D:s:t:U:d:p:m:T:M:G:O:-: hy" o; do |
| garciadeblas | 38d91ee | 2019-11-07 16:31:23 +0100 | [diff] [blame] | 64 | case "${o}" in |
| garciadeblas | 2ffcab9 | 2025-11-27 10:32:37 +0100 | [diff] [blame] | 65 | S) |
| 66 | DEVOPS_GERRIT_REFSPEC="${OPTARG}" |
| garciadeblas | 38d91ee | 2019-11-07 16:31:23 +0100 | [diff] [blame] | 67 | ;; |
| 68 | t) |
| garciadeblas | 25e87d2 | 2020-01-31 14:27:29 +0100 | [diff] [blame] | 69 | DOCKER_TAG="${OPTARG}" |
| garciadeblas | 38d91ee | 2019-11-07 16:31:23 +0100 | [diff] [blame] | 70 | ;; |
| garciadeblas | 72399e3 | 2019-11-22 10:09:40 +0100 | [diff] [blame] | 71 | -) |
| 72 | [ "${OPTARG}" == "help" ] && usage && exit 0 |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 73 | ;; |
| garciadeblas | 25e87d2 | 2020-01-31 14:27:29 +0100 | [diff] [blame] | 74 | :) |
| 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 | ;; |
| garciadeblas | 38d91ee | 2019-11-07 16:31:23 +0100 | [diff] [blame] | 85 | *) |
| 86 | ;; |
| 87 | esac |
| 88 | done |
| 89 | |
| garciadeblas | 5f420b1 | 2022-02-10 01:43:59 +0100 | [diff] [blame] | 90 | sudo DEBIAN_FRONTEND=noninteractive apt-get -qy update |
| garciadeblas | 2ffcab9 | 2025-11-27 10:32:37 +0100 | [diff] [blame] | 91 | sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git |
| 92 | DEVOPS_PATH=$(mktemp -d /tmp/osm-devops-XXXXXX) |
| 93 | git clone https://osm.etsi.org/gerrit/osm/devops.git $DEVOPS_PATH |
| garciadeblas | ccc7314 | 2025-12-15 12:47:55 +0100 | [diff] [blame] | 94 | git -C $DEVOPS_PATH fetch "https://osm.etsi.org/gerrit/osm/devops" $DEVOPS_GERRIT_REFSPEC |
| 95 | git -C $DEVOPS_PATH checkout FETCH_HEAD |
| garciadeblas | 2ffcab9 | 2025-11-27 10:32:37 +0100 | [diff] [blame] | 96 | $DEVOPS_PATH/installers/full_install_osm.sh -t $DOCKER_TAG "$@" |