Open itbgjm opened 4 years ago
This is not a bad idea, but I wonder if it would be better to implement something like this in the properties files? E.g.:
mscs-prestart-command=sudo /usr/bin/firewall-cmd --add-port=$PORT/tcp
mscs-poststop-command=sudo /usr/bin/firewall-cmd --remove-port=$PORT/tcp
That would allow for much more customization than hard coding something in to the script.
Either this or allow launching another script
That is essentially what I am suggesting with the prestart/poststop commands. However, alternatively we can just update the documentation to mention that something like this is possible*:
mscs-default-server-command=sh prestart.sh && $JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_LOCATION/$SERVER_JAR $SERVER_ARGS && sh poststop.sh
*We should verify that this works
That works too, the only advantage I can see with having a separate config option is that it makes it more obvious if someone is looking for the functionality
Actually, modifying the server-command as I suggested above does not work -- It breaks the getJavaPID
method.
I think moving forward, the best option would be to add mscs-prestart-command
and mscs-poststop-command
options to the config files..
In /etc/sudoers
User privilege specification
root ALL=(ALL) ALL minecraft ALL=NOPASSWD:/usr/bin/firewall-cmd --add-port=25565/tcp minecraft ALL=NOPASSWD:/usr/bin/firewall-cmd --remove-port=25565/tcp
msctl file around line 2426
Start each world requested, if not already running.
and
line 2469 sendCommand $WORLD "save-all" sendCommand $WORLD "save-off" if [ "$COMMAND" = "force-stop" ]; then forceStop $WORLD else stop $WORLD fi elif [ "$COMMAND" = "force-stop" ]; then printf " $WORLD" forceStop $WORLD fi
sudo /usr/bin/firewall-cmd --remove-port=$PORT/tcp