X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=scripts%2Finstall-openmano.sh;h=d46b22b2eb17f1055986dfee0230b863a0388807;hb=70d4c7a9aa85e92a7842b06a5b2ff05e32467fb7;hp=48e2a81d9991e7189da41d3a33750b5becf11186;hpb=89b3d840dfa2ae1aae544338fad79cf7703f4af4;p=osm%2FRO.git diff --git a/scripts/install-openmano.sh b/scripts/install-openmano.sh index 48e2a81d..d46b22b2 100755 --- a/scripts/install-openmano.sh +++ b/scripts/install-openmano.sh @@ -21,11 +21,9 @@ # contact with: nfvlabs@tid.es ## -#ONLY TESTED in Ubuntu 16.04 +#ONLY TESTED in Ubuntu 16.04 partially tested in Ubuntu 14.10 14.04 16.04, CentOS7 and RHEL7 #Get needed packages, source code and configure to run openmano #Ask for database user and password if not provided -# $1: database user -# $2: database password function usage(){ echo -e "usage: sudo $0 [OPTIONS]" @@ -39,6 +37,7 @@ function usage(){ echo -e " --develop: install last version for developers, and do not configure as a service" echo -e " --forcedb: reinstall mano_db DB, deleting previous database and creating a new one" echo -e " --noclone: assumes that openmano was cloned previously and that this script is run from the local repo" + echo -e " --no-install-packages: use this option to skip updating and installing the requires packages. This avoid wasting time if you are sure requires packages are present e.g. because of a previous installation" } function install_packages(){ @@ -77,6 +76,7 @@ QUIET_MODE="" DEVELOP="" FORCEDB="" NOCLONE="" +NO_PACKAGES="" while getopts ":u:p:hiq-:" o; do case "${o}" in u) @@ -99,6 +99,7 @@ while getopts ":u:p:hiq-:" o; do [ "${OPTARG}" == "forcedb" ] && FORCEDB="y" && continue [ "${OPTARG}" == "noclone" ] && NOCLONE="y" && continue [ "${OPTARG}" == "quiet" ] && export QUIET_MODE=yes && export DEBIAN_FRONTEND=noninteractive && continue + [ "${OPTARG}" == "no-install-packages" ] && export NO_PACKAGES=yes && continue echo -e "Invalid option: '--$OPTARG'\nTry $0 --help for more information" >&2 exit 1 ;; @@ -166,6 +167,8 @@ fi +if [[ -z "$NO_PACKAGES" ]] +then echo ' ################################################################# ##### UPDATE REPOSITORIES ##### @@ -178,7 +181,10 @@ echo ' && sudo rpm -ivh epel-release-7-5.noarch.rpm && sudo yum install -y epel-release && rm -f epel-release-7-5.noarch.rpm [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && sudo yum repolist +fi +if [[ -z "$NO_PACKAGES" ]] +then echo ' ################################################################# ##### INSTALL REQUIRED PACKAGES ##### @@ -210,6 +216,7 @@ then firewall-cmd --permanent --zone=public --add-service=https && firewall-cmd --reload fi +fi #[[ -z "$NO_PACKAGES" ]] #check and ask for database user password. Must be done after database installation if [[ -n $QUIET_MODE ]] @@ -228,6 +235,8 @@ then done fi +if [[ -z "$NO_PACKAGES" ]] +then echo ' ################################################################# ##### INSTALL PYTHON PACKAGES ##### @@ -241,6 +250,7 @@ echo ' #install openstack client needed for using openstack as a VIM [ "$_DISTRO" == "Ubuntu" ] && install_packages "python-novaclient python-keystoneclient python-glanceclient python-neutronclient" [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "python-devel" && easy_install python-novaclient python-keystoneclient python-glanceclient python-neutronclient #TODO revise if gcc python-pip is needed +fi #[[ -z "$NO_PACKAGES" ]] if [[ -z $NOCLONE ]]; then echo ' @@ -265,9 +275,7 @@ user=$DBUSER password=$DBPASSWD EOF -db_exists "mano_db" $TEMPFILE -DBEXISTS=$? -if [[ $DBEXISTS -eq 0 ]] ; then +if db_exists "mano_db" $TEMPFILE ; then if [[ -n $FORCEDB ]]; then echo " Deleting previous database mano_db" DBDELETEPARAM="" @@ -284,19 +292,26 @@ if [[ $DBEXISTS -eq 0 ]] ; then echo "Database exists. Use option '--forcedb' to force the deletion of the existing one" && exit 1 fi else - mysqladmin -u$DBUSER $DBPASSWD_PARAM -s create mano_db || ( echo "Error creating mano_db database" && exit 1 ) + mysqladmin -u$DBUSER $DBPASSWD_PARAM -s create mano_db || ! echo "Error creating mano_db database" || exit 1 echo "CREATE USER 'mano'@'localhost' identified by 'manopw';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1 echo "GRANT ALL PRIVILEGES ON mano_db.* TO 'mano'@'localhost';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1 echo " Database 'mano_db' created, user 'mano' password 'manopw'" fi +#Next operations require knowing OPENMANO_BASEFOLDER +HERE=$(realpath $(dirname $0)) +if [[ -z $NOCLONE ]]; then + OPENMANO_BASEFOLDER="${HERE}/openmano" +else + OPENMANO_BASEFOLDER=$(dirname $HERE) +fi + + echo ' ################################################################# ##### INIT DATABASE ##### #################################################################' -HERE=$(realpath $(dirname $0)) -OPENMANO_BASEFOLDER=$(dirname $HERE) su $SUDO_USER -c "${OPENMANO_BASEFOLDER}"'/database_utils/init_mano_db.sh -u mano -p manopw -d mano_db' || ! echo "Failed while initializing database" || exit 1