- Migrate vyprvpn up & down scripts.

This commit is contained in:
2025-06-30 10:04:04 +02:00
parent d227ca6d5a
commit 447623f748
2 changed files with 147 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
#!/bin/bash
#DEBUG=""
DEBUG="echo"
#DEBUG=":"
LOG=":"
#LOG="echo"
# Includes
#-----------------------------------------------------------------------------------------------------------------------------------
. /usr/local/lib/network.bash
# Global Variables
#-----------------------------------------------------------------------------------------------------------------------------------
LOG_FILE=/var/log/openvpn/up-down.log
# Main
#-----------------------------------------------------------------------------------------------------------------------------------
Dev="$1"
Local_MTU="$2"
Rrmote_MTU="$3"
Local_Address="$4"
Local_Netmask="$5"
Phase="$6"
network_tab_load
network_dst_tab_dev_lookup "${dev}"
network_dst_tab_get "${dst_id}"
echo -n >>${log_file} "$(date): Down: [${Dev}] Local_MTU: [${Local_MTU}] Remote_MTU: [${Remote_MTU}] Local_Address: [${Local_Address}] Local_Netmask: [${Local_Netmask}] Target_Table: ${target_table} Phase: ${Phase}"
if [[ "${dst_table}" != "" ]]
then
echo >>${log_file} " Status: [OK]"
remote_address=0.0.0.0
echo >>${log_file} "$(date): Down: ${Dev}: set ${remote_address} to vpn${id}.vpn.rx3"
/usr/local/sbin/ip_host_update vpn${id} vpn.rx3 ${remote_address} 60
else
echo >>${log_file} " Status: [ERROR]!"
fi
echo >>${log_file} "$(date): Down: ${Dev}: Done"

85
usr/local/sbin/vyprvpn-up Normal file
View File

@@ -0,0 +1,85 @@
#!/bin/bash
#DEBUG=""
DEBUG="echo"
#DEBUG=":"
LOG=":"
#LOG="echo"
# Includes
#-----------------------------------------------------------------------------------------------------------------------------------
. /usr/local/lib/network.bash
# Global Variables
#-----------------------------------------------------------------------------------------------------------------------------------
LOG_FILE=/var/log/openvpn/up-down.log
# Main
#-----------------------------------------------------------------------------------------------------------------------------------
Dev="$1"
Local_MTU="$2"
Rrmote_MTU="$3"
Local_Address="$4"
Local_Netmask="$5"
Phase="$6"
network_tab_load
network_dst_tab_dev_lookup "${dev}"
network_dst_tab_get "${dst_id}"
echo -n >>${log_file} "$(date): Up: [${Dev}] Local_MTU: [${Local_MTU} Remote_MTU: [${Remote_MTU}] Local_Address: [${Local_Address}] Local_Netmask: [${Local_Netmask}] Target_Table: [${target_table}] Dst_Id: [${dst_id}] Phase: [${Phase}]"
if [[ "${dst_table}" != "" ]]
then
echo >>${log_file} " Status: [OK]"
echo >>${log_file} "$(date): Up: ${Dev}: ip route add table ${dst_table} default dev ${Dev}"
/usr/sbin/ip route del table ${dst_table} default
/usr/sbin/ip route add table ${dst_table} default dev ${Dev}
# (
# sleep 3
#
# i=0
#
# while [[ ${remote_address} == "" && $i -lt 5 ]]
# do
# remote_address=$(/usr/local/sbin/ns-launch 3 ${dst_table} /usr/local/bin/my_address_get 2>/dev/null)
# echo >>${log_file} "$(date): Up: ${Dev}: Remote_Address=${remote_address} try=$i"
#
# i=$(($i + 1))
# sleep 5
# done
#
# if [[ remote_address != "" ]]
# then
# echo >>${log_file} "$(date): Up: ${Dev}: set ${remote_address} to vpn${dst_id}.vpn.rx3"
# /usr/local/sbin/ip_host_update vpn${dst_id} vpn.rx3 ${remote_address} 60
# else
# echo >>${log_file} "$(date): Up: ${Dev}: VPN not working?"
# fi
#
# echo >>${log_file} "$(date): Up: ${Dev}: Done!"
# ) &
echo >>${log_file} "$(date): Up: ${Dev}: Partially Done..."
else
echo >>${log_file} " Status: [ERROR]!"
echo >>${log_file} "$(date): Up: [${Dev}] Done"
fi