blob: 5f0867f69f8c5c3f5c925aabd38707bdcb79a58f [file] [log] [blame]
tiernof7aa8c42016-09-06 16:43:04 +02001#!/bin/bash
2
3##
4# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
tierno9a61c6b2016-09-08 10:57:02 +02005# This file is part of openvim
tiernof7aa8c42016-09-06 16:43:04 +02006# All Rights Reserved.
7#
8# Licensed under the Apache License, Version 2.0 (the "License"); you may
9# not use this file except in compliance with the License. You may obtain
10# a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17# License for the specific language governing permissions and limitations
18# under the License.
19#
20# For those usages not covered by the Apache License, Version 2.0 please
21# contact with: nfvlabs@tid.es
22##
23
tierno9a61c6b2016-09-08 10:57:02 +020024#ONLY TESTED for Ubuntu 14.10 14.04 16.04, CentOS7 and RHEL7
tiernof7aa8c42016-09-06 16:43:04 +020025#Get needed packages, source code and configure to run openvim
26#Ask for database user and password if not provided
tiernof7aa8c42016-09-06 16:43:04 +020027
tierno1c84ac02016-12-07 16:27:21 +010028
29
tiernof7aa8c42016-09-06 16:43:04 +020030function usage(){
tierno9a61c6b2016-09-08 10:57:02 +020031 echo -e "usage: sudo $0 [OPTIONS]"
32 echo -e "Install last stable source code in ./openvim and the needed packages"
33 echo -e "On a Ubuntu 16.04 it configures openvim as a service"
34 echo -e " OPTIONS"
35 echo -e " -u USER: database admin user. 'root' by default. Prompts if needed"
36 echo -e " -p PASS: database admin password to be used or installed. Prompts if needed"
37 echo -e " -q --quiet: install in an unattended mode"
38 echo -e " -h --help: show this help"
39 echo -e " --develop: install last version for developers, and do not configure as a service"
tierno1c84ac02016-12-07 16:27:21 +010040 echo -e " --force: makes idenpotent, delete previous installations folders if needed"
41 echo -e " --noclone: assumes that openvim was cloned previously and that this script is run from the local repo"
42 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"
mirabald87877c2017-03-31 15:15:52 +020043 echo -e " --no-db: do not insall mysql server"
tiernof7aa8c42016-09-06 16:43:04 +020044}
45
46function install_packages(){
47 [ -x /usr/bin/apt-get ] && apt-get install -y $*
48 [ -x /usr/bin/yum ] && yum install -y $*
49
50 #check properly installed
51 for PACKAGE in $*
52 do
53 PACKAGE_INSTALLED="no"
54 [ -x /usr/bin/apt-get ] && dpkg -l $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
55 [ -x /usr/bin/yum ] && yum list installed $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
56 if [ "$PACKAGE_INSTALLED" = "no" ]
57 then
58 echo "failed to install package '$PACKAGE'. Revise network connectivity and try again"
59 exit -1
60 fi
61 done
62}
63
tierno1c84ac02016-12-07 16:27:21 +010064function db_exists() {
mirabal9cc283f2017-04-26 12:44:14 +020065 RESULT=`mysqlshow --defaults-extra-file="$2" | grep -v Wildcard | grep -w $1`
tierno1c84ac02016-12-07 16:27:21 +010066 if [ "$RESULT" == "$1" ]; then
67 echo " DB $1 exists"
68 return 0
69 fi
70 echo " DB $1 does not exist"
71 return 1
72}
73
tiernof7aa8c42016-09-06 16:43:04 +020074
tierno9a61c6b2016-09-08 10:57:02 +020075GIT_URL=https://osm.etsi.org/gerrit/osm/openvim.git
76DBUSER="root"
77DBPASSWD=""
78DBPASSWD_PARAM=""
79QUIET_MODE=""
80DEVELOP=""
tierno1c84ac02016-12-07 16:27:21 +010081FORCE=""
82NOCLONE=""
tierno9a61c6b2016-09-08 10:57:02 +020083NO_PACKAGES=""
mirabald87877c2017-03-31 15:15:52 +020084NO_DB=""
85
tierno9a61c6b2016-09-08 10:57:02 +020086while getopts ":u:p:hiq-:" o; do
87 case "${o}" in
88 u)
89 export DBUSER="$OPTARG"
90 ;;
91 p)
92 export DBPASSWD="$OPTARG"
93 export DBPASSWD_PARAM="-p$OPTARG"
94 ;;
95 q)
96 export QUIET_MODE=yes
97 export DEBIAN_FRONTEND=noninteractive
98 ;;
99 h)
100 usage && exit 0
101 ;;
102 -)
103 [ "${OPTARG}" == "help" ] && usage && exit 0
104 [ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
mirabald87877c2017-03-31 15:15:52 +0200105 [ "${OPTARG}" == "force" ] && FORCE="y" && continue
tierno1c84ac02016-12-07 16:27:21 +0100106 [ "${OPTARG}" == "noclone" ] && NOCLONE="y" && continue
tierno9a61c6b2016-09-08 10:57:02 +0200107 [ "${OPTARG}" == "quiet" ] && export QUIET_MODE=yes && export DEBIAN_FRONTEND=noninteractive && continue
tierno1c84ac02016-12-07 16:27:21 +0100108 [ "${OPTARG}" == "no-install-packages" ] && export NO_PACKAGES=yes && continue
mirabald87877c2017-03-31 15:15:52 +0200109 [ "${OPTARG}" == "no-db" ] && NO_DB="y" && continue
tierno9a61c6b2016-09-08 10:57:02 +0200110 echo -e "Invalid option: '--$OPTARG'\nTry $0 --help for more information" >&2
111 exit 1
112 ;;
113 \?)
114 echo -e "Invalid option: '-$OPTARG'\nTry $0 --help for more information" >&2
115 exit 1
116 ;;
117 :)
118 echo -e "Option '-$OPTARG' requires an argument\nTry $0 --help for more information" >&2
119 exit 1
120 ;;
121 *)
122 usage >&2
123 exit -1
124 ;;
125 esac
126done
127
128#check root privileges and non a root user behind
129[ "$USER" != "root" ] && echo "Needed root privileges" >&2 && exit -1
130if [[ -z "$SUDO_USER" ]] || [[ "$SUDO_USER" = "root" ]]
131then
132 [[ -z $QUIET_MODE ]] && read -e -p "Install in the root user (y/N)?" KK
133 [[ -z $QUIET_MODE ]] && [[ "$KK" != "y" ]] && [[ "$KK" != "yes" ]] && echo "Cancelled" && exit 1
134 export SUDO_USER=root
135fi
tiernof7aa8c42016-09-06 16:43:04 +0200136
137#Discover Linux distribution
138#try redhat type
139[ -f /etc/redhat-release ] && _DISTRO=$(cat /etc/redhat-release 2>/dev/null | cut -d" " -f1)
140#if not assuming ubuntu type
141[ -f /etc/redhat-release ] || _DISTRO=$(lsb_release -is 2>/dev/null)
142if [ "$_DISTRO" == "Ubuntu" ]
143then
tierno9a61c6b2016-09-08 10:57:02 +0200144 _RELEASE=$(lsb_release -rs)
145 if [[ ${_RELEASE%%.*} != 14 ]] && [[ ${_RELEASE%%.*} != 16 ]]
146 then
147 [[ -z $QUIET_MODE ]] && read -e -p "WARNING! Not tested Ubuntu version. Continue assuming a trusty (14.XX)'? (y/N)" KK
148 [[ -z $QUIET_MODE ]] && [[ "$KK" != "y" ]] && [[ "$KK" != "yes" ]] && echo "Cancelled" && exit 1
149 _RELEASE = 14
tiernof7aa8c42016-09-06 16:43:04 +0200150 fi
151elif [ "$_DISTRO" == "CentOS" ]
152then
153 _RELEASE="7"
154 if ! cat /etc/redhat-release | grep -q "7."
155 then
156 read -e -p "WARNING! Not tested CentOS version. Continue assuming a '_RELEASE' type? (y/N)" KK
157 [ "$KK" != "y" -a "$KK" != "yes" ] && echo "Cancelled" && exit 0
158 fi
159elif [ "$_DISTRO" == "Red" ]
160then
161 _RELEASE="7"
162 if ! cat /etc/redhat-release | grep -q "7."
163 then
164 read -e -p "WARNING! Not tested Red Hat OS version. Continue assuming a '_RELEASE' type? (y/N)" KK
165 [ "$KK" != "y" -a "$KK" != "yes" ] && echo "Cancelled" && exit 0
166 fi
167else #[ "$_DISTRO" != "Ubuntu" -a "$_DISTRO" != "CentOS" -a "$_DISTRO" != "Red" ]
168 _DISTRO_DISCOVER=$_DISTRO
169 [ -x /usr/bin/apt-get ] && _DISTRO="Ubuntu" && _RELEASE="14"
170 [ -x /usr/bin/yum ] && _DISTRO="CentOS" && _RELEASE="7"
171 read -e -p "WARNING! Not tested Linux distribution '$_DISTRO_DISCOVER '. Continue assuming a '$_DISTRO $_RELEASE' type? (y/N)" KK
172 [ "$KK" != "y" -a "$KK" != "yes" ] && echo "Cancelled" && exit 0
173fi
174
tierno1c84ac02016-12-07 16:27:21 +0100175#check if installed as a service
176INSTALL_AS_A_SERVICE=""
177[[ "$_DISTRO" == "Ubuntu" ]] && [[ ${_RELEASE%%.*} == 16 ]] && [[ -z $DEVELOP ]] && INSTALL_AS_A_SERVICE="y"
178
179#Next operations require knowing BASEFOLDER
180if [[ -z "$NOCLONE" ]]; then
181 if [[ -n "$INSTALL_AS_A_SERVICE" ]] ; then
182 OPENVIM_BASEFOLDER=__openvim__${RANDOM}
183 else
184 OPENVIM_BASEFOLDER="${PWD}/openvim"
185 fi
186 [[ -n "$FORCE" ]] && rm -rf $OPENVIM_BASEFOLDER #make idempotent
187else
mirabal9cc283f2017-04-26 12:44:14 +0200188 HERE=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
tierno1c84ac02016-12-07 16:27:21 +0100189 OPENVIM_BASEFOLDER=$(dirname $HERE)
190fi
191
tiernof7aa8c42016-09-06 16:43:04 +0200192
tierno9a61c6b2016-09-08 10:57:02 +0200193if [[ -z "$NO_PACKAGES" ]]
194then
tiernof7aa8c42016-09-06 16:43:04 +0200195echo '
196#################################################################
197##### UPDATE REPOSITORIES #####
198#################################################################'
199[ "$_DISTRO" == "Ubuntu" ] && apt-get update -y
200
201[ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && yum check-update -y
202[ "$_DISTRO" == "CentOS" ] && sudo yum install -y epel-release
203[ "$_DISTRO" == "Red" ] && wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm \
204 && sudo rpm -ivh epel-release-7-5.noarch.rpm && sudo yum install -y epel-release && rm -f epel-release-7-5.noarch.rpm
205[ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && sudo yum repolist
tierno9a61c6b2016-09-08 10:57:02 +0200206fi
tiernof7aa8c42016-09-06 16:43:04 +0200207
tierno9a61c6b2016-09-08 10:57:02 +0200208if [[ -z "$NO_PACKAGES" ]]
209then
tiernof7aa8c42016-09-06 16:43:04 +0200210echo '
211#################################################################
212##### INSTALL REQUIRED PACKAGES #####
213#################################################################'
tierno9a61c6b2016-09-08 10:57:02 +0200214[ "$_DISTRO" == "Ubuntu" ] && install_packages "git screen wget mysql-server"
215[ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "git screen wget mariadb mariadb-server"
216
217if [[ "$_DISTRO" == "Ubuntu" ]]
218then
219 #start services. By default CentOS does not start services
220 service mysql start >> /dev/null
221 # try to set admin password, ignore if fails
222 [[ -n $DBPASSWD ]] && mysqladmin -u $DBUSER -s password $DBPASSWD
223fi
tiernof7aa8c42016-09-06 16:43:04 +0200224
225if [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ]
226then
227 #start services. By default CentOS does not start services
228 service mariadb start
229 service httpd start
230 systemctl enable mariadb
231 systemctl enable httpd
232 read -e -p "Do you want to configure mariadb (recomended if not done before) (Y/n)" KK
233 [ "$KK" != "n" -a "$KK" != "no" ] && mysql_secure_installation
234
235 read -e -p "Do you want to set firewall to grant web access port 80,443 (Y/n)" KK
236 [ "$KK" != "n" -a "$KK" != "no" ] &&
237 firewall-cmd --permanent --zone=public --add-service=http &&
238 firewall-cmd --permanent --zone=public --add-service=https &&
239 firewall-cmd --reload
240fi
tierno9a61c6b2016-09-08 10:57:02 +0200241fi #[[ -z "$NO_PACKAGES" ]]
tiernof7aa8c42016-09-06 16:43:04 +0200242
tierno9a61c6b2016-09-08 10:57:02 +0200243#check and ask for database user password. Must be done after database installation
244if [[ -n $QUIET_MODE ]]
245then
246 echo -e "\nCheking database connection and ask for credentials"
tierno2594a3a2016-10-13 13:11:31 +0000247 while ! mysqladmin -s -u$DBUSER $DBPASSWD_PARAM status >/dev/null
tierno9a61c6b2016-09-08 10:57:02 +0200248 do
tiernof7aa8c42016-09-06 16:43:04 +0200249 [ -n "$logintry" ] && echo -e "\nInvalid database credentials!!!. Try again (Ctrl+c to abort)"
250 [ -z "$logintry" ] && echo -e "\nProvide database credentials"
251 read -e -p "database user? ($DBUSER) " DBUSER_
252 [ -n "$DBUSER_" ] && DBUSER=$DBUSER_
253 read -e -s -p "database password? (Enter for not using password) " DBPASSWD_
tierno9a61c6b2016-09-08 10:57:02 +0200254 [ -n "$DBPASSWD_" ] && DBPASSWD="$DBPASSWD_" && DBPASSWD_PARAM="-p$DBPASSWD_"
255 [ -z "$DBPASSWD_" ] && DBPASSWD="" && DBPASSWD_PARAM=""
tiernof7aa8c42016-09-06 16:43:04 +0200256 logintry="yes"
tierno9a61c6b2016-09-08 10:57:02 +0200257 done
258fi
tiernof7aa8c42016-09-06 16:43:04 +0200259
tierno9a61c6b2016-09-08 10:57:02 +0200260if [[ -z "$NO_PACKAGES" ]]
261then
mirabald87877c2017-03-31 15:15:52 +0200262
tiernof7aa8c42016-09-06 16:43:04 +0200263echo '
264#################################################################
265##### INSTALL PYTHON PACKAGES #####
266#################################################################'
tierno9a61c6b2016-09-08 10:57:02 +0200267[ "$_DISTRO" == "Ubuntu" ] && install_packages "python-yaml python-libvirt python-bottle python-mysqldb python-jsonschema python-paramiko python-argcomplete python-requests"
268[ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "PyYAML libvirt-python MySQL-python python-jsonschema python-paramiko python-argcomplete python-requests"
tiernof7aa8c42016-09-06 16:43:04 +0200269
270#The only way to install python-bottle on Centos7 is with easy_install or pip
271[ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && easy_install -U bottle
272
tierno9a61c6b2016-09-08 10:57:02 +0200273fi #[[ -z "$NO_PACKAGES" ]]
274
tierno1c84ac02016-12-07 16:27:21 +0100275if [[ -z $NOCLONE ]]; then
276 echo '
tiernof7aa8c42016-09-06 16:43:04 +0200277#################################################################
278##### DOWNLOAD SOURCE #####
279#################################################################'
tierno1c84ac02016-12-07 16:27:21 +0100280 if [[ -d "${OPENVIM_BASEFOLDER}" ]]
281 then
282 if [[ -n "$FORCE" ]]
283 then
284 echo "deleting '${OPENVIM_BASEFOLDER}' folder"
285 rm -rf "$OPENVIM_BASEFOLDER" #make idempotent
286 elif [[ -z "$QUIET_MODE" ]]
287 then
288 read -e -p "${OPENVIM_BASEFOLDER} folder exist, overwrite? (y/N)" KK
289 if [[ "$KK" == "y" ]] || [[ "$KK" == "yes" ]]
290 then rm -rf "$OPENVIM_BASEFOLDER"
291 else
292 echo "canceled"
293 exit 1
294 fi
295 else
296 echo "'${OPENVIM_BASEFOLDER}' folder exist" >&2 && exit 1
297 fi
298 fi
tierno9a61c6b2016-09-08 10:57:02 +0200299
tierno1c84ac02016-12-07 16:27:21 +0100300
301 su $SUDO_USER -c "git clone ${GIT_URL} ${OPENVIM_BASEFOLDER}"
302 su $SUDO_USER -c "cp ${OPENVIM_BASEFOLDER}/.gitignore-common ${OPENVIM_BASEFOLDER}/.gitignore"
mirabal9cc283f2017-04-26 12:44:14 +0200303 [[ -z $DEVELOP ]] && su $SUDO_USER -c "git -C ${OPENVIM_BASEFOLDER} checkout v2.0"
tierno1c84ac02016-12-07 16:27:21 +0100304fi
tiernof7aa8c42016-09-06 16:43:04 +0200305
mirabal9cc283f2017-04-26 12:44:14 +0200306DB_QUIET=''
307if [ -z "$NO_DB" ]; then
308 if [ -n "$QUIET_MODE" ]; then
309 DB_QUIET='-q'
310 fi
311
312 echo "!!!! install-db-server.sh: ${OPENVIM_BASEFOLDER}/database_utils/install-db-server.sh -U $DBUSER $DBPASSWD_PARAM $DB_QUIET"
313 ${OPENVIM_BASEFOLDER}/database_utils/install-db-server.sh -U $DBUSER $DBPASSWD_PARAM $DB_QUIET || exit 1
314fi
tiernof7aa8c42016-09-06 16:43:04 +0200315
316
317if [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ]
318then
319 echo '
320#################################################################
321##### CONFIGURE firewalld #####
322#################################################################'
323 read -e -p "Configure firewalld for openvimd port 9080? (Y/n)" KK
324 if [ "$KK" != "n" -a "$KK" != "no" ]
325 then
326 #Creates a service file for openvim
327 echo '<?xml version="1.0" encoding="utf-8"?>
328<service>
329 <short>openvimd</short>
330 <description>openvimd service</description>
331 <port protocol="tcp" port="9080"/>
332</service>' > /etc/firewalld/services/openvimd.xml
333 #put proper permissions
334 pushd /etc/firewalld/services > /dev/null
335 restorecon openvim
336 chmod 640 openvim
337 popd > /dev/null
338 #Add the openvim service to the default zone permanently and reload the firewall configuration
339 firewall-cmd --permanent --add-service=openvim > /dev/null
340 firewall-cmd --reload > /dev/null
341 echo "done."
342 else
343 echo "skipping."
344 fi
345fi
346
347echo '
348#################################################################
tierno9a61c6b2016-09-08 10:57:02 +0200349##### CONFIGURE openvim CLIENT #####
tiernof7aa8c42016-09-06 16:43:04 +0200350#################################################################'
tierno1c84ac02016-12-07 16:27:21 +0100351#creates a link at ~/bin if not configured as a service
352if [[ -z "$INSTALL_AS_A_SERVICE" ]]
tierno9a61c6b2016-09-08 10:57:02 +0200353then
tierno1c84ac02016-12-07 16:27:21 +0100354 su $SUDO_USER -c 'mkdir -p ~/bin'
355 su $SUDO_USER -c 'rm -f ${HOME}/bin/openvim'
356 su $SUDO_USER -c 'rm -f ${HOME}/bin/openflow'
357 su $SUDO_USER -c 'rm -f ${HOME}/bin/service-openvim'
358 su $SUDO_USER -c 'rm -f ${HOME}/bin/initopenvim'
359 su $SUDO_USER -c 'rm -f ${HOME}/bin/service-floodlight'
360 su $SUDO_USER -c 'rm -f ${HOME}/bin/service-opendaylight'
361 su $SUDO_USER -c 'rm -f ${HOME}/bin/get_dhcp_lease.sh'
362 su $SUDO_USER -c "ln -s '${OPENVIM_BASEFOLDER}/openvim' "'${HOME}/bin/openvim'
363 su $SUDO_USER -c "ln -s '${OPENVIM_BASEFOLDER}/openflow' "'${HOME}/bin/openflow'
mirabal9cc283f2017-04-26 12:44:14 +0200364 su $SUDO_USER -c "ln -s '${OPENVIM_BASEFOLDER}/scripts/service-openvim' "'${HOME}/bin/service-openvim'
365 su $SUDO_USER -c "ln -s '${OPENVIM_BASEFOLDER}/scripts/initopenvim' "'${HOME}/bin/initopenvim'
366 su $SUDO_USER -c "ln -s '${OPENVIM_BASEFOLDER}/scripts/service-floodlight' "'${HOME}/bin/service-floodlight'
367 su $SUDO_USER -c "ln -s '${OPENVIM_BASEFOLDER}/scripts/service-opendaylight' "'${HOME}/bin/service-opendaylight'
tierno1c84ac02016-12-07 16:27:21 +0100368 su $SUDO_USER -c "ln -s '${OPENVIM_BASEFOLDER}/scripts/get_dhcp_lease.sh' "'${HOME}/bin/get_dhcp_lease.sh'
369
370 #insert /home/<user>/bin in the PATH
371 #skiped because normally this is done authomatically when ~/bin exist
372 #if ! su $SUDO_USER -c 'echo $PATH' | grep -q "/home/${SUDO_USER}/bin"
373 #then
374 # echo " inserting /home/$SUDO_USER/bin in the PATH at .bashrc"
375 # su $SUDO_USER -c 'echo "PATH=\$PATH:/home/\${USER}/bin" >> ~/.bashrc'
376 #fi
377
378 if [[ $SUDO_USER == root ]]
tierno9a61c6b2016-09-08 10:57:02 +0200379 then
tierno1c84ac02016-12-07 16:27:21 +0100380 if ! echo $PATH | grep -q "${HOME}/bin"
381 then
382 echo "PATH=\$PATH:\${HOME}/bin" >> ${HOME}/.bashrc
383 fi
tierno9a61c6b2016-09-08 10:57:02 +0200384 fi
385fi
386
tiernof7aa8c42016-09-06 16:43:04 +0200387#configure arg-autocomplete for this user
388#in case of minmal instalation this package is not installed by default
389[[ "$_DISTRO" == "CentOS" || "$_DISTRO" == "Red" ]] && yum install -y bash-completion
390#su $SUDO_USER -c 'mkdir -p ~/.bash_completion.d'
391su $SUDO_USER -c 'activate-global-python-argcomplete --user'
tierno3e9a1472016-09-20 11:05:26 +0000392if ! grep -q bash_completion.d/python-argcomplete.sh ${HOME}/.bashrc
tiernof7aa8c42016-09-06 16:43:04 +0200393then
394 echo " inserting .bash_completion.d/python-argcomplete.sh execution at .bashrc"
tierno3e9a1472016-09-20 11:05:26 +0000395 su $SUDO_USER -c 'echo ". ${HOME}/.bash_completion.d/python-argcomplete.sh" >> ~/.bashrc'
tiernof7aa8c42016-09-06 16:43:04 +0200396fi
397
tiernof7aa8c42016-09-06 16:43:04 +0200398
399
tierno1c84ac02016-12-07 16:27:21 +0100400if [[ -n "$INSTALL_AS_A_SERVICE" ]]
tierno9a61c6b2016-09-08 10:57:02 +0200401then
402echo '
403#################################################################
tierno3e9a1472016-09-20 11:05:26 +0000404##### CONFIGURE OPENVIM SERVICE #####
tierno9a61c6b2016-09-08 10:57:02 +0200405#################################################################'
tiernof7aa8c42016-09-06 16:43:04 +0200406
tierno36d22632016-12-16 00:22:32 +0100407 DELETE_PARAM="" && [[ -z "$NOCLONE" ]] && DELETE_PARAM="-d"
408 ${OPENVIM_BASEFOLDER}/scripts/install-openvim-service.sh -f ${OPENVIM_BASEFOLDER} ${DELETE_PARAM}
tierno9a61c6b2016-09-08 10:57:02 +0200409# alias service-openvim="service openvim"
410# echo 'alias service-openvim="service openvim"' >> ${HOME}/.bashrc
411
412 echo
tierno1c84ac02016-12-07 16:27:21 +0100413 echo
414 echo "Done! installed at /opt/openvim"
tierno9a61c6b2016-09-08 10:57:02 +0200415 echo " Manage server with 'service openvim start|stop|status|...' "
416
417
418else
419
420 echo
421 echo "Done! you may need to logout and login again for loading client configuration"
tierno1c84ac02016-12-07 16:27:21 +0100422 echo " Run 'service-openvim start' for starting openvim in a screen"
tierno9a61c6b2016-09-08 10:57:02 +0200423
424fi