Skip to content

Commit 45feda3

Browse files
committed
OpenHab: move installation to Docker instance and change port
1 parent c596cf6 commit 45feda3

File tree

3 files changed

+47
-26
lines changed

3 files changed

+47
-26
lines changed

tests/openhab.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
ENABLED=true
2-
RELEASE="bookworm"
1+
ENABLED=false
2+
RELEASE="noble"
33
TESTNAME="OpenHab install"
44

55
function testcase {(
66
set -e
7-
./bin/armbian-config --api module_openhab remove
7+
./bin/armbian-config --api module_docker purge
8+
./bin/armbian-config --api module_openhab purge
89
./bin/armbian-config --api module_openhab install
9-
systemctl is-active --quiet openhab.service
1010
)}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
=== "Access to the web interface"
22

3-
The web interface is accessible via port **8080**:
3+
The web interface is accessible via port **2080**:
44

5-
- URL: `https://<your.IP>:8080`
5+
- URL: `https://<your.IP>:2080`
66
- Username/Password: Are set at first web interface login
77

88
=== "Directories"
99

10-
- Install directory: `/usr/share/openhab`
11-
- Site configuration directory: `/etc/openhab`
12-
- Config file: `/etc/default/openhab`
13-
- Data directory: `/var/lib/openhab`
10+
- Install directory: `/armbian/openhab`
11+
- Site configuration directory: `/armbian/openhab/conf`
12+
- Userdata directory: `/armbian/openhab/userdata`
13+
- Addons directory: `/armbian/openhab/addons`
1414

1515
See also [openHAB file locations](https://www.openhab.org/docs/installation/linux.html#file-locations).
1616

1717
=== "View logs"
1818

1919
```sh
20-
journalctl -u openhab
20+
docker logs -f openhab
2121
```

tools/modules/software/module_openhab.sh

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module_options+=(
77
["module_openhab,status"]="Active"
88
["module_openhab,doc_link"]="https://www.openhab.org/docs/tutorial"
99
["module_openhab,group"]="HomeAutomation"
10-
["module_openhab,port"]="8080"
10+
["module_openhab,port"]="2080 2443 5007 9123"
1111
["module_openhab,arch"]="x86-64 arm64 armhf"
1212
)
1313
#
@@ -18,32 +18,53 @@ function module_openhab() {
1818
local title="openhab"
1919
local condition=$(which "$title" 2>/dev/null)
2020

21+
if pkg_installed docker-ce; then
22+
local container=$(docker container ls -a | mawk '/openhab?( |$)/{print $1}')
23+
local image=$(docker image ls -a | mawk '/openhab?( |$)/{print $3}')
24+
fi
25+
2126
local commands
2227
IFS=' ' read -r -a commands <<< "${module_options["module_openhab,example"]}"
2328

29+
OPENHAB_BASE="${SOFTWARE_FOLDER}/openhab"
30+
2431
case "$1" in
2532
"${commands[0]}")
26-
wget -qO - https://repos.azul.com/azul-repo.key | gpg --dearmor > "/usr/share/keyrings/azul.gpg"
27-
wget -qO - https://openhab.jfrog.io/artifactory/api/gpg/key/public | gpg --dearmor > "/usr/share/keyrings/openhab.gpg"
28-
echo "deb [signed-by=/usr/share/keyrings/azul.gpg] https://repos.azul.com/zulu/deb stable main" > "/etc/apt/sources.list.d/zulu.list"
29-
echo "deb [signed-by=/usr/share/keyrings/openhab.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable main" > "/etc/apt/sources.list.d/openhab.list"
30-
pkg_update
31-
pkg_install zulu17-jdk
32-
pkg_install openhab openhab-addons
33-
srv_daemon_reload
34-
srv_enable openhab
35-
srv_start openhab
33+
pkg_installed docker-ce || module_docker install
34+
docker run -d \
35+
--name openhab \
36+
--net=lsio \
37+
-p $(echo "${module_options[module_openhab,port]}" | awk '{print $1}'):8080 \
38+
-p $(echo "${module_options[module_openhab,port]}" | awk '{print $2}'):8443 \
39+
-p $(echo "${module_options[module_openhab,port]}" | awk '{print $3}'):5007 \
40+
-p $(echo "${module_options[module_openhab,port]}" | awk '{print $4}'):9123 \
41+
-v /etc/localtime:/etc/localtime:ro \
42+
-v /etc/timezone:/etc/timezone:ro \
43+
-v ${OPENHAB_BASE}/conf:/openhab/conf \
44+
-v ${OPENHAB_BASE}/userdata:/openhab/userdata \
45+
-v ${OPENHAB_BASE}/addons:/openhab/addons \
46+
-e USER_ID=1000 \
47+
-e GROUP_ID=1000 \
48+
-e CRYPTO_POLICY=unlimited \
49+
--restart=unless-stopped \
50+
openhab/openhab:latest
3651
;;
3752
"${commands[1]}")
38-
pkg_remove zulu17-jdk openhab openhab-addons
39-
rm -f /usr/share/keyrings/openhab.gpg /usr/share/keyrings/azul.gpg
40-
rm -f /etc/apt/sources.list.d/zulu.list /etc/apt/sources.list.d/openhab.list
53+
if [[ -n "${container}" ]]; then
54+
docker container rm -f "$container" >/dev/null
55+
fi
56+
if [[ -n "${image}" ]]; then
57+
docker image rm "$image" >/dev/null
58+
fi
4159
;;
4260
"${commands[2]}")
4361
${module_options["module_openhab,feature"]} ${commands[1]}
62+
if [[ -n "${OPENHAB_BASE}" && "${OPENHAB_BASE}" != "/" ]]; then
63+
rm -rf "${OPENHAB_BASE}"
64+
fi
4465
;;
4566
"${commands[3]}")
46-
if pkg_installed openhab; then
67+
if [[ "${container}" && "${image}" ]]; then
4768
return 0
4869
else
4970
return 1

0 commit comments

Comments
 (0)