Updating onos-package for debian packaging
Change-Id: Icc3899b3a35ba0a02a97f5eddebfbe51ff6c1638
diff --git a/tools/package/deb/postinst b/tools/package/deb/postinst
new file mode 100755
index 0000000..60de14a
--- /dev/null
+++ b/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
+