Newer
Older
openhab / install.sh
#!/bin/bash

# get user id
uid=$(id -u)

# get architecture
arc=$(uname -m)

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 dependend
	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
		sed -i "/^#OPENHAB_MEMORY_LIMIT=/c\\\OPENHAB_MEMORY_LIMIT=512m" openhab.conf
	else
		echo "unsupportet architecture"
		exit 1
	fi
else
	echo "Config already exists!"
fi