Last active
March 24, 2018 16:17
-
-
Save Eelviny/656f1a7904bbc43a2669a4880dc0e948 to your computer and use it in GitHub Desktop.
TTN SPF klk15 for iFemtocell HAL klk7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# Replace the existing file with this in /user/spf/bin/ | |
# Move to configuration directory | |
cd /user/spf/etc | |
# Create configuration and version files | |
ln -fs /user/spf/etc/global_conf.json /tmp/packet_forwarder.conf | |
echo spf 3.1.0-klk15 +hal_libloragw_4.1.3-klk7 > /tmp/packet_forwarder_version.txt | |
# Open firewall ports | |
iptables_accept() { | |
local PORT=1700 | |
[ -z "${PORT}" ] && return | |
local RULE="OUTPUT -t filter -p udp --dport $PORT -j ACCEPT" | |
iptables -C $RULE 2> /dev/null || iptables -I $RULE | |
local RULE="INPUT -t filter -p udp --sport $PORT -j ACCEPT" | |
iptables -C $RULE 2> /dev/null || iptables -I $RULE | |
} | |
iptables_accept /tmp/packet_forwarder.conf serv_port_up | |
iptables_accept /tmp/packet_forwarder.conf serv_port_down | |
( | |
# Lock on pid file | |
exec 8> /var/run/packet_forwarder.pid | |
flock -n -x 8 | |
trap "rm -f /var/run/packet_forwarder.pid" EXIT | |
# Start packet forwarder | |
/user/spf/bin/spf 2>&1 | logger -p local1.notice -t spf & | |
trap "killall -q spf" INT QUIT TERM | |
# Update pid and wait for it | |
pidof spf >&8 | |
wait | |
) & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: This script is specifically for:
If you are using a different version, it's best to manually copy the changes into the existing file, instead of overwriting it with this one.