I installed a modded FTB server to my Ubuntu Server, created a user and group called "ftb", and gave it its own directory /opt/ftb/
that contains a folder with the server files. In the server folder, there is a start.sh file to start the server. How do I make a system service file so I can use commands such as systemctl status ftbacademy.service
, systemctl start ftbacademy.service
, and systemctl stop ftbacademy.service
. Upon stopping the server I wish for it to save and then close the server. What would the .service file look like? I know it has to be placed in /etc/systemd/system/
, but I don't know how to write the file that would make the ftb user open it's own virtual terminal or whatever to be able to save the world and then stop the server.
Ubuntu Server Version 20.04.3
FTB Academy 1.16 Server Files Download Site Used: https://feed-the-beast.com/modpacks/88/server/2077 I selected the Linux download option then ran the install file to automatically download the server files.
I am also using a different version of JDK to run the server file so I changed the start.sh file to this:
#!/bin/bash
if ! grep -q "eula=true" eula.txt; then
echo "Do you agree to the Mojang EULA available at https://account.mojang.com/documents/minecraft_eula ?"
read -N 1 -p "[y/n] " EULA
if [ "$EULA" = "y" ]; then
echo "eula=true" > eula.txt
echo
fi
fi
/usr/lib/jvm/java-11-openjdk-amd64/bin/java -javaagent:log4jfix/Log4jPatcher-1.0.0.jar -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -Xmx5000M -Xms4000M -jar forge-1.16.5-36.2.2.jar nogui
.bashrc
, but I would need to see exactly what it does before giving install advice. Besides, I want a copy of the server. XD Btw you need to add your Ubuntu version to the question. Different versions contain different environments. Most answers will vary at least a tiny bit dependant on version. Especially since we just changed default win mgr in 21.04 – Nate T Jan 02 '22 at 02:45cd /usr/lib/jvm/java-11-openjdk-amd64/bin && ls -a | grep java
outputsjava java javac javadoc javap
. How will this help with the creation of the .service file? I have no issues running the server, I just want to make a .service file to run it on startup, stop the server, and check the status using the ftb user. Forgive me if I'm misunderstanding what's going on. I'm not too familiar with this. I mostly follow very specific guides and copy and paste stuff. – lordoftimelords Jan 02 '22 at 03:48MC_CMD='alias start_srvr="/usr/lib/jvm/java-11-openjdk-amd64/bin/java -javaagent:log4jfix/Log4jPatcher-1.0.0.jar -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -Xmx5000M -Xms4000M -jar forge-1.16.5-36.2.2.jar nogui"' && echo "${MC_CMD}" >> ~/.bash_aliases || echo "${MC_CMD}" >> ~/.bashrc
– Nate T Jan 02 '22 at 04:46&& echo "${MC_CMD}" >> ~/.bash_aliases || echo "${MC_CMD}" >> ~/.bashrc
do? – lordoftimelords Jan 02 '22 at 05:10sudo chmod 774 <folder-path>
will give you permission needed, but runls -l <folder-path>
and write down the old permission string first, in case you need to change back. Also why would you use systemd to run a start script? Are you wanting to run as a daemon? That wouldn't really make sense, unless you are using it as a dedicated webserver, in which case nevermind... – Nate T Jan 02 '22 at 05:19User=
andGroup=
for running as another user in systemd. – Terrance Jan 02 '22 at 05:36