aboutsummarylogtreecommitdiffstats
path: root/minecraft-server.install
blob: 3031324e00281ed8fa6aef89e1cb783db772b0e4 (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
post_install() {
  post_upgrade
}

post_upgrade() {
  getent group "minecraft" &>/dev/null || groupadd -r minecraft 1>/dev/null
  getent passwd "minecraft" &>/dev/null && usermod -s "/usr/bin/nologin" minecraft &>/dev/null || useradd -r -g minecraft -d "/srv/minecraft" -s "/usr/bin/nologin" minecraft 1>/dev/null
  touch /srv/minecraft/server.log
  chown -R minecraft:minecraft "/srv/minecraft" 1>/dev/null
  ln -s /srv/minecraft/server.log /var/log/minecraft.log &>/dev/null
  # Removes old data from previous version
  cat << EOF
==> World data is stored under /srv/minecraft
==> The server runs as "minecraft", not root
==> You can access the server's console as root with:
      $ screen -r minecraft
==> The systemd service is called "minecraftd.service"
==> Calling "stop" or "restart" with systemctl will gracefully exit the server, saving world data
==> Modify /etc/conf.d/minecraft to change the invocation of the server if you wish
==> A script at /usr/bin/minecraftctl is also provided. See the wiki for details on its usage.
==> For the server to start you have to accept the EULA in /srv/minecraft/eula.txt
 
EOF
}

post_remove() {
  if getent passwd "minecraft" >/dev/null; then
    userdel minecraft >/dev/null
  fi
  if getent group "minecraft" >/dev/null; then
    groupdel minecraft >/dev/null
  fi
}