aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/tools/package/deb
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/tools/package/deb')
-rw-r--r--framework/src/onos/tools/package/deb/control8
-rw-r--r--framework/src/onos/tools/package/deb/copyright20
-rwxr-xr-xframework/src/onos/tools/package/deb/postinst16
-rwxr-xr-xframework/src/onos/tools/package/deb/postrm5
-rwxr-xr-xframework/src/onos/tools/package/deb/prerm23
5 files changed, 72 insertions, 0 deletions
diff --git a/framework/src/onos/tools/package/deb/control b/framework/src/onos/tools/package/deb/control
new file mode 100644
index 00000000..c581ac25
--- /dev/null
+++ b/framework/src/onos/tools/package/deb/control
@@ -0,0 +1,8 @@
+Package: onos
+Architecture: all
+Maintainer: ONOS Project
+Depends: debconf (>= 0.5.00), default-jre-headless (>= 1.8) | openjdk-8-jre | oracle-java8-installer
+Priority: optional
+Version: @ONOS_POM_VERSION
+Description: Open Network Operating System (ONOS)
+ Open Network Operating System (ONOS) is an opensource SDN controller.
diff --git a/framework/src/onos/tools/package/deb/copyright b/framework/src/onos/tools/package/deb/copyright
new file mode 100644
index 00000000..09ec05e3
--- /dev/null
+++ b/framework/src/onos/tools/package/deb/copyright
@@ -0,0 +1,20 @@
+Upstream-Name: onos
+Source: http://github.com/opennetworkinglab/onos
+
+Files: *
+Copyright: 2014-2015 Open Networking Laboratory
+License: Apache 2.0
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ .
+ http://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ .
+ On Debian systems, the complete text of the Apache License 2.0 can
+ be found in "/usr/share/common-licenses/Apache-2.0"
diff --git a/framework/src/onos/tools/package/deb/postinst b/framework/src/onos/tools/package/deb/postinst
new file mode 100755
index 00000000..60de14a7
--- /dev/null
+++ b/framework/src/onos/tools/package/deb/postinst
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+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
+
diff --git a/framework/src/onos/tools/package/deb/postrm b/framework/src/onos/tools/package/deb/postrm
new file mode 100755
index 00000000..90dd6164
--- /dev/null
+++ b/framework/src/onos/tools/package/deb/postrm
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# FIXME dpkg will remove /opt if it is empty after removing onos
+# We should recreate /opt if it was deleted.
+sudo mkdir -p /opt
diff --git a/framework/src/onos/tools/package/deb/prerm b/framework/src/onos/tools/package/deb/prerm
new file mode 100755
index 00000000..2a1633da
--- /dev/null
+++ b/framework/src/onos/tools/package/deb/prerm
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# 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'
+)
+
+# Clean up onos runtime directories
+# TODO don't hardcode karaf version
+rm -rf /opt/onos/apache-karaf-3.0.3/
+rm -rf /opt/onos/var/*
+rm -rf /opt/onos/config
+rm -rf /opt/onos/options
+rm -rf /opt/onos/log
+
+#TODO consider removing the sdn user if we created it