Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deb files build initial commit #138

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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%

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/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 OPENHAB_LOGDIR="/var/log/openhab2"

export KARAF_HOME="${OPENHAB_RUNTIME}/karaf"
export KARAF_DATA="${OPENHAB_USERDATA}"
export KARAF_BASE="${OPENHAB_USERDATA}"
export KARAF_ETC="${OPENHAB_RUNTIME}/karaf/etc"



Original file line number Diff line number Diff line change
@@ -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 =
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: [[deb.name]]
Version: [[version]]
Section: [[deb.section]]
Priority: optional
Architecture: all
Maintainer: [[deb.maintainer]]
Description: [[deb.description]]
Distribution: [[deb.distribution]]
Depends: adduser
Conflicts: [[deb.conflicts]]
Homepage: http://www.openhab.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/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

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 [ -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"
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
else
# this is an upgrade
startOpenHAB
fi
;;
esac

exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

set -e

OH_USER=openhab
OH_GROUP=openhab

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -e

case "$1" in
install)
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`
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EXTRA_JAVA_OPTS=""
Original file line number Diff line number Diff line change
@@ -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 <openhab@openhab.org>
#


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="openhab:openhab"
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
Original file line number Diff line number Diff line change
@@ -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=openhab
Group=openhab
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
Loading