a9d0c37e1c2b85d5b12552bc74646ec271416497
4 # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
5 # This file is part of openmano
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
12 # http://www.apache.org/licenses/LICENSE-2.0
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
20 # For those usages not covered by the Apache License, Version 2.0 please
21 # contact with: nfvlabs@tid.es
24 #ONLY TESTED for Ubuntu 16.04
25 #it configures openmano to run as a service
28 echo -e "usage: sudo $0 [OPTIONS]"
29 echo -e "Configures openmano to run as a service"
31 echo -e " -u USER user to run openmano, 'root' by default"
32 echo -e " -f PATH path where openmano source is located. If missing it download from git"
33 echo -e " -q: install in an unattended mode"
34 echo -e " -h: show this help"
42 while getopts ":u:f:hq-:" o
; do
57 [ "${OPTARG}" == "help" ] && usage
&& exit 0
58 echo -e "Invalid option: '--$OPTARG'\nTry $0 --help for more information" >&2
62 echo -e "Invalid option: '-$OPTARG'\nTry $0 --help for more information" >&2
66 echo -e "Option '-$OPTARG' requires an argument\nTry $0 --help for more information" >&2
76 #check root privileges and non a root user behind
77 [ "$USER" != "root" ] && echo "Needed root privileges" >&2 && exit 1
79 #Discover Linux distribution
81 [ -f /etc
/redhat-release
] && _DISTRO
=$
(cat /etc
/redhat-release
2>/dev
/null | cut
-d" " -f1)
82 #if not assuming ubuntu type
83 [ -f /etc
/redhat-release
] || _DISTRO
=$
(lsb_release
-is 2>/dev
/null
)
84 if [ "$_DISTRO" == "Ubuntu" ]
86 _RELEASE
=`lsb_release -rs`
87 if ! lsb_release
-rs |
grep -q -e "16.04"
89 echo "Only tested in Ubuntu Server 16.04" >&2 && exit 1
92 echo "Only tested in Ubuntu Server 16.04" >&2 && exit 1
98 git clone https
://osm.etsi.org
/gerrit
/osm
/RO.git openmano
102 cp -r $FILE /opt
/openmano
103 cp ${FILE}/openmano
/usr
/sbin
/
104 mv /opt
/openmano
/openmanod.cfg
/etc
/default
/openmanod.cfg
105 mkdir
-p /var
/log
/openmano
/
106 mkdir
-p etc
/systemd
/system
/
109 cat >> /etc
/systemd
/system
/openmano.service
<< EOF
111 Description=openmano server
115 ExecStart=/opt/openmano/openmanod.py -c /etc/default/openmanod.cfg --log-file=/var/log/openmano/openmano.log
119 WantedBy=multi-user.target
122 [[ -n $DELETE ]] && rm -rf $FILE
124 service openmano start