blob: 5d35b012b77d3db163244f11435c2cc0234d17a7 (
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
|
_game="minecraft"
_user="minecraft"
_server_root="/srv/minecraft"
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 "${_server_root}" ${_user} 1>/dev/null
fi
chown -R ${_user}:${_user} "${_server_root}"
echo -e "\e[34;1m==>\e[39;1m NOTE: The world data is stored under ${_server_root}/<name>, by default. The server runs \e[0m"
echo -e "\e[34;1m==>\e[39;1m as ${_user} user to increase security. \e[0m"
echo -e "\e[34;1m==>\e[39;1m NOTE: Use the ${_game} script under /usr/bin/${_game}ctl to start, stop or backup the server \e[0m"
echo -e "\e[34;1m==>\e[39;1m and the configuration file under /etc/${_game}/<name> to adjust it to your liking. \e[0m"
echo -e "\e[34;1m==>\e[39;1m NOTE: For the server to start you have to accept the EULA. Add EULA=true in your configuration. \e[0m"
}
post_remove() {
# Notifying the user of kept dirs
[[ -d "${_server_root}" ]] && chown -R root:root "${_server_root}" && echo -e "\e[34;1m==>\e[39;1m NOTE: Game saves in ${_server_root} were kept on your system.\e[0m"
[[ -d "/etc/${_game}" ]] && echo -e "\e[34;1m==>\e[39;1m NOTE: Your configuration files in /etc/${_game} 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} 2>/dev/null
fi
}
|