Skip to content

Instantly share code, notes, and snippets.

@Eelviny
Last active March 24, 2018 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eelviny/656f1a7904bbc43a2669a4880dc0e948 to your computer and use it in GitHub Desktop.
Save Eelviny/656f1a7904bbc43a2669a4880dc0e948 to your computer and use it in GitHub Desktop.
TTN SPF klk15 for iFemtocell HAL klk7
#!/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
) &
@Eelviny
Copy link
Author

Eelviny commented Mar 24, 2018

NOTE: This script is specifically for:

  • Kerlink firmware 3.3.3
  • HAL klk7
  • Semtech Packet Forwarder klk15

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.

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