Added Mordhau-Open-Ports.bash
This commit is contained in:
parent
7ce518369f
commit
8c72ea3f31
14
Mordhau/Mordhau-Open-Ports.bash
Executable file
14
Mordhau/Mordhau-Open-Ports.bash
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash --posix
|
||||
|
||||
set -e
|
||||
|
||||
firewall-cmd --add-port 7770-7779/tcp --permanent
|
||||
firewall-cmd --add-port 27000-27009/tcp --permanent
|
||||
firewall-cmd --add-port 15000-15009/tcp --permanent
|
||||
firewall-cmd --add-port 26000-26009/tcp --permanent
|
||||
|
||||
echo "All ports open for Mordhau servers - reloading firewall-cmd..."
|
||||
|
||||
firewall-cmd --reload
|
||||
|
||||
echo "Finished opening ports."
|
@ -24,50 +24,54 @@ usage() {
|
||||
All above flags must be passed with arguments"
|
||||
}
|
||||
|
||||
|
||||
error() {
|
||||
printf '%s\n' "$1" >&2
|
||||
exit 1
|
||||
printf '%s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
while :; do
|
||||
case $1 in
|
||||
-h|-\?|--help)
|
||||
usage # Display a usage synopsis.
|
||||
exit
|
||||
;;
|
||||
--) # End of all options.
|
||||
shift
|
||||
break
|
||||
;;
|
||||
--ip)
|
||||
shift
|
||||
[[ "${1}" == "" ]] && error "--ip requires an argument"
|
||||
IP=${1}
|
||||
;;
|
||||
--inbound-port)
|
||||
shift
|
||||
[[ "${1}" == "" ]] && error "--inbound-port requires an argument"
|
||||
INBOUND_PORT=${1}
|
||||
;;
|
||||
--forward-port)
|
||||
shift
|
||||
[[ "${1}" == "" ]] && error "--forward-port requires an argument"
|
||||
FORWARD_PORT=${1}
|
||||
;;
|
||||
-?*)
|
||||
printf 'Unknown option: %s\n' "$1" >&2
|
||||
usage
|
||||
;;
|
||||
*) # Default case: No more options, so break out of the loop.
|
||||
break
|
||||
esac
|
||||
|
||||
case $1 in
|
||||
-h | -\? | --help)
|
||||
usage # Display a usage synopsis.
|
||||
exit
|
||||
;;
|
||||
--) # End of all options.
|
||||
shift
|
||||
break
|
||||
;;
|
||||
--ip)
|
||||
shift
|
||||
[[ "${1}" == "" ]] && error "--ip requires an argument"
|
||||
IP=${1}
|
||||
;;
|
||||
--inbound-port)
|
||||
shift
|
||||
[[ "${1}" == "" ]] && error "--inbound-port requires an argument"
|
||||
INBOUND_PORT=${1}
|
||||
;;
|
||||
--forward-port)
|
||||
shift
|
||||
[[ "${1}" == "" ]] && error "--forward-port requires an argument"
|
||||
FORWARD_PORT=${1}
|
||||
;;
|
||||
-?*)
|
||||
printf 'Unknown option: %s\n' "$1" >&2
|
||||
usage
|
||||
;;
|
||||
*) # Default case: No more options, so break out of the loop.
|
||||
break ;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
[[ "${IP}" == "" ]] && error "--ip requires an argument"
|
||||
[[ "${FORWARD_PORT}" == "" ]] && error "--forward-port requires an argument"
|
||||
[[ "${INBOUND_PORT}" == "" ]] && error "--inbound-port requires an argument"
|
||||
|
||||
firewall-cmd --permanent --add-forward-port=port="${INBOUND_PORT}":proto=tcp:toaddr="${IP}":toport="${FORWARD_PORT}"
|
||||
firewall-cmd --permanent --add-port="${INBOUND_PORT}"/tcp
|
||||
firewall-cmd --add-masquerade
|
||||
firewall-cmd --reload
|
||||
|
||||
echo "Routing all data on ${INBOUND_PORT} to ${IP}${FORWARD_PORT}"
|
||||
echo "Routing all data on ${INBOUND_PORT} to ${IP}:${FORWARD_PORT}"
|
Loading…
Reference in New Issue
Block a user