Screen needs mode 777 with systemd service
I am trying to set up Minecraft to run in a screen session on start-up. but with the following service file, bellow is my status of my service.
I am new to using the Systemd way of boot services so any help would be appreciated.
minecraft.service - Minecraft Server
Loaded: loaded (/home/matt/minecraft.service; enabled; vendor preset: enabled)
Active: active (exited) since Fri 2016-12-16 14:17:59 GMT; 6min ago
Process: 15942 ExecStopPost=/usr/bin/screen -X -S Minecraft exit (code=exited, status=1/FAILURE)
Process: 15940 ExecStop=/var/minecraft/mcrcon -H localhost -P 8101 -p drwho stop (code=exited, status=255)
Process: 15990 ExecStart=/usr/bin/screen -X -S Minecraft /usr/bin/java -Xmx1024M -Xms1024M -jar spigot.jar (code=exited, status=1/FAILURE)
Process: 15985 ExecStartPre=/usr/bin/screen -dmS Minecraft (code=exited, status=1/FAILURE)
Main PID: 15990 (code=exited, status=1/FAILURE)
Dec 16 14:17:59 TheCyberman systemd[1]: Starting Minecraft Server...
Dec 16 14:17:59 TheCyberman screen[15985]: Directory '/var/run/screen' must have mode 777.
Dec 16 14:17:59 TheCyberman systemd[1]: Started Minecraft Server.
Dec 16 14:17:59 TheCyberman screen[15990]: Directory '/var/run/screen' must have mode 777.
This is my Service file
[Unit]
Description=Minecraft Server
Documentation=
Wants=network.target
After=network.target
[Service]
User=minecraft
Group=minecraft
Nice=5
EnvironmentFile=-/var/minecraft/unit.conf
KillMode=none
SuccessExitStatus=0 1
RemainAfterExit=yes
ProtectHome=true
ProtectSystem=full
PrivateDevices=true
NoNewPrivileges=true
PrivateTmp=true
InaccessibleDirectories=/root /sys /srv -/opt /media -/lost+found
ReadWriteDirectories=/var/minecraft/server /usr/bin/screen
WorkingDirectory=/var/minecraft/server
ExecStartPre= /usr/bin/screen -dmS Minecraft
ExecStart= /usr/bin/screen -X -S Minecraft '/usr/bin/java -Xmx1024M -Xms1024M -jar spigot.jar'
ExecStop=/var/minecraft/mcrcon -H localhost -P 8101 -p drwho stop
ExecStopPost= /usr/bin/screen -X -S Minecraft 'exit'
ExecReload=/var/minecraft/mcrcon -H localhost -P 8101 -p drwho reload
Restart=on-failure
[Install]
WantedBy=multi-user.target
Solution 1:
The directory needs full permissions to read, write, and execute.
You can do this command chmod -R 777 /var/run/screen
Which will recursively change all folders/files permissions to 777, though typically less secure.
You can also run sudo chown -R $USER:$USER /var/run/screen
This will allow a typical user/or group full access, and will be more secure.