minecraft-server-fabric/minecraft-server.install

37 lines
1.5 KiB
Plaintext
Raw Normal View History

_game="minecraft"
_user="minecraft"
_server_root="/srv/minecraft"
2015-09-20 14:23:34 -07:00
post_install() {
getent group "${_user}" &>/dev/null
2015-12-13 06:32:38 -08:00
if [ $? -ne 0 ]; then
echo -e "\e[34;1m==>\e[39;1m Adding ${_user} system group... \e[0m"
groupadd -r ${_user} 1>/dev/null
2015-09-20 14:23:34 -07:00
fi
getent passwd "${_user}" &>/dev/null
2015-09-20 14:23:34 -07:00
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
2015-09-20 14:23:34 -07:00
fi
chown -R ${_user}:${_user} "${_server_root}"
2015-09-20 14:23:34 -07:00
echo -e "\e[34;1m==>\e[39;1m NOTE: The world data is stored under ${_server_root} and 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}d to start, stop or backup the server \e[0m"
echo -e "\e[34;1m==>\e[39;1m and the configuration file under /etc/conf.d/${_game} 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 in ${_server_root}/eula.txt \e[0m"
2015-12-13 06:32:38 -08:00
echo -e "\e[34;1m==>\e[39;1m which is generated after the first server start. \e[0m"
2015-09-20 14:23:34 -07:00
}
2015-07-03 10:16:00 -07:00
post_upgrade() {
chown -R ${_user}:${_user} "${_server_root}"
2015-09-20 14:23:34 -07:00
}
2015-07-03 10:16:00 -07:00
post_remove() {
2015-09-20 14:23:34 -07:00
# Notifying the user of kept dirs
[[ -d "${_server_root}" ]] && echo -e "\e[34;1m==>\e[39;1m NOTE: Game saves in ${_server_root} were kept on your system.\e[0m"
echo -e "\e[34;1m==>\e[39;1m NOTE: The ${_user} user was preserved on your system. \e[0m"
2015-07-03 10:16:00 -07:00
}