.service
This commit is contained in:
parent
5739e2c95e
commit
e3a6c5c532
@ -2,7 +2,9 @@ To switch user use: su minecraft -s /bin/bash
|
|||||||
|
|
||||||
# To DO
|
# To DO
|
||||||
- [ ] Basic commands
|
- [ ] Basic commands
|
||||||
|
- [ ] server.properties + run.sh
|
||||||
- [ ] iptable commands
|
- [ ] iptable commands
|
||||||
- [ ] my own .service file
|
- [ ] my own .service file
|
||||||
- [ ] modification of run.sh
|
- [ ] modification of run.sh
|
||||||
- [ ] screen usege
|
- [ ] screen usege
|
||||||
|
- [ ] SSH keys
|
||||||
|
|||||||
42
mc-forge.service
Normal file
42
mc-forge.service
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Minecraft Server
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecReload=/usr/bin/screen -S minecraft -X stuff \"reload^M\"
|
||||||
|
|
||||||
|
#ExecStart=/usr/bin/screen -DmS minecraft run.sh
|
||||||
|
|
||||||
|
ExecStartPre=/bin/sh -c '/usr/bin/screen -dmS mc-perfect'
|
||||||
|
ExecStart=/bin/sh -c '/opt/minecraft/run.sh'
|
||||||
|
|
||||||
|
#ExecStop=/usr/bin/screen -S minecraft -X stuff \"save-all^M\"
|
||||||
|
#ExecStop=/bin/sleep 5
|
||||||
|
#ExecStop=/usr/bin/screen -S minecraft -X stuff \"stop^M\"
|
||||||
|
#ExecStop=/bin/sleep 5
|
||||||
|
|
||||||
|
ExecStop=/usr/bin/screen -p 0 -S mc-perfect -X eval 'stuff "say SERVER SHUTTING DOWN. Saving map..."\\015'
|
||||||
|
ExecStop=/bin/sh -c '/bin/sleep 5'
|
||||||
|
ExecStop=/usr/bin/screen -p 0 -S mc-perfect -X eval 'stuff "save-all"\\015'
|
||||||
|
ExecStop=/usr/bin/screen -p 0 -S mc-perfect -X eval 'stuff "stop"\\015'
|
||||||
|
ExecStop=/bin/sh -c '/bin/sleep 10'
|
||||||
|
|
||||||
|
#Restart=on-failure
|
||||||
|
#RestartSec=60s
|
||||||
|
|
||||||
|
ProtectControlGroups=true
|
||||||
|
ProtectHome=true
|
||||||
|
ProtectKernelModules=true
|
||||||
|
ProtectKernelTunables=true
|
||||||
|
ProtectSystem=full
|
||||||
|
|
||||||
|
PrivateDevices=true
|
||||||
|
PrivateUsers=true
|
||||||
|
|
||||||
|
User=minecraft
|
||||||
|
Group=minecraft
|
||||||
|
|
||||||
|
WorkingDirectory=/opt/minecraft/
|
||||||
@ -3,4 +3,4 @@ sudo apt upgrade
|
|||||||
sudo apt install openjdk-17-jre-headless neofetch btop screen wget curl vim grep vim
|
sudo apt install openjdk-17-jre-headless neofetch btop screen wget curl vim grep vim
|
||||||
groupadd minecraft
|
groupadd minecraft
|
||||||
useradd --system --shell /usr/sbin/nologin --home /opt/minecraft -g minecraft minecraf
|
useradd --system --shell /usr/sbin/nologin --home /opt/minecraft -g minecraft minecraf
|
||||||
|
# find out if /opt/minecraft exist else mkdir /opt/minecraft
|
||||||
@ -1,30 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Minecraft Server
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecReload=/usr/bin/screen -S minecraft -X stuff \"reload^M\"
|
|
||||||
|
|
||||||
ExecStart=/usr/bin/screen -DmS minecraft run.sh
|
|
||||||
|
|
||||||
ExecStop=/usr/bin/screen -S minecraft -X stuff \"save-all^M\"
|
|
||||||
ExecStop=/bin/sleep 5
|
|
||||||
ExecStop=/usr/bin/screen -S minecraft -X stuff \"stop^M\"
|
|
||||||
ExecStop=/bin/sleep 5
|
|
||||||
|
|
||||||
ProtectControlGroups=true
|
|
||||||
ProtectHome=true
|
|
||||||
ProtectKernelModules=true
|
|
||||||
ProtectKernelTunables=true
|
|
||||||
ProtectSystem=full
|
|
||||||
|
|
||||||
PrivateDevices=true
|
|
||||||
PrivateUsers=true
|
|
||||||
|
|
||||||
User=minecraft
|
|
||||||
Group=minecraft
|
|
||||||
|
|
||||||
WorkingDirectory=/opt/minecraft/
|
|
||||||
Loading…
x
Reference in New Issue
Block a user