• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

agowa338/MinecraftSystemdUnit: Systemd Unit file for Minecraft Server

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

agowa338/MinecraftSystemdUnit

开源软件地址(OpenSource Url):

https://github.com/agowa338/MinecraftSystemdUnit

开源编程语言(OpenSource Language):


开源软件介绍(OpenSource Introduction):

MinecraftSystemdUnit

Systemd Unit file for Minecraft Server

Installation

  1. Connect to the server or if you want to run the server on your machine, open a terminal
  2. Become root using su or sudo
    • To validate that you're now root, run id
  3. Next install the necessary packages
    apt-get install -y openjdk-11-jre-headless curl screen nano bash grep
  4. Create the /opt folder if it doesn't already exist
    mkdir /opt
  5. Now you need to create the user for the service
    adduser --system --shell /bin/bash --home /opt/minecraft --group minecraft
    chmod +t /opt/minecraft
  6. Create the Systemd Unit file:
    nano /etc/systemd/system/minecraft@.service
    # paste the contents of minecraft@.service
    or
    curl https://raw.githubusercontent.com/agowa338/MinecraftSystemdUnit/master/minecraft%40.service > /etc/systemd/system/minecraft@.service

Setup Instance

Each server has it's own subdirectory of /opt/minecraft. This means that when a new server is being added, the following steps need to be followed:

  1. Create a subdirectory of /opt/minecraft for your Minecraft server, we'll be using feed-the-beast as an example
    • It is recommended to use a name which only includes lowercase characters, spaces should be replaced with dashes
    cd /opt/minecraft
    mkdir feed-the-beast
  2. Upload your files to the /opt/minecraft/feed-the-beast directory
    • Note: All uploaded files should be owned by the minecraft user
    chown -R minecraft:minecraft /opt/minecraft/feed-the-beast
  3. Accept the Minecraft server's EULA
    echo 'eula=true' > eula.txt
    

RAM allocation

With minecraft@.service it's possible to specify the RAM allocation per server. This can be done using a server.conf file in the server's directory.

Example

# /opt/minecraft/ftb-beyond/server.conf
MCMINMEM=512M
MCMAXMEM=2048M

Feed the Beast

Some Feed the Beast packs include a FTBInstall.sh. This script needs to be executed before starting the server.

cd /opt/minecraft/ftb-beyond
su -c 'bash /opt/minecraft/ftb-beyond/FTBInstall.sh' minecraft

Usage

Enable auto-start Minecraft server on boot

systemctl enable minecraft@ftb-beyond

Disable auto-start Minecraft server on boot

systemctl disable minecraft@ftb-beyond

Start Minecraft server manually

systemctl start minecraft@ftb-beyond

Stop Minecraft server manually

systemctl stop minecraft@ftb-beyond

Connecting to the Minecraft server console

To enter the console, screen is used.

All screen sessions are owned by the minecraft user and are prefixed with mc-.

# This will attach to the Minecraft server called `ftb-beyond`
su -c 'screen -r mc-ftb-beyond' minecraft

Note: To detach (exit) from the session, press CTRL + A followed by D.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
simondevyoutube/Quick_MinecraftClone2发布时间:2022-08-16
下一篇:
MCMrARM/modpe-mods: My Minecraft PE (ModPE) mods发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap