mirror of
https://github.com/michaelthomson0797/fleet-infra.git
synced 2026-02-04 13:09:53 +00:00
36 lines
1.2 KiB
YAML
36 lines
1.2 KiB
YAML
apiVersion: v1
|
|
data:
|
|
natpmp.sh: |
|
|
#!/bin/sh
|
|
|
|
while true; do
|
|
date
|
|
|
|
natpmpc -a 1 0 udp 60 -g 10.2.0.1 && natpmpc -a 1 0 tcp 60 -g 10.2.0.1 > /tmp/natpmpc_output || {
|
|
echo -e "ERROR with natpmpc command \a"
|
|
break
|
|
}
|
|
|
|
port=$(grep 'TCP' /tmp/natpmpc_output | grep -o 'Mapped public port [0-9]*' | awk '{print $4}')
|
|
currentPort=$(curl -XGET 'http://127.0.0.1:8080/api/v2/app/preferences' | jq '.listen_port')
|
|
|
|
echo "Opened port: $port"
|
|
echo "Current port: $currentPort"
|
|
if [ "$currentPort" != "$port" ]; then
|
|
echo "Current port is different. Changing from $currentPort to $port"
|
|
code=$(curl --write-out '%{http_code}' --silent --output /dev/null -XPOST -d "json={\"listen_port\":$port}" "http://127.0.0.1:8080/api/v2/app/setPreferences")
|
|
|
|
if [ "$code" != "200" ]; then
|
|
echo "ERROR: port change failed with status code $code"
|
|
else
|
|
echo "Port changed to $port successfully"
|
|
fi
|
|
fi
|
|
sleep 45
|
|
done
|
|
kind: ConfigMap
|
|
metadata:
|
|
creationTimestamp: null
|
|
name: natpmp-script
|
|
namespace: media
|