mirror of
https://git.freebsd.org/ports.git
synced 2025-06-23 05:30:31 -04:00
92 lines
2.9 KiB
Bash
92 lines
2.9 KiB
Bash
#!/bin/sh
|
|
|
|
#
|
|
# PROVIDE: openhab
|
|
# REQUIRE: LOGIN
|
|
# KEYWORD: shutdown
|
|
#
|
|
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
|
|
# to enable this service:
|
|
#
|
|
# openhab_enable (bool): Set to NO by default.
|
|
# Set it to YES to enable openhab.
|
|
# openhab_user (username): Set to openhab by default.
|
|
# openhab_group (groupname): Set to openhab by default.
|
|
# openhab_http_port (port): Set to 8080 by default.
|
|
# openhab_https_port (port): Set to 8443 by default.
|
|
# openhab_listen_address (IP): Set to 0.0.0.0 for http/https by default.
|
|
# openhab_backup_dir (path): Set to /var/db/openhab/backups by default.
|
|
# openhab_java_opts (string): Empty by default. You can add additional java
|
|
# options like -Duser.timezone=Europe/Berlin and/or
|
|
# -Dgnu.io.rxtx.SerialPorts=/dev/cuau0
|
|
# -Dsun.nio.fs.watchservice=polling
|
|
# openhab_home_dir (path): Set to %%PREFIX%%/libexec/openhab by default.
|
|
# openhab_conf_dir (path): Set to %%PREFIX%%/etc/openhab by default.
|
|
# openhab_runtime_dir (path): Set to %%PREFIX%%/libexec/openhab/runtime by default.
|
|
# openhab_userdata_dir (path): Set to /var/db/openhab/userdata by default.
|
|
# openhab_log_dir (path): Set to /var/log/openhab by default.
|
|
|
|
. /etc/rc.subr
|
|
|
|
name=openhab
|
|
rcvar=openhab_enable
|
|
|
|
load_rc_config $name
|
|
|
|
: ${openhab_enable:="NO"}
|
|
: ${openhab_user:="openhab"}
|
|
: ${openhab_group:="openhab"}
|
|
: ${openhab_http_port:="8080"}
|
|
: ${openhab_https_port:="8443"}
|
|
: ${openhab_listen_address:="0.0.0.0"}
|
|
: ${openhab_backup_dir:="/var/db/openhab/backups"}
|
|
: ${openhab_home_dir:="%%PREFIX%%/libexec/openhab"}
|
|
: ${openhab_conf_dir:="%%PREFIX%%/etc/openhab"}
|
|
: ${openhab_runtime_dir:="%%PREFIX%%/libexec/openhab/runtime"}
|
|
: ${openhab_userdata_dir:="/var/db/openhab/userdata"}
|
|
: ${openhab_log_dir:="/var/log/openhab"}
|
|
|
|
export OPENHAB_USER="${openhab_user}"
|
|
export OPENHAB_GROUP="${openhab_group}"
|
|
export OPENHAB_HTTP_PORT="${openhab_http_port}"
|
|
export OPENHAB_HTTPS_PORT="${openhab_https_port}"
|
|
export OPENHAB_HTTP_ADDRESS="${openhab_listen_address}"
|
|
export OPENHAB_BACKUPS="${openhab_backup_dir}"
|
|
export EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/cuau0 -Dsun.nio.fs.watchservice=polling ${openhab_java_opts}"
|
|
export OPENHAB_HOME="${openhab_home_dir}"
|
|
export OPENHAB_CONF="${openhab_conf_dir}"
|
|
export OPENHAB_RUNTIME="${openhab_runtime_dir}"
|
|
export OPENHAB_USERDATA="${openhab_userdata_dir}"
|
|
export OPENHAB_LOGDIR="${openhab_log_dir}"
|
|
# for UTF-8 encoding, language can be set inside openhab:
|
|
export LC_ALL=en_US.UTF-8
|
|
export JAVA_VERSION=11
|
|
|
|
pidfile=/var/run/${name}/${name}.pid
|
|
|
|
command=/usr/sbin/daemon
|
|
command_args="-p ${pidfile} -t openhab ${OPENHAB_HOME}/start.sh server"
|
|
|
|
openhab_stop() {
|
|
${OPENHAB_RUNTIME}/bin/stop
|
|
if [ -e ${pidfile} ]; then
|
|
wait_for_pids $(cat ${pidfile})
|
|
fi
|
|
}
|
|
|
|
openhab_status() {
|
|
case "$(${OPENHAB_RUNTIME}/bin/status 2>&1)" in
|
|
"Not Running ...")
|
|
echo ${name} is not running,
|
|
;;
|
|
"Running ...")
|
|
echo ${name} is running.
|
|
;;
|
|
esac
|
|
}
|
|
|
|
stop_cmd="openhab_stop"
|
|
status_cmd="openhab_status"
|
|
|
|
|
|
run_rc_command "$1"
|