Skip to content
Snippets Groups Projects
Commit d29cc738 authored by Bob Mottram's avatar Bob Mottram
Browse files

Move external ip function

parent e6e7711f
No related branches found
No related tags found
No related merge requests found
......@@ -110,19 +110,6 @@ function enable_ipv6 {
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
}
function update_external_ip {
ip_update_script=/usr/bin/externalipupdate
echo '#!/bin/bash' >> $ip_update_script
echo "existing_ip=\$(cat $CONFIGURATION_FILE | grep \"EXTERNAL_IPV4_ADDRESS=\" | head -n 1 | awk -F '=' '{print \$2}')'" >> $ip_update_script
echo "curr_ip=\$(nslookup . $EXTERNAL_IP_LOOKUP_URL | grep Address | tail -n 1 | awk -F ' ' '{print \$2}')" >> $ip_update_script
echo 'if [[ "$curr_ip" != "$existing_ip" ]]; then' >> $ip_update_script
echo " sed -i \"s|EXTERNAL_IPV4_ADDRESS=.*|EXTERNAL_IPV4_ADDRESS=\${curr_ip}|g\" $CONFIGURATION_FILE" >> $ip_update_script
echo ' iptables-save > /etc/firewall.conf' >> $ip_update_script
echo 'fi' >> $ip_update_script
cron_add_mins 10 $ip_update_script
}
function firewall_disable_vpn {
iptables -D INPUT -i ${FIREWALL_EIFACE} -m state --state NEW -p udp --dport 1194 -j ACCEPT
iptables -D INPUT -i tun+ -j ACCEPT
......
......@@ -85,4 +85,17 @@ function get_ipv6_address {
echo $(echo "$retval" | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
}
function update_external_ip {
ip_update_script=/usr/bin/externalipupdate
echo '#!/bin/bash' >> $ip_update_script
echo "existing_ip=\$(cat $CONFIGURATION_FILE | grep \"EXTERNAL_IPV4_ADDRESS=\" | head -n 1 | awk -F '=' '{print \$2}')'" >> $ip_update_script
echo "curr_ip=\$(nslookup . $EXTERNAL_IP_LOOKUP_URL | grep Address | tail -n 1 | awk -F ' ' '{print \$2}')" >> $ip_update_script
echo 'if [[ "$curr_ip" != "$existing_ip" ]]; then' >> $ip_update_script
echo " sed -i \"s|EXTERNAL_IPV4_ADDRESS=.*|EXTERNAL_IPV4_ADDRESS=\${curr_ip}|g\" $CONFIGURATION_FILE" >> $ip_update_script
echo ' iptables-save > /etc/firewall.conf' >> $ip_update_script
echo 'fi' >> $ip_update_script
cron_add_mins 10 $ip_update_script
}
# NOTE: deliberately no exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment