| Version: @ONOS_RPM_VERSION |
| Summary: Open Networking Operating System (ONOS) |
| Group: Applications/Engineering |
| URL: http://www.onosproject.org |
| Source0: %{name}-@ONOS_RPM_VERSION.tar.gz |
| BuildRoot: %{_tmppath}/%{name}-buildroot |
| Open Network Operating System (ONOS) is an open source SDN controller. |
| # 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_USER="$ONOS_USER" |
| # Change permissions for onos directory |
| [ -d /opt/onos ] && chown -R $ONOS_USER.$ONOS_USER /opt/onos |
| echo ONOS successfully installed at /opt/onos |
| # Check if onos is running; if it is, stop onos |
| [ -z "$(status onos 2>/dev/null | grep start)" ] && echo "onos is not running." || ( |
| # Wait for onos to stop up to 5 seconds |
| [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && break |
| [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && echo 'Stopped onos service' || echo 'Failed to stop onos' |
| #TODO this should be less brute-force |