diff --git a/.gitignore b/.gitignore index 1269488..85df019 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -data +/data +/backup +openhab.conf diff --git a/backup.sh b/backup.sh new file mode 100755 index 0000000..d3b4397 --- /dev/null +++ b/backup.sh @@ -0,0 +1,32 @@ +#!/bin/bash + + +# backup directory +backup_dir=backup + +# load variaables form config +source openhab.conf + +# current date +DATE=$(date +"%Y%m%d_%H%M%S") + +# create backuop directories +mkdir -p $backup_dir/conf +mkdir -p $backup_dir/data/conf +mkdir -p $backup_dir/data/addons +mkdir -p $backup_dir/data/userdata + + +## backup + +# main conf +tar -cjf ${PWD}/${backup_dir}/conf/${DATE}.tbz2 openhab.conf + +# openHAB conf +tar -C data -cjf ${PWD}/${backup_dir}/data/conf/${DATE}.tbz2 conf + +# openHAB addons +tar -C data -cjf ${PWD}/${backup_dir}/data/addons/${DATE}.tbz2 addons + +# openHAB userdata +tar -C data -cjf ${PWD}/${backup_dir}/data/userdata/${DATE}.tbz2 userdata diff --git a/clearPid.sh b/clearPid.sh new file mode 100755 index 0000000..7e7502f --- /dev/null +++ b/clearPid.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if [ -f "./data/userdata/tmp/karaf.pid" ]; then + rm ./data/userdata/tmp/karaf.pid +fi diff --git a/docker-compose.yml b/docker-compose.yml index e39c8c7..286d1a1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,18 @@ services: main-openhab: - image: openhab/openhab:2.0.0-${OPENHAB_ARCH:-amd64} + image: openhab/openhab:2.2.0-${OPENHAB_ARCH:-amd64}-debian mem_limit: 2g restart: always + tty: true + logging: + driver: json-file environment: - USER_ID=${OPENHAB_USER_ID} + - TZ=${TZ} + - LC_ALL=${OPENHAB_LANG} + - LANG=${OPENHAB_LANG} + - LANGUAGE=${OPENHAB_LANG} volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro @@ -19,4 +26,3 @@ - "${OPENHAB_HTTP_BIND:-127.0.0.1}:${OPENHAB_HTTP_PORT:-8080}:8080" - "${OPENHAB_HTTPS_BIND:-127.0.0.1}:${OPENHAB_HTTPS_PORTS:-8443}:8443" - "${OPENHAB_OSGI_BIND:-127.0.0.1}:${OPENHAB_OSGI_PORT:-5555}:5555" - diff --git a/install.sh b/install.sh index 1f15e3b..b895365 100755 --- a/install.sh +++ b/install.sh @@ -3,11 +3,29 @@ # get user id uid=$(id -u) -# create directories -mkdir -p data/conf -mkdir -p data/userdata -mkdir -p data/addons +# get architecture +arc=$(uname -m) -# replace uid and gid in config file -sed -i "/^OPENHAB_USER/c\\\OPENHAB_USER_ID=${uid}" openhab.conf +if [ ! -f "openhab.conf" ]; then + cp openhab.conf.example openhab.conf + # create directories + mkdir -p data/conf + mkdir -p data/userdata + mkdir -p data/addons + + # replace uid and gid in config file + sed -i "/^OPENHAB_USER/c\\\OPENHAB_USER_ID=${uid}" openhab.conf + + # replace architecture + if [[ $arc == "x86_64" ]]; then + sed -i "/^OPENHAB_ARCH=/c\\\OPENHAB_ARCH=amd64" openhab.conf + elif [[ $arc == *"armv"* ]]; then + sed -i "/^OPENHAB_ARCH=/c\\\OPENHAB_ARCH=armhf" openhab.conf + else + echo "unsupportet architecture" + exit 1 + fi +else + echo "Config already exists!" +fi diff --git a/openhab.conf b/openhab.conf deleted file mode 100644 index f7e2372..0000000 --- a/openhab.conf +++ /dev/null @@ -1,20 +0,0 @@ -# system architecture -# amd64, armhf, arm64 -# look at https://hub.docker.com/r/openhab/openhab/ for more details -OPENHAB_ARCH=amd64 - -# user configuration -# http://docs.openhab.org/installation/docker.html -# please add user like UID:GID -OPENHAB_USER_ID=1000 - -# network configuration -OPENHAB_HTTP_BIND=127.0.0.1 -OPENHAB_HTTP_PORT=8080 - -OPENHAB_HTTPS_BIND=127.0.0.1 -OPENHAB_HTTPS_PORT=8443 - -OPENHAB_OSGI_BIND=127.0.0.1 -OPENHAB_OSGI_PORT=5555 - diff --git a/openhab.conf.example b/openhab.conf.example new file mode 100644 index 0000000..71ecd8c --- /dev/null +++ b/openhab.conf.example @@ -0,0 +1,25 @@ +# system architecture +# amd64, armhf, arm64 +# look at https://hub.docker.com/r/openhab/openhab/ for more details +OPENHAB_ARCH=amd64 + +# user configuration +# http://docs.openhab.org/installation/docker.html +# please add user like UID:GID +OPENHAB_USER_ID=1000 + +# network configuration +OPENHAB_HTTP_BIND=127.0.0.1 +OPENHAB_HTTP_PORT=8080 + +OPENHAB_HTTPS_BIND=127.0.0.1 +OPENHAB_HTTPS_PORT=8443 + +OPENHAB_OSGI_BIND=127.0.0.1 +OPENHAB_OSGI_PORT=5555 + +# timezone +TZ=Europe/Berlin + +# language +OPENHAB_LANG=de_DE.UTF-8