blob: df0a05d539b90dccc269b1a9acbe83ddbcbadce3 [file] [log] [blame]
Brian O'Connorac322442015-09-17 23:49:17 -07001Name: onos
2Version: @ONOS_RPM_VERSION
3Release: 1
4Summary: Open Networking Operating System (ONOS)
5Vendor: ONOS Project
6Packager: ONOS Project
7
8Group: Applications/Engineering
9License: Apache 2.0
10Requires: jre >= 1:8
11URL: http://www.onosproject.org
12Source0: %{name}-@ONOS_RPM_VERSION.tar.gz
13
14BuildArch: noarch
15BuildRoot: %{_tmppath}/%{name}-buildroot
16
17%description
18Open Network Operating System (ONOS) is an open source SDN controller.
19
20%prep
21%setup -q
22
23%install
24mkdir -p %{buildroot}
25cp -R * %{buildroot}
26
27%clean
28rm -rf %{buildroot}
29
30%files
31%defattr(-,root,root,-)
32/etc/init/onos.conf
33/opt/onos/
34
35%post
36ONOS_USER=sdn
37
38# Check to see if user exists, and if not, create a service account
39getent passwd $ONOS_USER >/dev/null 2&>1 || ( useradd -M $ONOS_USER && usermod -L $ONOS_USER )
40
41# Create ONOS options file
42[ ! -f /opt/onos/options ] && cat << EOF > /opt/onos/options
43export ONOS_OPTS=server
44export ONOS_USER="$ONOS_USER"
45EOF
46
47# Change permissions for onos directory
48[ -d /opt/onos ] && chown -R $ONOS_USER.$ONOS_USER /opt/onos
49
50echo ONOS successfully installed at /opt/onos
51
52%preun
53# Check if onos is running; if it is, stop onos
54[ -z "$(status onos 2>/dev/null | grep start)" ] && echo "onos is not running." || (
55 stop onos
56
57 # Wait for onos to stop up to 5 seconds
58 for i in $(seq 1 5); do
59 [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && break
60 sleep 1
61 done
62 [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && echo 'Stopped onos service' || echo 'Failed to stop onos'
63)
64
65%postun
66#TODO this should be less brute-force
67rm -rf /opt/onos
68
69%changelog
70# TODO
71