summarylogtreecommitdiffstats
path: root/starbound-client-server-gog.install
blob: 384a1504ce94850cc1e4e822c9d483b2fc6749c0 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# mostly copied from minecraft-server package

_game="starbound"
_user="starbound"

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} -d "/usr/share/starbound" ${_user} 1>/dev/null
	fi

	chown -R ${_user}:${_user} "/etc/conf.d/starbound"

	echo -e "\e[34;1m==>\e[39;1m NOTE: The world data is stored under /etc/conf.d/starbound/storage\e[0m"
	echo -e "\e[34;1m==>\e[39;1m and the server runs as ${_user} user to increase security. \e[0m"
	echo -e "\e[34;1m==>\e[39;1m NOTE: Use the starbound_server systemd-unit to start or stop the server \e[0m"
}

post_upgrade() {
	chown -R ${_user}:${_user} "/etc/conf.d/starbound"
}

pre_remove() {
	echo -e "\e[34;1m==>\e[39;1m Stopping and disabling ${_game}_server... \e[0m"
	systemctl stop starbound_server.service
	systemctl disable starbound_server.service
}

post_remove() {
	# Notifying the user of kept dirs
	[[ -d "/etc/conf.d/starbound" ]] && chown -R root:root "/etc/conf.d/starbound" && echo -e "\e[34;1m==>\e[39;1m NOTE: Game saves in /etc/conf.d/starbound were kept on your system.\e[0m"

	echo -e "\e[34;1m==>\e[39;1m Removing ${_user} system user and group... \e[0m"
	if getent passwd ${_user} >/dev/null 2>&1; then
		userdel ${_user} 2>/dev/null
	fi
	if getent group ${_user} >/dev/null 2>&1; then
		groupdel ${_user}
	fi
}