diff --git a/docker-compose.yml b/docker-compose.yml index f2d0ee9..3138c9b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,13 +5,13 @@ image: openhab/openhab:2.0.0-${OPENHAB_ARCH:-amd64} mem_limit: 2g restart: always - user: ${OPENHAB_USER:-openhab:openhab} + ##user: ${OPENHAB_USER:-openhab:eopnhab} volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro - - ./data/conf:/openhab/conf - - ./data/userdata:/openhab/userdata - - ./data/addons:/openhab/addons + - ./data/conf/:/openhab/conf/ + - ./data/userdata/:/openhab/userdata/ + - ./data/addons/:/openhab/addons/ tmpfs: - /tmp:rw,size=100m ports: diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..5344d64 --- /dev/null +++ b/install.sh @@ -0,0 +1,27 @@ +#!/bin/bash + + +userStr=$(getent passwd openhab) + +# check user +if [ -z $userStr ]; then + echo "create openhab user and group" + + useradd -r -s /sbin/nologin openhab +fi + +# gut user id +uid=$(id openhab -u) +gid=$(id openhab -g) + +# create directories +mkdir -p data/conf +mkdir -p data/userdata +mkdir -p data/addons + +chown -R ${uid}:${gid} data +chmod -R 770 data + +# replace uid and gid in config file +sed -i "/^OPENHAB_USER/c\\\OPENHAB_USER=${uid}:${gid}" openhab.conf + diff --git a/openhab.conf b/openhab.conf index f3622ba..7414d21 100644 --- a/openhab.conf +++ b/openhab.conf @@ -6,7 +6,7 @@ # user configuration # http://docs.openhab.org/installation/docker.html # please add user like UID:GID -OPENHAB_USER=998:998 +OPENHAB_USER=999:998 # network configuration OPENHAB_BIND=127.0.0.1