Newer
Older
garciadeblas
committed
track juju
[ -n "$INSTALL_NODOCKER" ] || install_docker_ce
garciadeblas
committed
track docker_ce
#install_docker_compose
[ -n "$INSTALL_NODOCKER" ] || init_docker_swarm
[ -z "$DOCKER_NOBUILD" ] && generate_docker_images
garciadeblas
committed
track docker_build
generate_docker_env_files
generate_config_log_folders
# remove old stack
remove_stack $OSM_STACK_NAME
create_docker_network
deploy_lightweight
garciadeblas
committed
track docker_deploy
[ -n "$INSTALL_VIMEMU" ] && install_vimemu && track vimemu
[ -n "$INSTALL_ELK" ] && deploy_elk && track elk
[ -n "$INSTALL_PERFMON" ] && deploy_perfmon && track perfmon
[ -z "$INSTALL_NOHOSTCLIENT" ] && install_osmclient
garciadeblas
committed
track osmclient
wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null
track end
return 0
}
function install_vimemu() {
echo "\nInstalling vim-emu"
EMUTEMPDIR="$(mktemp -d -q --tmpdir "installosmvimemu.XXXXXX")"
trap 'rm -rf "${EMUTEMPDIR}"' EXIT
# clone vim-emu repository (attention: branch is currently master only)
echo "Cloning vim-emu repository ..."
git clone https://osm.etsi.org/gerrit/osm/vim-emu.git $EMUTEMPDIR
# build vim-emu docker
echo "Building vim-emu Docker container..."
sg docker -c "docker build -t vim-emu-img -f $EMUTEMPDIR/Dockerfile --no-cache $EMUTEMPDIR/" || FATAL "cannot build vim-emu-img docker image"
# start vim-emu container as daemon
echo "Starting vim-emu Docker container 'vim-emu' ..."
if [ -n "$INSTALL_LIGHTWEIGHT" ]; then
# in lightweight mode, the emulator needs to be attached to netOSM
sg docker -c "docker run --name vim-emu -t -d --restart always --privileged --pid='host' --network=net${OSM_STACK_NAME} -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py"
else
# classic build mode
sg docker -c "docker run --name vim-emu -t -d --restart always --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py"
echo "Waiting for 'vim-emu' container to start ..."
sleep 5
export VIMEMU_HOSTNAME=$(sg docker -c "docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu")
echo "vim-emu running at ${VIMEMU_HOSTNAME} ..."
# print vim-emu connection info
echo -e "\nYou might be interested in adding the following vim-emu env variables to your .bashrc file:"
echo " export VIMEMU_HOSTNAME=${VIMEMU_HOSTNAME}"
echo -e "To add the emulated VIM to OSM you should do:"
echo " osm vim-create --name emu-vim1 --user username --password password --auth_url http://${VIMEMU_HOSTNAME}:6001/v2.0 --tenant tenantName --account_type openstack"
}
function dump_vars(){
echo "DEVELOP=$DEVELOP"
echo "INSTALL_FROM_SOURCE=$INSTALL_FROM_SOURCE"
echo "UNINSTALL=$UNINSTALL"
echo "NAT=$NAT"
echo "UPDATE=$UPDATE"
echo "RECONFIGURE=$RECONFIGURE"
echo "TEST_INSTALLER=$TEST_INSTALLER"
echo "INSTALL_VIMEMU=$INSTALL_VIMEMU"
echo "INSTALL_LXD=$INSTALL_LXD"
echo "INSTALL_FROM_LXDIMAGES=$INSTALL_FROM_LXDIMAGES"
echo "LXD_REPOSITORY_BASE=$LXD_REPOSITORY_BASE"
echo "LXD_REPOSITORY_PATH=$LXD_REPOSITORY_PATH"
echo "INSTALL_LIGHTWEIGHT=$INSTALL_LIGHTWEIGHT"
garciadeblas
committed
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 "INSTALL_NODOCKER=$INSTALL_NODOCKER"
echo "INSTALL_NOJUJU=$INSTALL_NOJUJU"
echo "RELEASE=$RELEASE"
echo "REPOSITORY=$REPOSITORY"
echo "REPOSITORY_BASE=$REPOSITORY_BASE"
echo "REPOSITORY_KEY=$REPOSITORY_KEY"
echo "NOCONFIGURE=$NOCONFIGURE"
echo "OSM_DEVOPS=$OSM_DEVOPS"
echo "OSM_VCA_HOST=$OSM_VCA_HOST"
echo "OSM_VCA_SECRET=$OSM_VCA_SECRET"
echo "NO_HOST_PORTS=$NO_HOST_PORTS"
echo "DOCKER_NOBUILD=$DOCKER_NOBUILD"
echo "WORKDIR_SUDO=$WORKDIR_SUDO"
echo "OSM_WORK_DIR=$OSM_STACK_NAME"
echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG"
echo "DOCKER_USER=$DOCKER_USER"
echo "OSM_STACK_NAME=$OSM_STACK_NAME"
echo "PULL_IMAGES=$PULL_IMAGES"
echo "SHOWOPTS=$SHOWOPTS"
echo "Install from specific refspec (-b): $COMMIT_ID"
}
function track(){
ctime=`date +%s`
duration=$((ctime - SESSION_ID))
url="http://www.woopra.com/track/ce?project=osm.etsi.org&cookie=${SESSION_ID}"
#url="${url}&ce_campaign_name=${CAMPAIGN_NAME}"
event_name="bin"
garciadeblas
committed
[ -z "$INSTALL_LIGHTWEIGHT" ] && [ -n "$INSTALL_FROM_SOURCE" ] && event_name="binsrc"
[ -z "$INSTALL_LIGHTWEIGHT" ] && [ -n "$INSTALL_FROM_LXDIMAGES" ] && event_name="lxd"
[ -n "$INSTALL_LIGHTWEIGHT" ] && event_name="lw"
event_name="${event_name}_$1"
url="${url}&event=${event_name}&ce_duration=${duration}"
wget -q -O /dev/null $url
}
UNINSTALL=""
DEVELOP=""
NAT=""
UPDATE=""
RECONFIGURE=""
TEST_INSTALLER=""
INSTALL_LXD=""
SHOWOPTS=""
COMMIT_ID=""
ASSUME_YES=""
INSTALL_FROM_SOURCE=""
RELEASE="ReleaseFOUR"
REPOSITORY="stable"
INSTALL_VIMEMU=""
INSTALL_FROM_LXDIMAGES=""
LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
LXD_REPOSITORY_PATH=""
INSTALL_LIGHTWEIGHT="y"
garciadeblas
committed
INSTALL_ONLY=""
INSTALL_ELK=""
INSTALL_PERFMON=""
TO_REBUILD=""
INSTALL_NODOCKER=""
INSTALL_NOHOSTCLIENT=""
NOCONFIGURE=""
RELEASE_DAILY=""
SESSION_ID=`date +%s`
OSM_DEVOPS=
OSM_VCA_HOST=
OSM_VCA_SECRET=
OSM_STACK_NAME=osm
NO_HOST_PORTS=""
DOCKER_NOBUILD=""
REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/debian"
WORKDIR_SUDO=sudo
OSM_WORK_DIR="/etc/osm"
DOCKER_USER=opensourcemano
PULL_IMAGES="y"
OSM_DATABASE_COMMONKEY=
while getopts ":hy-:b:r:k:u:R:l:p:D:o:m:H:S:s:w:t:U:" o; do
case "${o}" in
h)
usage && exit 0
;;
b)
COMMIT_ID=${OPTARG}
REPOSITORY="${OPTARG}"
REPO_ARGS+=(-r "$REPOSITORY")
RELEASE="${OPTARG}"
REPO_ARGS+=(-R "$RELEASE")
REPOSITORY_KEY="${OPTARG}"
REPO_ARGS+=(-k "$REPOSITORY_KEY")
REPOSITORY_BASE="${OPTARG}"
REPO_ARGS+=(-u "$REPOSITORY_BASE")
U)
DOCKER_USER="${OPTARG}"
;;
l)
LXD_REPOSITORY_BASE="${OPTARG}"
;;
p)
LXD_REPOSITORY_PATH="${OPTARG}"
;;
D)
OSM_DEVOPS="${OPTARG}"
;;
s)
OSM_STACK_NAME="${OPTARG}"
;;
H)
;;
w)
# when specifying workdir, do not use sudo for access
WORKDIR_SUDO=
OSM_WORK_DIR="${OPTARG}"
;;
garciadeblas
committed
o)
INSTALL_ONLY="y"
[ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
[ "${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" && PULL_IMAGES="" && continue
[ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
[ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
[ "${OPTARG}" == "nat" ] && NAT="y" && continue
[ "${OPTARG}" == "update" ] && UPDATE="y" && continue
[ "${OPTARG}" == "reconfigure" ] && RECONFIGURE="y" && continue
[ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue
[ "${OPTARG}" == "lxdinstall" ] && INSTALL_LXD="y" && continue
[ "${OPTARG}" == "nolxd" ] && INSTALL_NOLXD="y" && continue
[ "${OPTARG}" == "nodocker" ] && INSTALL_NODOCKER="y" && continue
[ "${OPTARG}" == "lxdimages" ] && INSTALL_FROM_LXDIMAGES="y" && continue
[ "${OPTARG}" == "lightweight" ] && INSTALL_LIGHTWEIGHT="y" && continue
garciadeblas
committed
[ "${OPTARG}" == "soui" ] && INSTALL_LIGHTWEIGHT="" && RELEASE="-R ReleaseTHREE" && REPOSITORY="-r stable" && continue
[ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
garciadeblas
committed
[ "${OPTARG}" == "elk_stack" ] && INSTALL_ELK="y" && continue
[ "${OPTARG}" == "pm_stack" ] && INSTALL_PERFMON="y" && continue
[ "${OPTARG}" == "noconfigure" ] && NOCONFIGURE="y" && continue
[ "${OPTARG}" == "showopts" ] && SHOWOPTS="y" && continue
[ "${OPTARG}" == "daily" ] && RELEASE_DAILY="y" && continue
[ "${OPTARG}" == "nohostports" ] && NO_HOST_PORTS="y" && continue
[ "${OPTARG}" == "nojuju" ] && INSTALL_NOJUJU="y" && continue
[ "${OPTARG}" == "nodockerbuild" ] && DOCKER_NOBUILD="y" && continue
[ "${OPTARG}" == "nohostclient" ] && INSTALL_NOHOSTCLIENT="y" && continue
[ "${OPTARG}" == "pullimages" ] && continue
echo -e "Invalid option: '--$OPTARG'\n" >&2
usage && exit 1
;;
\?)
echo -e "Invalid option: '-$OPTARG'\n" >&2
usage && exit 1
;;
y)
ASSUME_YES="y"
;;
*)
usage && exit 1
;;
esac
done
garciadeblas
committed
[ -n "$INSTALL_FROM_LXDIMAGES" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --lxd can only be used with --soui"
garciadeblas
committed
[ -n "$NAT" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --nat can only be used with --soui"
[ -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 "$INSTALL_NODOCKER" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option: --nodocker 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"
garciadeblas
committed
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
if [ -n "$SHOWOPTS" ]; then
dump_vars
exit 0
fi
[ -n "$RELEASE_DAILY" ] && echo -e "\nInstalling from daily build repo" && RELEASE="-R ReleaseTHREE-daily" && REPOSITORY="-r testing" && COMMIT_ID="master"
# if develop, we force master
[ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
need_packages="git jq wget curl tar"
echo -e "Checking required packages: $need_packages"
dpkg -l $need_packages &>/dev/null \
|| ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \
|| sudo apt-get update \
|| FATAL "failed to run apt-get update"
dpkg -l $need_packages &>/dev/null \
|| ! echo -e "Installing $need_packages requires root privileges." \
|| sudo apt-get install -y $need_packages \
|| FATAL "failed to install $need_packages"
if [ -z "$OSM_DEVOPS" ]; then
if [ -n "$TEST_INSTALLER" ]; then
echo -e "\nUsing local devops repo for OSM installation"
OSM_DEVOPS="$(dirname $(realpath $(dirname $0)))"
else
echo -e "\nCreating temporary dir for OSM installation"
OSM_DEVOPS="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
trap 'rm -rf "$OSM_DEVOPS"' EXIT
git clone https://osm.etsi.org/gerrit/osm/devops.git $OSM_DEVOPS
if [ -z "$COMMIT_ID" ]; then
echo -e "\nGuessing the current stable release"
LATEST_STABLE_DEVOPS=`git -C $OSM_DEVOPS tag -l v[0-9].* | sort -V | tail -n1`
[ -z "$LATEST_STABLE_DEVOPS" ] && echo "Could not find the current latest stable release" && exit 0
echo "Latest tag in devops repo: $LATEST_STABLE_DEVOPS"
COMMIT_ID="tags/$LATEST_STABLE_DEVOPS"
else
echo -e "\nDEVOPS Using commit $COMMIT_ID"
fi
git -C $OSM_DEVOPS checkout $COMMIT_ID
fi
fi
OSM_JENKINS="$OSM_DEVOPS/jenkins"
. $OSM_JENKINS/common/all_funcs
[ -n "$INSTALL_LIGHTWEIGHT" ] && [ -n "$UNINSTALL" ] && uninstall_lightweight && echo -e "\nDONE" && exit 0
[ -n "$UNINSTALL" ] && uninstall && echo -e "\nDONE" && exit 0
[ -n "$NAT" ] && nat && echo -e "\nDONE" && exit 0
[ -n "$UPDATE" ] && update && echo -e "\nDONE" && exit 0
[ -n "$RECONFIGURE" ] && configure && echo -e "\nDONE" && exit 0
garciadeblas
committed
[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_ELK" ] && deploy_elk
[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_PERFMON" ] && deploy_perfmon
[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_VIMEMU" ] && install_vimemu
[ -n "$INSTALL_ONLY" ] && echo -e "\nDONE" && exit 0
#Installation starts here
garciadeblas
committed
wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README.txt &> /dev/null
track start
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
[ -n "$INSTALL_LIGHTWEIGHT" ] && install_lightweight && echo -e "\nDONE" && exit 0
echo -e "\nInstalling OSM from refspec: $COMMIT_ID"
if [ -n "$INSTALL_FROM_SOURCE" ] && [ -z "$ASSUME_YES" ]; then
! ask_user "The installation will take about 75-90 minutes. Continue (Y/n)? " y && echo "Cancelled!" && exit 1
fi
echo -e "Checking required packages: lxd"
lxd --version &>/dev/null || FATAL "lxd not present, exiting."
[ -n "$INSTALL_LXD" ] && echo -e "\nInstalling and configuring lxd" && install_lxd
# use local devops for containers
export OSM_USE_LOCAL_DEVOPS=true
if [ -n "$INSTALL_FROM_SOURCE" ]; then #install from source
echo -e "\nCreating the containers and building from source ..."
$OSM_DEVOPS/jenkins/host/start_build RO --notest checkout $COMMIT_ID || FATAL "RO container build failed (refspec: '$COMMIT_ID')"
ro_is_up && track RO
$OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA container build failed"
vca_is_up && track VCA
$OSM_DEVOPS/jenkins/host/start_build MON || FATAL "MON install failed"
mon_is_up && track MON
$OSM_DEVOPS/jenkins/host/start_build SO checkout $COMMIT_ID || FATAL "SO container build failed (refspec: '$COMMIT_ID')"
$OSM_DEVOPS/jenkins/host/start_build UI checkout $COMMIT_ID || FATAL "UI container build failed (refspec: '$COMMIT_ID')"
#so_is_up && track SOUI
track SOUI
elif [ -n "$INSTALL_FROM_LXDIMAGES" ]; then #install from LXD images stored in OSM repo
echo -e "\nInstalling from lxd images ..."
install_from_lxdimages
else #install from binaries
echo -e "\nCreating the containers and installing from binaries ..."
$OSM_DEVOPS/jenkins/host/install RO ${REPO_ARGS[@]} || FATAL "RO install failed"
ro_is_up && track RO
$OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA install failed"
vca_is_up && track VCA
$OSM_DEVOPS/jenkins/host/install MON || FATAL "MON build failed"
mon_is_up && track MON
$OSM_DEVOPS/jenkins/host/install SO ${REPO_ARGS[@]} || FATAL "SO install failed"
$OSM_DEVOPS/jenkins/host/install UI ${REPO_ARGS[@]} || FATAL "UI install failed"
#so_is_up && track SOUI
track SOUI
fi
#Install iptables-persistent and configure NAT rules
[ -z "$NOCONFIGURE" ] && nat
#Configure components
[ -z "$NOCONFIGURE" ] && configure
#Install osmclient
[ -z "$NOCONFIGURE" ] && install_osmclient
#Install vim-emu (optional)
[ -n "$INSTALL_VIMEMU" ] && install_docker_ce && install_vimemu
wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null
track end
echo -e "\nDONE"