[WIP] Upgrade ONOS to karaf version 4.2.1

Change-Id: I7cd40c995bdf1c80f94b1895fb3344e32404c7fa
diff --git a/tools/package/etc/keys.properties b/tools/package/etc/keys.properties
new file mode 100644
index 0000000..463a0bb
--- /dev/null
+++ b/tools/package/etc/keys.properties
@@ -0,0 +1,35 @@
+################################################################################
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You 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.
+#
+################################################################################
+
+#
+# This file contains the valid users who can log into Karaf. Each line have to be of
+# the format:
+#
+# USER=KEY,ROLE1,ROLE2,...
+#
+# All users and roles entered in this file are available after Karaf startup
+# and modifiable via the JAAS command group. These users reside in a JAAS domain
+# with the name "karaf"..
+#
+
+#
+# For security reason, the default auto-signed key is disabled.
+# The user guide describes how to generate/update the key.
+#
+_g_\:admingroup = group,admin,manager,viewer,systembundles,ssh
diff --git a/tools/package/etc/org.apache.karaf.features.cfg b/tools/package/etc/org.apache.karaf.features.cfg
new file mode 100644
index 0000000..d986a57
--- /dev/null
+++ b/tools/package/etc/org.apache.karaf.features.cfg
@@ -0,0 +1,107 @@
+################################################################################
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You 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.
+#
+################################################################################
+
+#
+# Comma separated list of features repositories to register by default
+#
+featuresRepositories = \
+    mvn:org.apache.karaf.features/standard/4.2.1/xml/features, \
+    mvn:org.onosproject/onos-features/$ONOS_VERSION/xml/features, \
+    mvn:org.apache.karaf.features/enterprise/4.2.1/xml/features, \
+    mvn:org.apache.karaf.features/spring/4.2.1/xml/features, \
+    mvn:org.apache.karaf.features/standard/4.2.1/xml/features, \
+    mvn:org.apache.karaf.features/framework/4.2.1/xml/features
+
+#
+# Comma separated list of features to install at startup
+#
+featuresBoot = \
+    instance/4.2.1, \
+    package/4.2.1, \
+    log/4.2.1, \
+    ssh/4.2.1, \
+    framework/4.2.1, \
+    system/4.2.1, \
+    eventadmin/4.2.1, \
+    feature/4.2.1, \
+    shell/4.2.1, \
+    management/4.2.1, \
+    service/4.2.1, \
+    jaas/4.2.1, \
+    deployer/4.2.1, \
+    diagnostic/4.2.1, \
+    (wrap/2.5.4), \
+    bundle/4.2.1, \
+    config/4.2.1, \
+    kar/4.2.1, \
+    webconsole/4.2.1, \
+    scr/4.2.1, \
+    war/4.2.1, \
+    onos-api, \
+    onos-core, \
+    onos-incubator
+    #onos-cli,
+    #onos-gui,
+    #onos-rest
+
+
+#
+# Resource repositories (OBR) that the features resolver can use
+# to resolve requirements/capabilities
+#
+# The format of the resourceRepositories is
+# resourceRepositories=[xml:url|json:url],...
+# for Instance:
+#
+#resourceRepositories=xml:http://host/path/to/index.xml
+# or
+#resourceRepositories=json:http://host/path/to/index.json
+#
+
+#
+# Defines if the boot features are started in asynchronous mode (in a dedicated thread)
+#
+featuresBootAsynchronous=false
+
+#
+# Service requirements enforcement
+#
+# By default, the feature resolver checks the service requirements/capabilities of
+# bundles for new features (xml schema >= 1.3.0) in order to automatically installs
+# the required bundles.
+# The following flag can have those values:
+#   - disable: service requirements are completely ignored
+#   - default: service requirements are ignored for old features
+#   - enforce: service requirements are always verified
+#
+#serviceRequirements=default
+
+#
+# Store cfg file for config element in feature
+#
+#configCfgStore=true
+
+#
+# Configuration of features processing mechanism (overrides, blacklisting, modification of features)
+# XML file defines instructions related to features processing
+# versions.properties may declare properties to resolve placeholders in XML file
+# both files are relative to ${karaf.etc}
+#
+#featureProcessing=org.apache.karaf.features.xml
+#featureProcessingVersions=versions.properties
diff --git a/tools/package/etc/shell.init.script b/tools/package/etc/shell.init.script
new file mode 100644
index 0000000..ac55755
--- /dev/null
+++ b/tools/package/etc/shell.init.script
@@ -0,0 +1,65 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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.
+//
+// This script is run each time a shell is created.
+// You can define here closures or variables that will be available
+// in each session.
+//
+ld = { log:display $args } ;
+lde = { log:exception-display $args } ;
+la = { bundle:list -t 0 $args } ;
+ls = { service:list $args } ;
+cl = { config:list "(service.pid=$args)" } ;
+halt = { system:shutdown -h -f $args } ;
+help = { *:help $args | more } ;
+man = { help $args } ;
+log:list = { log:get ALL } ;
+service:get = { $.context getService ($.context getServiceReference $args) };
+
+env = { shell:set $args }
+edit = { shell:nano $args }
+more = { shell:less -F $args }
+
+\#prompt = { "${USER}@${APPLICATION} ${SUBSHELL}> "?};
+
+__load_class = {
+  (($.reader class) classLoader) loadClass $1
+}
+
+// make sure that we catch exceptions
+// as they do occur if the session is headless / non-interactive
+jlineReader = $.reader
+if { %(jlineReader != null) } {
+
+  # On 256 colors terminal, add a right prompt
+  max_colors = ($.jline.terminal getNumericCapability max_colors)
+  if { %(max_colors >= 256) } {
+    __rprompt_formatter = (((__load_class java.text.SimpleDateFormat) getConstructor (__load_class java.lang.String)) newInstance \'$'\u001B\[90m'\'HH:mm:ss)
+    __date_class = (__load_class java.util.Date)
+    \#rprompt = { $__rprompt_formatter format ($__date_class newInstance) }
+  }
+
+  setopt group
+  setopt auto-fresh-line
+  unsetopt insert-tab
+  keymap "^[OA" up-line-or-search
+  keymap "^[[A" up-line-or-search
+  keymap "^[OB" down-line-or-search
+  keymap "^[[B" down-line-or-search
+
+}
diff --git a/tools/package/etc/users.properties b/tools/package/etc/users.properties
index 95a97bc..cacc254 100644
--- a/tools/package/etc/users.properties
+++ b/tools/package/etc/users.properties
@@ -28,10 +28,11 @@
 # All users, groups, and roles entered in this file are available after Karaf startup
 # and modifiable via the JAAS command group. These users reside in a JAAS domain
 # with the name "karaf".
-#
 karaf = karaf,_g_:admingroup
 onos = rocks,_g_:admingroup
 guest = guest,_g_:guestgroup
-_g_\:admingroup = group,admin,manager,viewer,webconsole
+
+_g_\:admingroup = group,admin,manager,viewer,systembundles,ssh,webconsole
 _g_\:guestgroup = group,viewer
 
+