From e5f0a90e2b04ab33c97e333c3eac7b39a3e35a3f Mon Sep 17 00:00:00 2001 From: Theo Weiss Date: Sun, 21 Feb 2016 23:07:44 +0100 Subject: [PATCH 1/9] deb files build initial commit --- .../src/main/resources/deb/bin/oh2_dir_layout | 17 ++ .../main/resources/deb/bin/setpermissions.sh | 0 .../resources/deb/conf/services/addons.cfg | 27 +++ .../resources/deb/control-runtime/control | 10 ++ .../resources/deb/control-runtime/postinst | 43 +++++ .../main/resources/deb/control-runtime/postrm | 42 +++++ .../resources/deb/control-runtime/preinst | 24 +++ .../main/resources/deb/control-runtime/prerm | 33 ++++ .../main/resources/deb/etc/default/openhab2 | 1 + .../main/resources/deb/etc/init.d/openhab2 | 117 +++++++++++++ .../resources/deb/systemd/openhab2.service | 21 +++ distributions/openhab-offline/pom.xml | 23 ++- .../src/main/descriptors/archive.xml | 1 + distributions/openhab-online/pom.xml | 10 ++ .../src/main/descriptors/archive.xml | 1 + distributions/pom.xml | 156 ++++++++++++++++++ 16 files changed, 519 insertions(+), 7 deletions(-) create mode 100644 distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout create mode 100644 distributions/distribution-resources/src/main/resources/deb/bin/setpermissions.sh create mode 100644 distributions/distribution-resources/src/main/resources/deb/conf/services/addons.cfg create mode 100644 distributions/distribution-resources/src/main/resources/deb/control-runtime/control create mode 100644 distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst create mode 100644 distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm create mode 100644 distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst create mode 100644 distributions/distribution-resources/src/main/resources/deb/control-runtime/prerm create mode 100644 distributions/distribution-resources/src/main/resources/deb/etc/default/openhab2 create mode 100644 distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 create mode 100644 distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service diff --git a/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout b/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout new file mode 100644 index 0000000000..d7e174b2c9 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout @@ -0,0 +1,17 @@ +#!/bin/sh + +# DIRNAME is the directory of karaf, setenv, etc. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +export OPENHAB_HOME=`cd "$DIRNAME/../../.."; pwd` +export OPENHAB_CONF="/etc/openhab2" +export OPENHAB_RUNTIME="${OPENHAB_HOME}/runtime" +export OPENHAB_USERDATA="/var/lib/openhab2" + +export KARAF_HOME="${OPENHAB_RUNTIME}/karaf" +export KARAF_DATA="${OPENHAB_USERDATA}" +export KARAF_BASE="${OPENHAB_USERDATA}" +export KARAF_ETC="${OPENHAB_RUNTIME}/karaf/etc" + + + diff --git a/distributions/distribution-resources/src/main/resources/deb/bin/setpermissions.sh b/distributions/distribution-resources/src/main/resources/deb/bin/setpermissions.sh new file mode 100644 index 0000000000..e69de29bb2 diff --git a/distributions/distribution-resources/src/main/resources/deb/conf/services/addons.cfg b/distributions/distribution-resources/src/main/resources/deb/conf/services/addons.cfg new file mode 100644 index 0000000000..747d8cf50d --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/conf/services/addons.cfg @@ -0,0 +1,27 @@ +# The base installation package of this openHAB instance +# Valid options: +# - minimal : Installation only with dashboard, but no UIs or other addons +# - standard : Typical installation with all standards UIs +# - demo : A demo setup which includes UIs, a few bindings, config files etc. +package = standard + +# A comma-separated list of bindings to install (e.g. "sonos,knx,zwave") +binding = + +# A comma-separated list of UIs to install (e.g. "basic,paper") +ui = + +# A comma-separated list of persistence services to install (e.g. "rrd4j,jpa") +persistence = + +# A comma-separated list of actions to install (e.g. "mail,pushover") +action = + +# A comma-separated list of transformation services to install (e.g. "map,jsonpath") +transformation = + +# A comma-separated list of text-to-speech engines to install (e.g. "marytts,freetts") +tts = + +# A comma-separated list of miscellaneous services to install (e.g. "myopenhab") +misc = diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/control b/distributions/distribution-resources/src/main/resources/deb/control-runtime/control new file mode 100644 index 0000000000..c303fcdfd0 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/control @@ -0,0 +1,10 @@ +Package: [[deb.name]] +Version: [[version]] +Section: [[deb.section]] +Priority: optional +Architecture: all +Maintainer: [[deb.maintainer]] +Description: [[deb.description]] +Distribution: [[deb.distribution]] +Depends: adduser +Homepage: http://www.openhab.org diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst new file mode 100644 index 0000000000..2db680272e --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst @@ -0,0 +1,43 @@ +#!/bin/sh + +set -e + +[ -f /etc/default/openhab2 ] && . /etc/default/openhab2 + +startOpenHAB() { + if [ -x /bin/systemctl ] ; then + /bin/systemctl daemon-reload + /bin/systemctl start openhab2.service + elif [ -x "/etc/init.d/openhab2" ]; then + if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then + invoke-rc.d openhab2 start || true + else + /etc/init.d/openhab2 start || true + fi + fi +} + +case "$1" in + configure) + # if $2 is set, this is an upgrade + if [ -n $2 ] ; then + startOpenHAB + # this is a fresh installation + else + if [ -x /bin/systemctl ] ; then + echo "### NOT starting on installation, please execute the following statements to configure openHAB to start automatically using systemd" + echo " sudo /bin/systemctl daemon-reload" + echo " sudo /bin/systemctl enable openhab2.service" + echo "### You can start openhab2 by executing" + echo " sudo /bin/systemctl start openhab2.service" + elif [ -x /usr/sbin/update-rc.d ] ; then + echo "### NOT starting openhab2 by default on bootup, please execute" + echo " sudo update-rc.d openhab2 defaults" + echo "### In order to start openhab2, execute" + echo " sudo /etc/init.d/openhab2 start" + fi + fi + ;; +esac + +exit 0 diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm new file mode 100644 index 0000000000..9a359cea24 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +OH_USER=openhab2 +OH_GROUP=openhab2 + +removeOpenHABInit() { + if [ -x /bin/systemctl ] ; then + /bin/systemctl --no-reload disable openhab2.service > /dev/null 2>&1 || : + else + update-rc.d openhab2 remove > /dev/null 2>&1 || : + fi +} + +case "$1" in + remove) + removeOpenHABInit + ;; + purge) + removeOpenHABInit + if getent passwd $OH_USER > /dev/null 2>&1; then + deluser --system --quiet $OH_USER || true + fi + if getent group $OH_GROUP > /dev/null 2>&1; then + delgroup --system --quiet $OH_GROUP || true + fi + rm -rf /var/log/openhab2 + rm -rf /var/lib/openhab2 + rm -rf /usr/share/openhab2 + rm -rf /etc/openhab2 + exit 0 + ;; + abort-install|abort-upgrade|disappear|failed-upgrade|upgrade) + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst b/distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst new file mode 100644 index 0000000000..107e357ee8 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst @@ -0,0 +1,24 @@ +#!/bin/sh + +set -e + +case "$1" in + install) + OH_USER=openhab2 + OH_GROUP=openhab2 + if [ x"${USER_AND_GROUP}" != x ]; then + OH_USER=`echo ${USER_AND_GROUP} | cut -d ":" -f 1` + OH_GROUP=`echo ${USER_AND_GROUP} | cut -d ":" -f 2` + fi + if ! getent group "$OH_GROUP" > /dev/null 2>&1 ; then + addgroup --system "$OH_GROUP" --quiet + fi + if ! getent passwd "$OH_USER" > /dev/null 2>&1 ; then + adduser --quiet --system --ingroup "$OH_GROUP" --no-create-home \ + --disabled-password --shell /bin/false \ + --gecos "openhab2 runtime user" --home /var/lib/openhab2 "$OH_USER" + fi + ;; +esac + +exit 0 diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/prerm b/distributions/distribution-resources/src/main/resources/deb/control-runtime/prerm new file mode 100644 index 0000000000..722cc2fdc9 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/prerm @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e + +[ -f /etc/default/openhab2 ] && . /etc/default/openhab2 + +stopOpenHAB() { + if [ -x /bin/systemctl ] ; then + /bin/systemctl --no-reload stop openhab2.service > /dev/null 2>&1 || : + elif [ -x "/etc/init.d/openhab2" ]; then + if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then + invoke-rc.d openhab2 stop + else + /etc/init.d/openhab2 stop + fi + # waiting for the openhab2 process stop (max 10 seconds), otherwise the removal of the user will fail. + # workaround /etc/init.d/openhab2 stop the service needs some time to stop + sleep 5 + fi +} + +case "$1" in + upgrade) + stopOpenHAB + ;; + remove|deconfigure) + stopOpenHAB + ;; + failed-upgrade) + ;; +esac + +exit 0 diff --git a/distributions/distribution-resources/src/main/resources/deb/etc/default/openhab2 b/distributions/distribution-resources/src/main/resources/deb/etc/default/openhab2 new file mode 100644 index 0000000000..73212dcb22 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/etc/default/openhab2 @@ -0,0 +1 @@ +EXTRA_JAVA_OPTS="" diff --git a/distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 b/distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 new file mode 100644 index 0000000000..8aec042dff --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 @@ -0,0 +1,117 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: openhab2 +# Required-Start: $all +# Required-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: openHAB2 server +# Description: Start / Stop openHAB2 server +### END INIT INFO + +# Author: openHAB +# + + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +OPENHAB_INST_DIR="/usr/share/openhab2" + +DESC="openHAB2 server" +NAME=openhab2 +JAVA="/usr/bin/java" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME +SETOWNER=yes + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +# Read configuration variable file if it is present +[ -r /etc/default/openhab2 ] && . /etc/default/openhab2 + +OPENHAB_CONF_DIR="/etc/openhab2" +OPENHAB_DIR="/usr/share/openhab2" +OPENHAB_HOME_DIR="/var/lib/openhab2" +OPENHAB_USER_DATA_DIR="${OPENHAB_HOME_DIR}" + +if [ -z "$USER_AND_GROUP" ]; then + USER_AND_GROUP="openhab2:openhab2" +fi + +if [ x"${OPENHAB_JAVA}" != x ]; then + JAVA="${OPENHAB_JAVA}" +fi + +if [ -n ${EXTRA_JAVA_OPTS} ]; then + export EXTRA_JAVA_OPTS +fi + +if [ ! -x "${JAVA}" ]; then + log_failure_msg "no java executable found at ${JAVA}" + exit 2 +fi + +USER=`echo ${USER_AND_GROUP} | cut -d ":" -f 1` +GROUP=`echo ${USER_AND_GROUP} | cut -d ":" -f 2` + +#Check whether the specified user exists +if ! getent passwd "${USER}" > /dev/null 2>&1; then + log_failure_msg "runtime user doesn't exists" + exit 2 +fi + +#Check whether the specified group exists +if ! getent group "${GROUP}" > /dev/null 2>&1; then + log_failure_msg "runtime group doesn't exists" + exit 2 +fi + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +case "$1" in + start) + log_daemon_msg "Starting $DESC" "$NAME" + #${OPENHAB_INST_DIR}/bin/setpermissions.sh > /dev/null + if start-stop-daemon --start --quiet --pidfile $PIDFILE -c "${USER_AND_GROUP}" --umask 002 --background --make-pidfile --chdir ${OPENHAB_DIR} \ + --oknodo --exec /usr/share/openhab2/runtime/karaf/bin/start + then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + stop) + log_daemon_msg "Stopping $DESC" "$NAME" + if /usr/share/openhab2/runtime/karaf/bin/stop + then + rm -f $PIDFILE + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + status) + /usr/share/openhab2/runtime/karaf/bin/status + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "$NAME" + if /usr/share/openhab2/runtime/karaf/bin/stop + then + if /usr/share/openhab2/runtime/karaf/bin/start + then + log_end_msg 0 + else + log_end_msg 1 + fi + else + log_end_msg 1 + fi + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac diff --git a/distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service b/distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service new file mode 100644 index 0000000000..eacff19198 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service @@ -0,0 +1,21 @@ +[Unit] +Description=Starts and stops the openHAB Home Automation Bus +Documentation=http://www.openhab.org +Wants=network-online.target +After=network-online.target + +[Service] +EnvironmentFile=/etc/default/openhab2 +User=openhab2 +Group=openhab2 +WorkingDirectory=/usr/share/openhab2 +#PermissionsStartOnly=true +#ExecStartPre=/usr/share/openhab/bin/setpermissions.sh +ExecStart=/usr/share/openhab2/start.sh server +ExecStop=/usr/share/openhab2/runtime/karaf/bin/stop +# Shutdown delay in seconds, before process is tried to be killed with KILL (if configured) +TimeoutStopSec=120 +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/distributions/openhab-offline/pom.xml b/distributions/openhab-offline/pom.xml index 3871be5c74..1b2e95bf70 100644 --- a/distributions/openhab-offline/pom.xml +++ b/distributions/openhab-offline/pom.xml @@ -14,6 +14,12 @@ openHAB Offline Distribution This is an offline distribution of openHAB + + openhab2-offline + openhab-offline-${project.version}.tar.gz + + + org.apache.karaf.features @@ -45,11 +51,11 @@ - org.openhab.distro.deps - pax-web-jetty - 4.2.3.sp1 - provided - + org.openhab.distro.deps + pax-web-jetty + 4.2.3.sp1 + provided + @@ -151,7 +157,10 @@ + + jdeb + org.vafer + - - + diff --git a/distributions/openhab-offline/src/main/descriptors/archive.xml b/distributions/openhab-offline/src/main/descriptors/archive.xml index a5ad201281..82e6721d3a 100644 --- a/distributions/openhab-offline/src/main/descriptors/archive.xml +++ b/distributions/openhab-offline/src/main/descriptors/archive.xml @@ -3,6 +3,7 @@ archive zip + tar.gz false diff --git a/distributions/openhab-online/pom.xml b/distributions/openhab-online/pom.xml index 025f52f843..7898aa90db 100644 --- a/distributions/openhab-online/pom.xml +++ b/distributions/openhab-online/pom.xml @@ -14,6 +14,12 @@ openHAB Online Distribution This is the online distribution of openHAB + + openhab2-online + openhab-online-${project.version}.tar.gz + + + org.apache.karaf.features @@ -192,6 +198,10 @@ + + jdeb + org.vafer + diff --git a/distributions/openhab-online/src/main/descriptors/archive.xml b/distributions/openhab-online/src/main/descriptors/archive.xml index e09b6e13cf..51fd19b942 100644 --- a/distributions/openhab-online/src/main/descriptors/archive.xml +++ b/distributions/openhab-online/src/main/descriptors/archive.xml @@ -3,6 +3,7 @@ archive zip + tar.gz false diff --git a/distributions/pom.xml b/distributions/pom.xml index fbc0ef67fc..3ea77de286 100644 --- a/distributions/pom.xml +++ b/distributions/pom.xml @@ -12,6 +12,12 @@ pom-distributions openHAB Distributions + + ${project.name} + openHAB <admin@openhab.org> + misc + development + pom @@ -20,4 +26,154 @@ openhab-online + + + + + jdeb + org.vafer + 1.5 + + + runtime + package + + jdeb + + + ${basedir}/../distribution-resources/src/main/resources/deb/control-runtime + ${basedir}/target/${deb.name}-${project.version}.deb + + + template + + etc/openhab2 + usr/share/openhab2 + usr/share/openhab2/bin + var/lib/openhab2 + var/lib/openhab2/persistence/db4o + var/lib/openhab2/persistence/rrd4j + var/lib/openhab2/persistence/mapdb + var/log/openhab2 + + + perm + openhab2 + openhab2 + + + + ${basedir}/../distribution-resources/src/main/resources/deb/etc/default/openhab2 + file + true + + perm + /etc/default + root + root + + + + ${basedir}/../distribution-resources/src/main/resources/deb/etc/init.d/openhab2 + file + + perm + /etc/init.d + 755 + root + root + + + + ${basedir}/../distribution-resources/src/main/resources/deb/bin/setpermissions.sh + file + + perm + /usr/share/openhab2/bin + 755 + root + root + + + + ${basedir}/../distribution-resources/src/main/resources/deb/systemd/openhab2.service + file + + perm + /usr/lib/systemd/system + 644 + root + root + + + + ${basedir}/target/${deb.srcarchive} + archive + conf/**,userdata/**,runtime/karaf/bin/oh2_dir_layout,start.bat,start_debug.bat + + perm + /usr/share/openhab2 + openhab2 + openhab2 + + + + ${basedir}/target/${deb.srcarchive} + archive + conf/** + conf/services/addons.cfg + true + + perm + 1 + /etc/openhab2 + openhab2 + openhab2 + + + + ${basedir}/target/${deb.srcarchive} + archive + userdata/** + true + + perm + 1 + /var/lib/openhab2 + openhab2 + openhab2 + + + + ${basedir}/../distribution-resources/src/main/resources/deb/bin/oh2_dir_layout + file + + perm + /usr/share/openhab2/runtime/karaf/bin + 755 + openhab2 + openhab2 + + + + ${basedir}/../distribution-resources/src/main/resources/deb/conf/services/addons.cfg + file + true + + perm + /etc/openhab2/services + 644 + openhab2 + openhab2 + + + + + + + + + + + \ No newline at end of file From 50cd04a242f5a67ca493a28fab923701eda84143 Mon Sep 17 00:00:00 2001 From: Theo Weiss Date: Sun, 21 Feb 2016 23:07:44 +0100 Subject: [PATCH 2/9] deb files build initial commit --- .../src/main/resources/deb/bin/oh2_dir_layout | 17 ++ .../main/resources/deb/bin/setpermissions.sh | 0 .../resources/deb/conf/services/addons.cfg | 27 +++ .../resources/deb/control-runtime/control | 10 ++ .../resources/deb/control-runtime/postinst | 43 +++++ .../main/resources/deb/control-runtime/postrm | 42 +++++ .../resources/deb/control-runtime/preinst | 24 +++ .../main/resources/deb/control-runtime/prerm | 33 ++++ .../main/resources/deb/etc/default/openhab2 | 1 + .../main/resources/deb/etc/init.d/openhab2 | 117 +++++++++++++ .../resources/deb/systemd/openhab2.service | 21 +++ distributions/openhab-offline/pom.xml | 23 ++- .../src/main/descriptors/archive.xml | 1 + distributions/openhab-online/pom.xml | 10 ++ .../src/main/descriptors/archive.xml | 1 + distributions/pom.xml | 156 ++++++++++++++++++ 16 files changed, 519 insertions(+), 7 deletions(-) create mode 100644 distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout create mode 100644 distributions/distribution-resources/src/main/resources/deb/bin/setpermissions.sh create mode 100644 distributions/distribution-resources/src/main/resources/deb/conf/services/addons.cfg create mode 100644 distributions/distribution-resources/src/main/resources/deb/control-runtime/control create mode 100644 distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst create mode 100644 distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm create mode 100644 distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst create mode 100644 distributions/distribution-resources/src/main/resources/deb/control-runtime/prerm create mode 100644 distributions/distribution-resources/src/main/resources/deb/etc/default/openhab2 create mode 100644 distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 create mode 100644 distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service diff --git a/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout b/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout new file mode 100644 index 0000000000..d7e174b2c9 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout @@ -0,0 +1,17 @@ +#!/bin/sh + +# DIRNAME is the directory of karaf, setenv, etc. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +export OPENHAB_HOME=`cd "$DIRNAME/../../.."; pwd` +export OPENHAB_CONF="/etc/openhab2" +export OPENHAB_RUNTIME="${OPENHAB_HOME}/runtime" +export OPENHAB_USERDATA="/var/lib/openhab2" + +export KARAF_HOME="${OPENHAB_RUNTIME}/karaf" +export KARAF_DATA="${OPENHAB_USERDATA}" +export KARAF_BASE="${OPENHAB_USERDATA}" +export KARAF_ETC="${OPENHAB_RUNTIME}/karaf/etc" + + + diff --git a/distributions/distribution-resources/src/main/resources/deb/bin/setpermissions.sh b/distributions/distribution-resources/src/main/resources/deb/bin/setpermissions.sh new file mode 100644 index 0000000000..e69de29bb2 diff --git a/distributions/distribution-resources/src/main/resources/deb/conf/services/addons.cfg b/distributions/distribution-resources/src/main/resources/deb/conf/services/addons.cfg new file mode 100644 index 0000000000..747d8cf50d --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/conf/services/addons.cfg @@ -0,0 +1,27 @@ +# The base installation package of this openHAB instance +# Valid options: +# - minimal : Installation only with dashboard, but no UIs or other addons +# - standard : Typical installation with all standards UIs +# - demo : A demo setup which includes UIs, a few bindings, config files etc. +package = standard + +# A comma-separated list of bindings to install (e.g. "sonos,knx,zwave") +binding = + +# A comma-separated list of UIs to install (e.g. "basic,paper") +ui = + +# A comma-separated list of persistence services to install (e.g. "rrd4j,jpa") +persistence = + +# A comma-separated list of actions to install (e.g. "mail,pushover") +action = + +# A comma-separated list of transformation services to install (e.g. "map,jsonpath") +transformation = + +# A comma-separated list of text-to-speech engines to install (e.g. "marytts,freetts") +tts = + +# A comma-separated list of miscellaneous services to install (e.g. "myopenhab") +misc = diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/control b/distributions/distribution-resources/src/main/resources/deb/control-runtime/control new file mode 100644 index 0000000000..c303fcdfd0 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/control @@ -0,0 +1,10 @@ +Package: [[deb.name]] +Version: [[version]] +Section: [[deb.section]] +Priority: optional +Architecture: all +Maintainer: [[deb.maintainer]] +Description: [[deb.description]] +Distribution: [[deb.distribution]] +Depends: adduser +Homepage: http://www.openhab.org diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst new file mode 100644 index 0000000000..2db680272e --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst @@ -0,0 +1,43 @@ +#!/bin/sh + +set -e + +[ -f /etc/default/openhab2 ] && . /etc/default/openhab2 + +startOpenHAB() { + if [ -x /bin/systemctl ] ; then + /bin/systemctl daemon-reload + /bin/systemctl start openhab2.service + elif [ -x "/etc/init.d/openhab2" ]; then + if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then + invoke-rc.d openhab2 start || true + else + /etc/init.d/openhab2 start || true + fi + fi +} + +case "$1" in + configure) + # if $2 is set, this is an upgrade + if [ -n $2 ] ; then + startOpenHAB + # this is a fresh installation + else + if [ -x /bin/systemctl ] ; then + echo "### NOT starting on installation, please execute the following statements to configure openHAB to start automatically using systemd" + echo " sudo /bin/systemctl daemon-reload" + echo " sudo /bin/systemctl enable openhab2.service" + echo "### You can start openhab2 by executing" + echo " sudo /bin/systemctl start openhab2.service" + elif [ -x /usr/sbin/update-rc.d ] ; then + echo "### NOT starting openhab2 by default on bootup, please execute" + echo " sudo update-rc.d openhab2 defaults" + echo "### In order to start openhab2, execute" + echo " sudo /etc/init.d/openhab2 start" + fi + fi + ;; +esac + +exit 0 diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm new file mode 100644 index 0000000000..9a359cea24 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +OH_USER=openhab2 +OH_GROUP=openhab2 + +removeOpenHABInit() { + if [ -x /bin/systemctl ] ; then + /bin/systemctl --no-reload disable openhab2.service > /dev/null 2>&1 || : + else + update-rc.d openhab2 remove > /dev/null 2>&1 || : + fi +} + +case "$1" in + remove) + removeOpenHABInit + ;; + purge) + removeOpenHABInit + if getent passwd $OH_USER > /dev/null 2>&1; then + deluser --system --quiet $OH_USER || true + fi + if getent group $OH_GROUP > /dev/null 2>&1; then + delgroup --system --quiet $OH_GROUP || true + fi + rm -rf /var/log/openhab2 + rm -rf /var/lib/openhab2 + rm -rf /usr/share/openhab2 + rm -rf /etc/openhab2 + exit 0 + ;; + abort-install|abort-upgrade|disappear|failed-upgrade|upgrade) + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst b/distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst new file mode 100644 index 0000000000..107e357ee8 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst @@ -0,0 +1,24 @@ +#!/bin/sh + +set -e + +case "$1" in + install) + OH_USER=openhab2 + OH_GROUP=openhab2 + if [ x"${USER_AND_GROUP}" != x ]; then + OH_USER=`echo ${USER_AND_GROUP} | cut -d ":" -f 1` + OH_GROUP=`echo ${USER_AND_GROUP} | cut -d ":" -f 2` + fi + if ! getent group "$OH_GROUP" > /dev/null 2>&1 ; then + addgroup --system "$OH_GROUP" --quiet + fi + if ! getent passwd "$OH_USER" > /dev/null 2>&1 ; then + adduser --quiet --system --ingroup "$OH_GROUP" --no-create-home \ + --disabled-password --shell /bin/false \ + --gecos "openhab2 runtime user" --home /var/lib/openhab2 "$OH_USER" + fi + ;; +esac + +exit 0 diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/prerm b/distributions/distribution-resources/src/main/resources/deb/control-runtime/prerm new file mode 100644 index 0000000000..722cc2fdc9 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/prerm @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e + +[ -f /etc/default/openhab2 ] && . /etc/default/openhab2 + +stopOpenHAB() { + if [ -x /bin/systemctl ] ; then + /bin/systemctl --no-reload stop openhab2.service > /dev/null 2>&1 || : + elif [ -x "/etc/init.d/openhab2" ]; then + if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then + invoke-rc.d openhab2 stop + else + /etc/init.d/openhab2 stop + fi + # waiting for the openhab2 process stop (max 10 seconds), otherwise the removal of the user will fail. + # workaround /etc/init.d/openhab2 stop the service needs some time to stop + sleep 5 + fi +} + +case "$1" in + upgrade) + stopOpenHAB + ;; + remove|deconfigure) + stopOpenHAB + ;; + failed-upgrade) + ;; +esac + +exit 0 diff --git a/distributions/distribution-resources/src/main/resources/deb/etc/default/openhab2 b/distributions/distribution-resources/src/main/resources/deb/etc/default/openhab2 new file mode 100644 index 0000000000..73212dcb22 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/etc/default/openhab2 @@ -0,0 +1 @@ +EXTRA_JAVA_OPTS="" diff --git a/distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 b/distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 new file mode 100644 index 0000000000..8aec042dff --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 @@ -0,0 +1,117 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: openhab2 +# Required-Start: $all +# Required-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: openHAB2 server +# Description: Start / Stop openHAB2 server +### END INIT INFO + +# Author: openHAB +# + + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +OPENHAB_INST_DIR="/usr/share/openhab2" + +DESC="openHAB2 server" +NAME=openhab2 +JAVA="/usr/bin/java" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME +SETOWNER=yes + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +# Read configuration variable file if it is present +[ -r /etc/default/openhab2 ] && . /etc/default/openhab2 + +OPENHAB_CONF_DIR="/etc/openhab2" +OPENHAB_DIR="/usr/share/openhab2" +OPENHAB_HOME_DIR="/var/lib/openhab2" +OPENHAB_USER_DATA_DIR="${OPENHAB_HOME_DIR}" + +if [ -z "$USER_AND_GROUP" ]; then + USER_AND_GROUP="openhab2:openhab2" +fi + +if [ x"${OPENHAB_JAVA}" != x ]; then + JAVA="${OPENHAB_JAVA}" +fi + +if [ -n ${EXTRA_JAVA_OPTS} ]; then + export EXTRA_JAVA_OPTS +fi + +if [ ! -x "${JAVA}" ]; then + log_failure_msg "no java executable found at ${JAVA}" + exit 2 +fi + +USER=`echo ${USER_AND_GROUP} | cut -d ":" -f 1` +GROUP=`echo ${USER_AND_GROUP} | cut -d ":" -f 2` + +#Check whether the specified user exists +if ! getent passwd "${USER}" > /dev/null 2>&1; then + log_failure_msg "runtime user doesn't exists" + exit 2 +fi + +#Check whether the specified group exists +if ! getent group "${GROUP}" > /dev/null 2>&1; then + log_failure_msg "runtime group doesn't exists" + exit 2 +fi + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +case "$1" in + start) + log_daemon_msg "Starting $DESC" "$NAME" + #${OPENHAB_INST_DIR}/bin/setpermissions.sh > /dev/null + if start-stop-daemon --start --quiet --pidfile $PIDFILE -c "${USER_AND_GROUP}" --umask 002 --background --make-pidfile --chdir ${OPENHAB_DIR} \ + --oknodo --exec /usr/share/openhab2/runtime/karaf/bin/start + then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + stop) + log_daemon_msg "Stopping $DESC" "$NAME" + if /usr/share/openhab2/runtime/karaf/bin/stop + then + rm -f $PIDFILE + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + status) + /usr/share/openhab2/runtime/karaf/bin/status + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "$NAME" + if /usr/share/openhab2/runtime/karaf/bin/stop + then + if /usr/share/openhab2/runtime/karaf/bin/start + then + log_end_msg 0 + else + log_end_msg 1 + fi + else + log_end_msg 1 + fi + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac diff --git a/distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service b/distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service new file mode 100644 index 0000000000..eacff19198 --- /dev/null +++ b/distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service @@ -0,0 +1,21 @@ +[Unit] +Description=Starts and stops the openHAB Home Automation Bus +Documentation=http://www.openhab.org +Wants=network-online.target +After=network-online.target + +[Service] +EnvironmentFile=/etc/default/openhab2 +User=openhab2 +Group=openhab2 +WorkingDirectory=/usr/share/openhab2 +#PermissionsStartOnly=true +#ExecStartPre=/usr/share/openhab/bin/setpermissions.sh +ExecStart=/usr/share/openhab2/start.sh server +ExecStop=/usr/share/openhab2/runtime/karaf/bin/stop +# Shutdown delay in seconds, before process is tried to be killed with KILL (if configured) +TimeoutStopSec=120 +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/distributions/openhab-offline/pom.xml b/distributions/openhab-offline/pom.xml index 3871be5c74..1b2e95bf70 100644 --- a/distributions/openhab-offline/pom.xml +++ b/distributions/openhab-offline/pom.xml @@ -14,6 +14,12 @@ openHAB Offline Distribution This is an offline distribution of openHAB + + openhab2-offline + openhab-offline-${project.version}.tar.gz + + + org.apache.karaf.features @@ -45,11 +51,11 @@ - org.openhab.distro.deps - pax-web-jetty - 4.2.3.sp1 - provided - + org.openhab.distro.deps + pax-web-jetty + 4.2.3.sp1 + provided + @@ -151,7 +157,10 @@ + + jdeb + org.vafer + - - + diff --git a/distributions/openhab-offline/src/main/descriptors/archive.xml b/distributions/openhab-offline/src/main/descriptors/archive.xml index a5ad201281..82e6721d3a 100644 --- a/distributions/openhab-offline/src/main/descriptors/archive.xml +++ b/distributions/openhab-offline/src/main/descriptors/archive.xml @@ -3,6 +3,7 @@ archive zip + tar.gz false diff --git a/distributions/openhab-online/pom.xml b/distributions/openhab-online/pom.xml index 025f52f843..7898aa90db 100644 --- a/distributions/openhab-online/pom.xml +++ b/distributions/openhab-online/pom.xml @@ -14,6 +14,12 @@ openHAB Online Distribution This is the online distribution of openHAB + + openhab2-online + openhab-online-${project.version}.tar.gz + + + org.apache.karaf.features @@ -192,6 +198,10 @@ + + jdeb + org.vafer + diff --git a/distributions/openhab-online/src/main/descriptors/archive.xml b/distributions/openhab-online/src/main/descriptors/archive.xml index e09b6e13cf..51fd19b942 100644 --- a/distributions/openhab-online/src/main/descriptors/archive.xml +++ b/distributions/openhab-online/src/main/descriptors/archive.xml @@ -3,6 +3,7 @@ archive zip + tar.gz false diff --git a/distributions/pom.xml b/distributions/pom.xml index fbc0ef67fc..3ea77de286 100644 --- a/distributions/pom.xml +++ b/distributions/pom.xml @@ -12,6 +12,12 @@ pom-distributions openHAB Distributions + + ${project.name} + openHAB <admin@openhab.org> + misc + development + pom @@ -20,4 +26,154 @@ openhab-online + + + + + jdeb + org.vafer + 1.5 + + + runtime + package + + jdeb + + + ${basedir}/../distribution-resources/src/main/resources/deb/control-runtime + ${basedir}/target/${deb.name}-${project.version}.deb + + + template + + etc/openhab2 + usr/share/openhab2 + usr/share/openhab2/bin + var/lib/openhab2 + var/lib/openhab2/persistence/db4o + var/lib/openhab2/persistence/rrd4j + var/lib/openhab2/persistence/mapdb + var/log/openhab2 + + + perm + openhab2 + openhab2 + + + + ${basedir}/../distribution-resources/src/main/resources/deb/etc/default/openhab2 + file + true + + perm + /etc/default + root + root + + + + ${basedir}/../distribution-resources/src/main/resources/deb/etc/init.d/openhab2 + file + + perm + /etc/init.d + 755 + root + root + + + + ${basedir}/../distribution-resources/src/main/resources/deb/bin/setpermissions.sh + file + + perm + /usr/share/openhab2/bin + 755 + root + root + + + + ${basedir}/../distribution-resources/src/main/resources/deb/systemd/openhab2.service + file + + perm + /usr/lib/systemd/system + 644 + root + root + + + + ${basedir}/target/${deb.srcarchive} + archive + conf/**,userdata/**,runtime/karaf/bin/oh2_dir_layout,start.bat,start_debug.bat + + perm + /usr/share/openhab2 + openhab2 + openhab2 + + + + ${basedir}/target/${deb.srcarchive} + archive + conf/** + conf/services/addons.cfg + true + + perm + 1 + /etc/openhab2 + openhab2 + openhab2 + + + + ${basedir}/target/${deb.srcarchive} + archive + userdata/** + true + + perm + 1 + /var/lib/openhab2 + openhab2 + openhab2 + + + + ${basedir}/../distribution-resources/src/main/resources/deb/bin/oh2_dir_layout + file + + perm + /usr/share/openhab2/runtime/karaf/bin + 755 + openhab2 + openhab2 + + + + ${basedir}/../distribution-resources/src/main/resources/deb/conf/services/addons.cfg + file + true + + perm + /etc/openhab2/services + 644 + openhab2 + openhab2 + + + + + + + + + + + \ No newline at end of file From ae2776a99ab53b9ac5ff29f8f4fed760f0215fcd Mon Sep 17 00:00:00 2001 From: Theo Weiss Date: Thu, 7 Apr 2016 23:32:25 +0200 Subject: [PATCH 3/9] make log directory configurable --- .../src/main/resources/bin/oh2_dir_layout | 1 + .../src/main/resources/bin/oh2_dir_layout.bat | 1 + .../distribution-resources/src/main/resources/bin/setenv | 1 + .../src/main/resources/bin/setenv.bat | 1 + .../src/main/resources/deb/bin/oh2_dir_layout | 1 + .../src/main/resources/etc/org.ops4j.pax.logging.cfg | 6 +++--- 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout index e09cd5cd1f..52a94f09e5 100644 --- a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout +++ b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout @@ -7,6 +7,7 @@ export OPENHAB_HOME=`cd "$DIRNAME/../../.."; pwd` export OPENHAB_CONF="${OPENHAB_HOME}/conf" export OPENHAB_RUNTIME="${OPENHAB_HOME}/runtime" export OPENHAB_USERDATA="${OPENHAB_HOME}/userdata" +export OPENHAB_LOGDIR="${OPENHAB_USERDATA}/logs" export KARAF_HOME="${OPENHAB_RUNTIME}/karaf" export KARAF_DATA="${OPENHAB_USERDATA}" diff --git a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat index 33cada6480..e07ec9d79c 100644 --- a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat +++ b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat @@ -5,6 +5,7 @@ set OPENHAB_HOME=%RETVAL% set OPENHAB_CONF=%OPENHAB_HOME%\conf set OPENHAB_RUNTIME=%OPENHAB_HOME%\runtime set OPENHAB_USERDATA=%OPENHAB_HOME%\userdata +set OPENHAB_LOGDIR=%OPENHAB_USERDATA%\logs set KARAF_DATA=%OPENHAB_USERDATA% set KARAF_BASE=%OPENHAB_USERDATA% set KARAF_ETC=%OPENHAB_RUNTIME%\karaf\etc diff --git a/distributions/distribution-resources/src/main/resources/bin/setenv b/distributions/distribution-resources/src/main/resources/bin/setenv index 138cd6907c..b2f482f97e 100755 --- a/distributions/distribution-resources/src/main/resources/bin/setenv +++ b/distributions/distribution-resources/src/main/resources/bin/setenv @@ -75,6 +75,7 @@ export JAVA_OPTS="${JAVA_OPTS} -Dopenhab.conf=${OPENHAB_CONF} -Dopenhab.runtime=${OPENHAB_RUNTIME} -Dopenhab.userdata=${OPENHAB_USERDATA} + -Dopenhab.logdir=${OPENHAB_LOGDIR} -Dorg.osgi.service.http.port=${HTTP_PORT} -Dorg.osgi.service.http.port.secure=${HTTPS_PORT}" diff --git a/distributions/distribution-resources/src/main/resources/bin/setenv.bat b/distributions/distribution-resources/src/main/resources/bin/setenv.bat index e02146d4f3..f0e4a7d779 100644 --- a/distributions/distribution-resources/src/main/resources/bin/setenv.bat +++ b/distributions/distribution-resources/src/main/resources/bin/setenv.bat @@ -93,6 +93,7 @@ set JAVA_OPTS=%JAVA_OPTS% ^ -Dopenhab.conf=%OPENHAB_CONF% ^ -Dopenhab.runtime=%OPENHAB_RUNTIME% ^ -Dopenhab.userdata=%OPENHAB_USERDATA% ^ + -Dopenhab.logdir=%OPENHAB_LOGDIR% ^ -Dorg.osgi.service.http.port=%HTTP_PORT% ^ -Dorg.osgi.service.http.port.secure=%HTTPS_PORT% diff --git a/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout b/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout index d7e174b2c9..4f1f3c1d6f 100644 --- a/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout +++ b/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout @@ -7,6 +7,7 @@ export OPENHAB_HOME=`cd "$DIRNAME/../../.."; pwd` export OPENHAB_CONF="/etc/openhab2" export OPENHAB_RUNTIME="${OPENHAB_HOME}/runtime" export OPENHAB_USERDATA="/var/lib/openhab2" +export OPENHAB_LOGDIR="/var/log/openhab2" export KARAF_HOME="${OPENHAB_RUNTIME}/karaf" export KARAF_DATA="${OPENHAB_USERDATA}" diff --git a/distributions/distribution-resources/src/main/resources/etc/org.ops4j.pax.logging.cfg b/distributions/distribution-resources/src/main/resources/etc/org.ops4j.pax.logging.cfg index cec5f7c595..3906d33a1d 100644 --- a/distributions/distribution-resources/src/main/resources/etc/org.ops4j.pax.logging.cfg +++ b/distributions/distribution-resources/src/main/resources/etc/org.ops4j.pax.logging.cfg @@ -20,7 +20,7 @@ log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss.SSS} [%-5.5p] [%-36.3 log4j.appender.out=org.apache.log4j.RollingFileAppender log4j.appender.out.layout=org.apache.log4j.PatternLayout log4j.appender.out.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n -log4j.appender.out.file=${karaf.data}/logs/openhab.log +log4j.appender.out.file=${openhab.logdir}/openhab.log log4j.appender.out.append=true log4j.appender.out.maxFileSize=10MB log4j.appender.out.maxBackupIndex=10 @@ -29,7 +29,7 @@ log4j.appender.out.maxBackupIndex=10 log4j.appender.event=org.apache.log4j.RollingFileAppender log4j.appender.event.layout=org.apache.log4j.PatternLayout log4j.appender.event.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-26.26c{1}] - %m%n -log4j.appender.event.file=${karaf.data}/logs/events.log +log4j.appender.event.file=${openhab.logdir}/events.log log4j.appender.event.append=true log4j.appender.event.maxFileSize=10MB log4j.appender.event.maxBackupIndex=10 @@ -41,5 +41,5 @@ log4j.appender.sift.default=openhab log4j.appender.sift.appender=org.apache.log4j.FileAppender log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout log4j.appender.sift.appender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n -log4j.appender.sift.appender.file=${karaf.data}/logs/$\\{bundle.name\\}.log +log4j.appender.sift.appender.file=${openhab.logdir}/$\\{bundle.name\\}.log log4j.appender.sift.appender.append=true From 0b592ee61d9cde07b10a89cbd9eef91fb95d001c Mon Sep 17 00:00:00 2001 From: Theo Weiss Date: Sun, 10 Apr 2016 22:13:48 +0200 Subject: [PATCH 4/9] handle docker installations --- .../src/main/resources/deb/control-runtime/postinst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst index 2db680272e..e288cbb710 100644 --- a/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst @@ -1,6 +1,10 @@ #!/bin/sh set -e +if [ x"${OH_DOCKER_INSTALLATION}" != x ]; then + echo "docker installation \"${OH_DOCKER_INSTALLATION}\"" + exit 0 +fi [ -f /etc/default/openhab2 ] && . /etc/default/openhab2 From c6ebc89ae9e71f7630617242e96e47d9bbee9e29 Mon Sep 17 00:00:00 2001 From: Theo Weiss Date: Sun, 17 Apr 2016 11:06:32 +0200 Subject: [PATCH 5/9] configure karaf.instances --- .../src/main/resources/bin/oh2_dir_layout | 2 +- .../src/main/resources/bin/oh2_dir_layout.bat | 2 +- .../distribution-resources/src/main/resources/bin/setenv | 7 ++++++- .../src/main/resources/bin/setenv.bat | 4 ++++ .../src/main/resources/deb/bin/oh2_dir_layout | 4 +--- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout index 52a94f09e5..0a98f8eb10 100644 --- a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout +++ b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout @@ -13,4 +13,4 @@ export KARAF_HOME="${OPENHAB_RUNTIME}/karaf" export KARAF_DATA="${OPENHAB_USERDATA}" export KARAF_BASE="${OPENHAB_USERDATA}" export KARAF_ETC="${OPENHAB_RUNTIME}/karaf/etc" - +export KARAF_INSTANCES="${OPENHAB_USERDATA}" diff --git a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat index e07ec9d79c..243616ace8 100644 --- a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat +++ b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat @@ -9,7 +9,7 @@ set OPENHAB_LOGDIR=%OPENHAB_USERDATA%\logs set KARAF_DATA=%OPENHAB_USERDATA% set KARAF_BASE=%OPENHAB_USERDATA% set KARAF_ETC=%OPENHAB_RUNTIME%\karaf\etc - +set KARAF_INSTANCES=%OPENHAB_USERDATA% EXIT /B :removeSpacesFromPath diff --git a/distributions/distribution-resources/src/main/resources/bin/setenv b/distributions/distribution-resources/src/main/resources/bin/setenv index b2f482f97e..5f403f053e 100755 --- a/distributions/distribution-resources/src/main/resources/bin/setenv +++ b/distributions/distribution-resources/src/main/resources/bin/setenv @@ -67,9 +67,14 @@ else fi # -# set java options +# set karaf options # +export KARAF_OPTS="${KARAF_OPTS} + -Dkaraf.instances=${KARAF_INSTANCES}" +# +# set java options +# export JAVA_OPTS="${JAVA_OPTS} -Dopenhab.home=${OPENHAB_HOME} -Dopenhab.conf=${OPENHAB_CONF} diff --git a/distributions/distribution-resources/src/main/resources/bin/setenv.bat b/distributions/distribution-resources/src/main/resources/bin/setenv.bat index f0e4a7d779..d44a9b6fa5 100644 --- a/distributions/distribution-resources/src/main/resources/bin/setenv.bat +++ b/distributions/distribution-resources/src/main/resources/bin/setenv.bat @@ -87,6 +87,10 @@ goto :https_port_done :https_port_done +:: set karaf options +set KARAF_OPTS=%KARAF_OPTS% ^ + -Dkaraf.instances=%KARAF_INSTANCES% ^ + :: set java options set JAVA_OPTS=%JAVA_OPTS% ^ -Dopenhab.home=%OPENHAB_HOME% ^ diff --git a/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout b/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout index 4f1f3c1d6f..aad505f930 100644 --- a/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout +++ b/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout @@ -13,6 +13,4 @@ export KARAF_HOME="${OPENHAB_RUNTIME}/karaf" export KARAF_DATA="${OPENHAB_USERDATA}" export KARAF_BASE="${OPENHAB_USERDATA}" export KARAF_ETC="${OPENHAB_RUNTIME}/karaf/etc" - - - +export KARAF_INSTANCES="${OPENHAB_USERDATA}" From a6e9f8daff3177b1c96ff3bfe02d63ed4e92fe43 Mon Sep 17 00:00:00 2001 From: Theo Weiss Date: Sun, 17 Apr 2016 14:21:24 +0200 Subject: [PATCH 6/9] root as runtime owner; conflicts configuration added; postinst optimized --- .../resources/deb/control-runtime/control | 1 + .../resources/deb/control-runtime/postinst | 10 ++++----- distributions/openhab-offline/pom.xml | 3 ++- distributions/openhab-online/pom.xml | 1 + distributions/pom.xml | 22 ++++++++++++++----- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/control b/distributions/distribution-resources/src/main/resources/deb/control-runtime/control index c303fcdfd0..5147fd4f57 100644 --- a/distributions/distribution-resources/src/main/resources/deb/control-runtime/control +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/control @@ -7,4 +7,5 @@ Maintainer: [[deb.maintainer]] Description: [[deb.description]] Distribution: [[deb.distribution]] Depends: adduser +Conflicts: [[deb.conflicts]] Homepage: http://www.openhab.org diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst index e288cbb710..1dc0650edf 100644 --- a/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postinst @@ -23,11 +23,8 @@ startOpenHAB() { case "$1" in configure) - # if $2 is set, this is an upgrade - if [ -n $2 ] ; then - startOpenHAB - # this is a fresh installation - else + if [ -z $2 ] ; then + # this is a fresh installation if [ -x /bin/systemctl ] ; then echo "### NOT starting on installation, please execute the following statements to configure openHAB to start automatically using systemd" echo " sudo /bin/systemctl daemon-reload" @@ -40,6 +37,9 @@ case "$1" in echo "### In order to start openhab2, execute" echo " sudo /etc/init.d/openhab2 start" fi + else + # this is an upgrade + startOpenHAB fi ;; esac diff --git a/distributions/openhab-offline/pom.xml b/distributions/openhab-offline/pom.xml index 6cc2b1e52e..14a678c25c 100644 --- a/distributions/openhab-offline/pom.xml +++ b/distributions/openhab-offline/pom.xml @@ -8,7 +8,7 @@ 2.0.0-SNAPSHOT - openhab-offline + openhab2-offline karaf-assembly openHAB Offline Distribution @@ -17,6 +17,7 @@ openhab2-offline openhab-offline-${project.version}.tar.gz + openhab-online diff --git a/distributions/openhab-online/pom.xml b/distributions/openhab-online/pom.xml index a72480ebdf..fdb28aba06 100644 --- a/distributions/openhab-online/pom.xml +++ b/distributions/openhab-online/pom.xml @@ -17,6 +17,7 @@ openhab2-online openhab-online-${project.version}.tar.gz + openhab2-offline diff --git a/distributions/pom.xml b/distributions/pom.xml index 3ea77de286..5914a33dc8 100644 --- a/distributions/pom.xml +++ b/distributions/pom.xml @@ -48,8 +48,6 @@ template etc/openhab2 - usr/share/openhab2 - usr/share/openhab2/bin var/lib/openhab2 var/lib/openhab2/persistence/db4o var/lib/openhab2/persistence/rrd4j @@ -62,6 +60,18 @@ openhab2 + + template + + usr/share/openhab2 + usr/share/openhab2/bin + + + perm + root + root + + ${basedir}/../distribution-resources/src/main/resources/deb/etc/default/openhab2 file @@ -113,8 +123,8 @@ perm /usr/share/openhab2 - openhab2 - openhab2 + root + root @@ -151,8 +161,8 @@ perm /usr/share/openhab2/runtime/karaf/bin 755 - openhab2 - openhab2 + root + root From 02ecf27baf936a667dfdc46a208c3ed735462661 Mon Sep 17 00:00:00 2001 From: Theo Weiss Date: Sun, 17 Apr 2016 16:06:41 +0200 Subject: [PATCH 7/9] fix typo in pom.xml; add apt-repo build plugin --- distributions/openhab-offline/pom.xml | 17 +++++++++++++++-- distributions/openhab-online/pom.xml | 13 +++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/distributions/openhab-offline/pom.xml b/distributions/openhab-offline/pom.xml index 14a678c25c..dd4d95d6b8 100644 --- a/distributions/openhab-offline/pom.xml +++ b/distributions/openhab-offline/pom.xml @@ -8,7 +8,7 @@ 2.0.0-SNAPSHOT - openhab2-offline + openhab-offline karaf-assembly openHAB Offline Distribution @@ -17,7 +17,7 @@ openhab2-offline openhab-offline-${project.version}.tar.gz - openhab-online + openhab2-online @@ -162,6 +162,19 @@ jdeb org.vafer + + apt-repo + org.m1theo + 0.2.3 + + + package + + apt-repo + + + + diff --git a/distributions/openhab-online/pom.xml b/distributions/openhab-online/pom.xml index fdb28aba06..062627ba5f 100644 --- a/distributions/openhab-online/pom.xml +++ b/distributions/openhab-online/pom.xml @@ -195,6 +195,19 @@ jdeb org.vafer + + apt-repo + org.m1theo + 0.2.3 + + + package + + apt-repo + + + + From 281cdb6cebc19276ba490a102bf7d7e770d7356b Mon Sep 17 00:00:00 2001 From: Theo Weiss Date: Sun, 15 May 2016 22:11:23 +0200 Subject: [PATCH 8/9] revert karaf.instances changes --- .../src/main/resources/bin/oh2_dir_layout | 2 +- .../src/main/resources/bin/oh2_dir_layout.bat | 2 +- .../distribution-resources/src/main/resources/bin/setenv | 7 +------ .../src/main/resources/bin/setenv.bat | 4 ---- .../src/main/resources/deb/bin/oh2_dir_layout | 4 +++- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout index 0a98f8eb10..52a94f09e5 100644 --- a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout +++ b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout @@ -13,4 +13,4 @@ export KARAF_HOME="${OPENHAB_RUNTIME}/karaf" export KARAF_DATA="${OPENHAB_USERDATA}" export KARAF_BASE="${OPENHAB_USERDATA}" export KARAF_ETC="${OPENHAB_RUNTIME}/karaf/etc" -export KARAF_INSTANCES="${OPENHAB_USERDATA}" + diff --git a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat index 243616ace8..e07ec9d79c 100644 --- a/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat +++ b/distributions/distribution-resources/src/main/resources/bin/oh2_dir_layout.bat @@ -9,7 +9,7 @@ set OPENHAB_LOGDIR=%OPENHAB_USERDATA%\logs set KARAF_DATA=%OPENHAB_USERDATA% set KARAF_BASE=%OPENHAB_USERDATA% set KARAF_ETC=%OPENHAB_RUNTIME%\karaf\etc -set KARAF_INSTANCES=%OPENHAB_USERDATA% + EXIT /B :removeSpacesFromPath diff --git a/distributions/distribution-resources/src/main/resources/bin/setenv b/distributions/distribution-resources/src/main/resources/bin/setenv index 5f403f053e..b2f482f97e 100755 --- a/distributions/distribution-resources/src/main/resources/bin/setenv +++ b/distributions/distribution-resources/src/main/resources/bin/setenv @@ -66,15 +66,10 @@ else HTTPS_PORT=8443 fi -# -# set karaf options -# -export KARAF_OPTS="${KARAF_OPTS} - -Dkaraf.instances=${KARAF_INSTANCES}" - # # set java options # + export JAVA_OPTS="${JAVA_OPTS} -Dopenhab.home=${OPENHAB_HOME} -Dopenhab.conf=${OPENHAB_CONF} diff --git a/distributions/distribution-resources/src/main/resources/bin/setenv.bat b/distributions/distribution-resources/src/main/resources/bin/setenv.bat index d44a9b6fa5..f0e4a7d779 100644 --- a/distributions/distribution-resources/src/main/resources/bin/setenv.bat +++ b/distributions/distribution-resources/src/main/resources/bin/setenv.bat @@ -87,10 +87,6 @@ goto :https_port_done :https_port_done -:: set karaf options -set KARAF_OPTS=%KARAF_OPTS% ^ - -Dkaraf.instances=%KARAF_INSTANCES% ^ - :: set java options set JAVA_OPTS=%JAVA_OPTS% ^ -Dopenhab.home=%OPENHAB_HOME% ^ diff --git a/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout b/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout index aad505f930..4f1f3c1d6f 100644 --- a/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout +++ b/distributions/distribution-resources/src/main/resources/deb/bin/oh2_dir_layout @@ -13,4 +13,6 @@ export KARAF_HOME="${OPENHAB_RUNTIME}/karaf" export KARAF_DATA="${OPENHAB_USERDATA}" export KARAF_BASE="${OPENHAB_USERDATA}" export KARAF_ETC="${OPENHAB_RUNTIME}/karaf/etc" -export KARAF_INSTANCES="${OPENHAB_USERDATA}" + + + From e22787ae569092483693a35c2f4d41159eeb66b0 Mon Sep 17 00:00:00 2001 From: Theo Weiss Date: Thu, 19 May 2016 18:04:24 +0200 Subject: [PATCH 9/9] rename openhab2 user and group to openhab; openhab user as owner of all application files --- .../main/resources/deb/control-runtime/postrm | 4 +-- .../resources/deb/control-runtime/preinst | 4 +-- .../main/resources/deb/etc/init.d/openhab2 | 2 +- .../resources/deb/systemd/openhab2.service | 4 +-- distributions/pom.xml | 26 ++++++++++--------- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm index 9a359cea24..cc0322efb5 100644 --- a/distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/postrm @@ -2,8 +2,8 @@ set -e -OH_USER=openhab2 -OH_GROUP=openhab2 +OH_USER=openhab +OH_GROUP=openhab removeOpenHABInit() { if [ -x /bin/systemctl ] ; then diff --git a/distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst b/distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst index 107e357ee8..60253de3be 100644 --- a/distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst +++ b/distributions/distribution-resources/src/main/resources/deb/control-runtime/preinst @@ -4,8 +4,8 @@ set -e case "$1" in install) - OH_USER=openhab2 - OH_GROUP=openhab2 + OH_USER=openhab + OH_GROUP=openhab if [ x"${USER_AND_GROUP}" != x ]; then OH_USER=`echo ${USER_AND_GROUP} | cut -d ":" -f 1` OH_GROUP=`echo ${USER_AND_GROUP} | cut -d ":" -f 2` diff --git a/distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 b/distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 index 8aec042dff..04f716bd63 100644 --- a/distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 +++ b/distributions/distribution-resources/src/main/resources/deb/etc/init.d/openhab2 @@ -37,7 +37,7 @@ OPENHAB_HOME_DIR="/var/lib/openhab2" OPENHAB_USER_DATA_DIR="${OPENHAB_HOME_DIR}" if [ -z "$USER_AND_GROUP" ]; then - USER_AND_GROUP="openhab2:openhab2" + USER_AND_GROUP="openhab:openhab" fi if [ x"${OPENHAB_JAVA}" != x ]; then diff --git a/distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service b/distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service index eacff19198..2be8c19c9d 100644 --- a/distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service +++ b/distributions/distribution-resources/src/main/resources/deb/systemd/openhab2.service @@ -6,8 +6,8 @@ After=network-online.target [Service] EnvironmentFile=/etc/default/openhab2 -User=openhab2 -Group=openhab2 +User=openhab +Group=openhab WorkingDirectory=/usr/share/openhab2 #PermissionsStartOnly=true #ExecStartPre=/usr/share/openhab/bin/setpermissions.sh diff --git a/distributions/pom.xml b/distributions/pom.xml index 5914a33dc8..5debaf8673 100644 --- a/distributions/pom.xml +++ b/distributions/pom.xml @@ -17,6 +17,8 @@ openHAB <admin@openhab.org> misc development + openhab + openhab pom @@ -56,8 +58,8 @@ perm - openhab2 - openhab2 + ${deb.user} + ${deb.group} @@ -68,8 +70,8 @@ perm - root - root + ${deb.user} + ${deb.group} @@ -123,8 +125,8 @@ perm /usr/share/openhab2 - root - root + ${deb.user} + ${deb.group} @@ -137,8 +139,8 @@ perm 1 /etc/openhab2 - openhab2 - openhab2 + ${deb.user} + ${deb.group} @@ -150,8 +152,8 @@ perm 1 /var/lib/openhab2 - openhab2 - openhab2 + ${deb.user} + ${deb.group} @@ -173,8 +175,8 @@ perm /etc/openhab2/services 644 - openhab2 - openhab2 + ${deb.user} + ${deb.group}