Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion - open and close firewall #239

Open
itbgjm opened this issue Feb 22, 2020 · 5 comments
Open

Suggestion - open and close firewall #239

itbgjm opened this issue Feb 22, 2020 · 5 comments

Comments

@itbgjm
Copy link

itbgjm commented Feb 22, 2020

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.
printf "Starting Minecraft Server:"
for WORLD in $WORLDS; do
if ! serverRunning $WORLD; then
printf " $WORLD"
start $WORLD
fi
#sudo /usr/bin/firewall-cmd --add-port=$PORT/tcp
sudo /usr/bin/firewall-cmd --add-port=25565/tcp
done

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
sudo /usr/bin/firewall-cmd --remove-port=25565/tcp
done

@sandain
Copy link
Member

sandain commented May 6, 2020

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.

@zanix
Copy link
Member

zanix commented Jun 9, 2020

Either this or allow launching another script

@sandain
Copy link
Member

sandain commented Jun 9, 2020

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

@zanix
Copy link
Member

zanix commented Jun 9, 2020

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

@sandain
Copy link
Member

sandain commented Jun 10, 2020

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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants