aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/tools/package/rpm
diff options
context:
space:
mode:
authorAshlee Young <ashlee@onosfw.com>2015-09-22 12:49:09 -0700
committerAshlee Young <ashlee@onosfw.com>2015-09-22 12:49:09 -0700
commit81391595dca425ae58e2294898f09f11d9a32dbc (patch)
treef5d65c39a732150b2b29daa8de98a35d1236d3fb /framework/src/onos/tools/package/rpm
parent0aa37e73dcb3a55b8d889b0c32ff74055551b1f3 (diff)
bringing src to commit tag 65d551b50e782b0c1ea76c1a9ed1c5a801a5a7e4
Change-Id: Ib2da78962eaef856f418636c31b0f5c84286244f
Diffstat (limited to 'framework/src/onos/tools/package/rpm')
-rw-r--r--framework/src/onos/tools/package/rpm/onos.spec71
1 files changed, 71 insertions, 0 deletions
diff --git a/framework/src/onos/tools/package/rpm/onos.spec b/framework/src/onos/tools/package/rpm/onos.spec
new file mode 100644
index 00000000..df0a05d5
--- /dev/null
+++ b/framework/src/onos/tools/package/rpm/onos.spec
@@ -0,0 +1,71 @@
+Name: onos
+Version: @ONOS_RPM_VERSION
+Release: 1
+Summary: Open Networking Operating System (ONOS)
+Vendor: ONOS Project
+Packager: ONOS Project
+
+Group: Applications/Engineering
+License: Apache 2.0
+Requires: jre >= 1:8
+URL: http://www.onosproject.org
+Source0: %{name}-@ONOS_RPM_VERSION.tar.gz
+
+BuildArch: noarch
+BuildRoot: %{_tmppath}/%{name}-buildroot
+
+%description
+Open Network Operating System (ONOS) is an open source SDN controller.
+
+%prep
+%setup -q
+
+%install
+mkdir -p %{buildroot}
+cp -R * %{buildroot}
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+/etc/init/onos.conf
+/opt/onos/
+
+%post
+ONOS_USER=sdn
+
+# Check to see if user exists, and if not, create a service account
+getent passwd $ONOS_USER >/dev/null 2&>1 || ( useradd -M $ONOS_USER && usermod -L $ONOS_USER )
+
+# Create ONOS options file
+[ ! -f /opt/onos/options ] && cat << EOF > /opt/onos/options
+export ONOS_OPTS=server
+export ONOS_USER="$ONOS_USER"
+EOF
+
+# Change permissions for onos directory
+[ -d /opt/onos ] && chown -R $ONOS_USER.$ONOS_USER /opt/onos
+
+echo ONOS successfully installed at /opt/onos
+
+%preun
+# Check if onos is running; if it is, stop onos
+[ -z "$(status onos 2>/dev/null | grep start)" ] && echo "onos is not running." || (
+ stop onos
+
+ # Wait for onos to stop up to 5 seconds
+ for i in $(seq 1 5); do
+ [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && break
+ sleep 1
+ done
+ [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && echo 'Stopped onos service' || echo 'Failed to stop onos'
+)
+
+%postun
+#TODO this should be less brute-force
+rm -rf /opt/onos
+
+%changelog
+# TODO
+