summarylogtreecommitdiffstats
path: root/openhab2.install
blob: 3cc7dc85d2a1ad7547751c9c090d6fa5f8916a6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
_user="openhab"

post_install() {
	getent group "${_user}" &>/dev/null
	if [ $? -ne 0 ]; then
		echo -e "\e[34;1m==>\e[39;1m Adding ${_user} system group... \e[0m"
		groupadd -r ${_user} 1>/dev/null
	fi

	getent passwd "${_user}" &>/dev/null
	if [ $? -ne 0 ]; then
		echo -e "\e[34;1m==>\e[39;1m Adding ${_user} system user... \e[0m"
		useradd -r -g ${_user} -G audio -d /usr/share/openhab2 ${_user} 1>/dev/null
	fi

	post_upgrade
}

post_upgrade() {
	chown -R ${_user}:${_user} /etc/openhab2
	chown -R ${_user}:${_user} /usr/share/openhab2
	chown -R ${_user}:${_user} /var/lib/openhab2
	chown -R ${_user}:${_user} /var/log/openhab2
}

post_remove() {
	# Notifying the user of kept dirs
	echo -e "\e[34;1m==>\e[39;1m NOTE: The ${_user} user was preserved on your system. \e[0m"
}