X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Ffull_install_osm.sh;h=43da95a5271c68e860e25093b6cd92669ff7cec2;hb=refs%2Fchanges%2F27%2F6227%2F2;hp=cfbab57945c8f3f0ffe6eb9d3a254d8e65041a1b;hpb=fb566274af34f3a262830747aa92dd450682f8fd;p=osm%2Fdevops.git diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index cfbab579..43da95a5 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -29,6 +29,7 @@ function usage(){ echo -e " --vimemu: additionally deploy the VIM emulator as a docker container" echo -e " --elk_stack: additionally deploy an ELK docker stack for event logging" echo -e " --pm_stack: additionally deploy a Prometheus+Grafana stack for performance monitoring (PM)" + echo -e " -m : install OSM but only rebuild the specified docker images (RO, LCM, NBI, LW-UI, MON, KAFKA, MONGO, NONE)" echo -e " -o : do not install OSM, but ONLY one of the addons (vimemu, elk_stack, pm_stack) (assumes OSM is already installed)" echo -e " -D use local devops installation path" echo -e " --nolxd: do not install and configure LXD, allowing unattended installations (assumes LXD is already installed and confifured)" @@ -72,7 +73,7 @@ function uninstall(){ function remove_stack() { stack=$1 - if $(sg docker -c "docker stack ps ${stack}"); then + if sg docker -c "docker stack ps ${stack}" ; then echo -e "\nRemoving stack ${stack}" && sg docker -c "docker stack rm ${stack}" COUNTER=0 result=1 @@ -111,6 +112,9 @@ function uninstall_lightweight() { docker volume rm osm_osm_packages docker volume rm osm_ro_db EONG + echo "Removing /etc/osm and /var/log/osm files" + rm -rf /etc/osm + rm -rf /var/log/osm return 0 } @@ -562,28 +566,40 @@ function install_juju() { function generate_docker_images() { echo "Pulling and generating docker images" - newgrp docker << EONG - docker pull wurstmeister/kafka - docker pull wurstmeister/zookeeper - docker pull mongo - docker pull mysql:5 -EONG - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/MON - git -C ${LWTEMPDIR}/MON checkout ${COMMIT_ID} - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/NBI - git -C ${LWTEMPDIR}/NBI checkout ${COMMIT_ID} - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/RO - git -C ${LWTEMPDIR}/RO checkout ${COMMIT_ID} - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LCM - git -C ${LWTEMPDIR}/LCM checkout ${COMMIT_ID} - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LW-UI - git -C ${LWTEMPDIR}/LW-UI checkout ${COMMIT_ID} - sg docker -c "docker build ${LWTEMPDIR}/MON -f ${LWTEMPDIR}/MON/docker/Dockerfile -t osm/mon --no-cache" || FATAL "cannot build MON docker image" - sg docker -c "docker build ${LWTEMPDIR}/MON/policy_module -f ${LWTEMPDIR}/MON/policy_module/Dockerfile -t osm/pm --no-cache" || FATAL "cannot build PM docker image" - sg docker -c "docker build ${LWTEMPDIR}/NBI -f ${LWTEMPDIR}/NBI/Dockerfile.local -t osm/nbi --no-cache" || FATAL "cannot build NBI docker image" - sg docker -c "docker build ${LWTEMPDIR}/RO -f ${LWTEMPDIR}/RO/docker/Dockerfile-local -t osm/ro --no-cache" || FATAL "cannot build RO docker image" - sg docker -c "docker build ${LWTEMPDIR}/LCM -f ${LWTEMPDIR}/LCM/Dockerfile.local -t osm/lcm --no-cache" || FATAL "cannot build LCM docker image" - sg docker -c "docker build ${LWTEMPDIR}/LW-UI -t osm/light-ui -f ${LWTEMPDIR}/LW-UI/Dockerfile --no-cache" || FATAL "cannot build LW-UI docker image" + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q KAFKA ; then + sg docker -c "docker pull wurstmeister/zookeeper" || FATAL "cannot get zookeeper docker image" + sg docker -c "docker pull wurstmeister/kafka" || FATAL "cannot get kafka docker image" + fi + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q MONGO ; then + sg docker -c "docker pull mongo" || FATAL "cannot get mongo docker image" + fi + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q MON ; then + git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/MON + git -C ${LWTEMPDIR}/MON checkout ${COMMIT_ID} + sg docker -c "docker build ${LWTEMPDIR}/MON -f ${LWTEMPDIR}/MON/docker/Dockerfile -t osm/mon --no-cache" || FATAL "cannot build MON docker image" + sg docker -c "docker build ${LWTEMPDIR}/MON/policy_module -f ${LWTEMPDIR}/MON/policy_module/Dockerfile -t osm/pm --no-cache" || FATAL "cannot build PM docker image" + fi + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q NBI ; then + git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/NBI + git -C ${LWTEMPDIR}/NBI checkout ${COMMIT_ID} + sg docker -c "docker build ${LWTEMPDIR}/NBI -f ${LWTEMPDIR}/NBI/Dockerfile.local -t osm/nbi --no-cache" || FATAL "cannot build NBI docker image" + fi + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q RO ; then + sg docker -c "docker pull mysql:5" || FATAL "cannot get mysql docker image" + git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/RO + git -C ${LWTEMPDIR}/RO checkout ${COMMIT_ID} + sg docker -c "docker build ${LWTEMPDIR}/RO -f ${LWTEMPDIR}/RO/docker/Dockerfile-local -t osm/ro --no-cache" || FATAL "cannot build RO docker image" + fi + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LCM ; then + git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LCM + git -C ${LWTEMPDIR}/LCM checkout ${COMMIT_ID} + sg docker -c "docker build ${LWTEMPDIR}/LCM -f ${LWTEMPDIR}/LCM/Dockerfile.local -t osm/lcm --no-cache" || FATAL "cannot build LCM docker image" + fi + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LW-UI ; then + git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LW-UI + git -C ${LWTEMPDIR}/LW-UI checkout ${COMMIT_ID} + sg docker -c "docker build ${LWTEMPDIR}/LW-UI -t osm/light-ui -f ${LWTEMPDIR}/LW-UI/Dockerfile --no-cache" || FATAL "cannot build LW-UI docker image" + fi echo "Finished generation of docker images" } @@ -592,9 +608,9 @@ function cmp_overwrite() { file2="$2" if ! $(cmp "${file1}" "${file2}" >/dev/null 2>&1); then if [ -f "${file2}" ]; then - ask_user "The file ${file2} already exists. Overwrite (y/N)? " n && sudo cp -f ${file1} ${file2} + ask_user "The file ${file2} already exists. Overwrite (y/N)? " n && sudo cp -b ${file1} ${file2} else - sudo cp ${file1} ${file2} + sudo cp -b ${file1} ${file2} fi fi } @@ -602,15 +618,13 @@ function cmp_overwrite() { function generate_config_log_folders() { echo "Generating config and log folders" sudo mkdir -p /etc/osm/docker - sudo cp ${DEVOPS}/installers/docker/docker-compose.yaml /etc/osm/docker/docker-compose.yaml + sudo cp -b ${OSM_DEVOPS}/installers/docker/docker-compose.yaml /etc/osm/docker/docker-compose.yaml sudo mkdir -p /var/log/osm echo "Finished generation of config and log folders" } function generate_docker_env_files() { echo "Generating docker env files" - OSMLCM_VCA_HOST=`sg lxd -c "juju show-controller"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'` - OSMLCM_VCA_SECRET=`grep password ${HOME}/.local/share/juju/accounts.yaml |awk '{print $2}'` echo "OSMLCM_VCA_HOST=${OSMLCM_VCA_HOST}" |sudo tee /etc/osm/docker/lcm.env echo "OSMLCM_VCA_SECRET=${OSMLCM_VCA_SECRET}" |sudo tee -a /etc/osm/docker/lcm.env MYSQL_ROOT_PASSWORD=`date +%s | sha256sum | base64 | head -c 32` @@ -621,7 +635,7 @@ function generate_docker_env_files() { echo "RO_DB_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" |sudo tee /etc/osm/docker/ro.env fi echo "OS_NOTIFIER_URI=http://${DEFAULT_IP}:8662" |sudo tee ${OSM_DEVOPS}/installers/docker/mon.env - cmp_overwrite ${DEVOPS}/installers/docker/mon.env /etc/osm/docker/mon.env + cmp_overwrite ${OSM_DEVOPS}/installers/docker/mon.env /etc/osm/docker/mon.env echo "Finished generation of docker env files" } @@ -642,7 +656,7 @@ function deploy_lightweight() { function deploy_elk() { sudo mkdir -p /etc/osm/docker/osm_elk - sudo cp ${DEVOPS}/installers/docker/osm_elk/* /etc/osm/docker/osm_elk + sudo cp -b ${OSM_DEVOPS}/installers/docker/osm_elk/* /etc/osm/docker/osm_elk remove_stack osm_elk echo "Deploying ELK stack" sg docker -c "docker stack deploy -c /etc/osm/docker/osm_elk/docker-compose.yml osm_elk" @@ -688,8 +702,8 @@ function deploy_perfmon() { sg docker -c "docker build ${OSM_DEVOPS}/installers/docker/osm_metrics/kafka-exporter -f ${OSM_DEVOPS}/installers/docker/osm_metrics/kafka-exporter/Dockerfile -t osm/kafka-exporter --no-cache" || FATAL "cannot build kafka-exporter docker image" echo "Finished generation of osm/kafka-exporter docker image" sudo mkdir -p /etc/osm/docker/osm_metrics - sudo cp ${DEVOPS}/installers/docker/osm_metrics/*.yml /etc/osm/docker/osm_metrics - sudo cp ${DEVOPS}/installers/docker/osm_metrics/*.json /etc/osm/docker/osm_metrics + sudo cp -b ${OSM_DEVOPS}/installers/docker/osm_metrics/*.yml /etc/osm/docker/osm_metrics + sudo cp -b ${OSM_DEVOPS}/installers/docker/osm_metrics/*.json /etc/osm/docker/osm_metrics remove_stack osm_metrics echo "Deploying PM stack (Kafka exporter + Prometheus + Grafana)" sg docker -c "docker stack deploy -c /etc/osm/docker/osm_metrics/docker-compose.yml osm_metrics" @@ -718,12 +732,17 @@ function install_lightweight() { || FATAL "failed to install $need_packages_lw" fi install_juju + OSMLCM_VCA_HOST=`sg lxd -c "juju show-controller"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'` + OSMLCM_VCA_SECRET=`grep password ${HOME}/.local/share/juju/accounts.yaml |awk '{print $2}'` + [ -z "$OSMLCM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address" + [ -z "$OSMLCM_VCA_SECRET" ] && FATAL "Cannot obtain juju secret" track juju install_docker_ce track docker_ce #install_docker_compose generate_docker_images track docker_build + generate_config_log_folders generate_docker_env_files deploy_lightweight track docker_deploy @@ -784,6 +803,7 @@ function dump_vars(){ echo "INSTALL_ONLY=$INSTALL_ONLY" echo "INSTALL_ELK=$INSTALL_ELK" echo "INSTALL_PERFMON=$INSTALL_PERFMON" + echo "TO_REBUILD=$TO_REBUILD" echo "INSTALL_NOLXD=$INSTALL_NOLXD" echo "RELEASE=$RELEASE" echo "REPOSITORY=$REPOSITORY" @@ -829,13 +849,14 @@ INSTALL_LIGHTWEIGHT="y" INSTALL_ONLY="" INSTALL_ELK="" INSTALL_PERFMON="" +TO_REBUILD="" INSTALL_NOLXD="" NOCONFIGURE="" RELEASE_DAILY="" SESSION_ID=`date +%s` OSM_DEVOPS= -while getopts ":hy-:b:r:k:u:R:l:p:D:o:" o; do +while getopts ":hy-:b:r:k:u:R:l:p:D:o:m:" o; do case "${o}" in h) usage && exit 0 @@ -870,6 +891,16 @@ while getopts ":hy-:b:r:k:u:R:l:p:D:o:" o; do [ "${OPTARG}" == "elk_stack" ] && INSTALL_ELK="y" && continue [ "${OPTARG}" == "pm_stack" ] && INSTALL_PERFMON="y" && continue ;; + m) + [ "${OPTARG}" == "RO" ] && TO_REBUILD="$TO_REBUILD RO" && continue + [ "${OPTARG}" == "LCM" ] && TO_REBUILD="$TO_REBUILD LCM" && continue + [ "${OPTARG}" == "NBI" ] && TO_REBUILD="$TO_REBUILD NBI" && continue + [ "${OPTARG}" == "LW-UI" ] && TO_REBUILD="$TO_REBUILD LW-UI" && continue + [ "${OPTARG}" == "MON" ] && TO_REBUILD="$TO_REBUILD MON" && continue + [ "${OPTARG}" == "KAFKA" ] && TO_REBUILD="$TO_REBUILD KAFKA" && continue + [ "${OPTARG}" == "MONGO" ] && TO_REBUILD="$TO_REBUILD MONGO" && continue + [ "${OPTARG}" == "NONE" ] && TO_REBUILD="$TO_REBUILD NONE" && continue + ;; -) [ "${OPTARG}" == "help" ] && usage && exit 0 [ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && continue @@ -911,6 +942,8 @@ done [ -n "$NOCONFIGURE" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --noconfigure can only be used with --soui" [ -n "$RELEASE_DAILY" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --daily can only be used with --soui" [ -n "$INSTALL_NOLXD" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option: --nolxd cannot be used with --soui" +[ -n "$TO_REBUILD" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option: -m cannot be used with --soui" +[ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" != " NONE" ] && echo $TO_REBUILD | grep -q NONE && FATAL "Incompatible option: -m NONE cannot be used with other -m options" if [ -n "$SHOWOPTS" ]; then dump_vars