Compare commits
9 Commits
network_to
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f58ffedef9 | |||
| 360db73a09 | |||
| 6d2fd44dba | |||
| 0c05cfd6c0 | |||
| 540bd1ce03 | |||
| 5e3d8ed47b | |||
| ce66dba7a6 | |||
| 2083444bc1 | |||
| 8cd1bcce64 |
@@ -1,8 +1,38 @@
|
|||||||
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
Network Tools V 1.2.0 - A. GIBERT - 2026/04/xx
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
- Split repository to remove the Rx3 configuration part and push it to rx3-config repo,
|
||||||
|
- Switch this repository to public,
|
||||||
|
- Migrate Network Tools to the new Rx3 Base Bash library,
|
||||||
|
- Add RPM Spec & bash completion files,
|
||||||
|
- Move install dir form /usr/locla to usr,
|
||||||
|
- Support now rx3-base 1.1.1.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
Network Tools V 1.1.3 - A. GIBERT - 2025/09/19
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
- Fix uptime for gateway destinations,
|
||||||
|
- Add status filtering in the VPN Admin page.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
Network Tools V 1.1.2 - A. GIBERT - 2025/09/12
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
- Minor fixes in config files and openvpn-status.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
Network Tools V 1.1.1 - A. GIBERT - 2025/09/03
|
Network Tools V 1.1.1 - A. GIBERT - 2025/09/03
|
||||||
------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
- Add a new conection state for gateways device up with no gateway client conected,
|
- Add a new conection state for gateways device up with no gateway client connected,
|
||||||
- Improve openvpn stats reporting,
|
- Improve openvpn stats reporting,
|
||||||
- Improve device up api events,
|
- Improve device up api events,
|
||||||
- Add network reinit() function,
|
- Add network reinit() function,
|
||||||
|
|||||||
91
etc/bash_completion.d/rx3_net_adm
Normal file
91
etc/bash_completion.d/rx3_net_adm
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Rx3 Net Adm Bash Completion
|
||||||
|
#
|
||||||
|
# Copyright (C) 2025-2026 Arnaud G. GIBERT
|
||||||
|
# mailto:arnaud@rx3.net
|
||||||
|
#
|
||||||
|
# This is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; If not, see
|
||||||
|
# <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Rx3 Net Adm Completion
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_rx3_net_adm_completion()
|
||||||
|
{
|
||||||
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
local opts="-h --help -V --version -v --verbose"
|
||||||
|
|
||||||
|
local pos=0
|
||||||
|
local i
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
|
||||||
|
# Count non-option positional arguments already provided
|
||||||
|
for (( i=1; i<COMP_CWORD; i++ ))
|
||||||
|
do
|
||||||
|
case "${COMP_WORDS[i]}" in
|
||||||
|
-h|--help|-V|--version|-v|--verbose)
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
pos=$(( pos + 1 ))
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Complete options if current word starts with '-'
|
||||||
|
if [[ "${cur}" == -* ]]
|
||||||
|
then
|
||||||
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Complete positional arguments
|
||||||
|
case "${pos}" in
|
||||||
|
0)
|
||||||
|
COMPREPLY=( $(compgen -W "start stop restart status dump table_set refresh_address" -- "${cur}") )
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
case "${prev}" in
|
||||||
|
table_set)
|
||||||
|
COMPREPLY=( $(compgen -W "$(network_dst_tab_dump | grep -oP 'Name.*: \[\K[^\]]+')" -- "${cur}") )
|
||||||
|
;;
|
||||||
|
refresh_address)
|
||||||
|
COMPREPLY=( $(compgen -W "$(network_dst_tab_dump | grep -oP 'Name.*: \[\K[^\]]+')" -- "${cur}") )
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
complete -o filenames -F _rx3_net_adm_completion rx3_net_adm
|
||||||
@@ -1,28 +1,48 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Rx3 DNS Library
|
||||||
|
#
|
||||||
|
# Copyright (C) 2025-2026 Arnaud G. GIBERT
|
||||||
|
# mailto:arnaud@rx3.net
|
||||||
|
#
|
||||||
|
# This is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this program; If not, see
|
||||||
|
# <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
if [[ "${DNS_BASH}" != "" ]]
|
if [[ "${RX3_DNS_LIB}" != "" ]]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
declare -g DNS_BASH=1
|
declare -g RX3_DNS_LIB=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
# Includes
|
# Includes
|
||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
if [[ -e /usr/local/lib/default.bash ]]
|
: "${RX3_LIB_DIR:=/usr/lib/rx3}"
|
||||||
then
|
. "${RX3_LIB_DIR}/base.bash"
|
||||||
. /usr/local/lib/default.bash
|
|
||||||
else
|
|
||||||
. /usr/global/lib/default.bash
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
# Global Variable
|
# Global Variable
|
||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -1,23 +1,48 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Rx3 Network Library
|
||||||
|
#
|
||||||
|
# Copyright (C) 2025-2026 Arnaud G. GIBERT
|
||||||
|
# mailto:arnaud@rx3.net
|
||||||
|
#
|
||||||
|
# This is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this program; If not, see
|
||||||
|
# <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
if [[ "${NETWORK_BASH}" != "" ]]
|
if [[ "${RX3_NETWORK_LIB}" != "" ]]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
declare -g NETWORK_BASH=1
|
declare -g RX3_NETWORK_LIB=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
# Includes
|
# Includes
|
||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
. /usr/local/lib/dns.bash
|
: "${RX3_LIB_DIR:=/usr/lib/rx3}"
|
||||||
|
. "${RX3_LIB_DIR}/dns.bash"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
# Global Variable
|
# Global Variable
|
||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -119,7 +144,7 @@ num_to_ip()
|
|||||||
# Optional safety check
|
# Optional safety check
|
||||||
if (( num < 0 || num > 4294967295 ))
|
if (( num < 0 || num > 4294967295 ))
|
||||||
then
|
then
|
||||||
echo "num_to_ip: value out of range (0‑4294967295)" >&2
|
echo_error "num_to_ip: value out of range (0‑4294967295)"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -406,9 +431,14 @@ network_dst_tab_load()
|
|||||||
|
|
||||||
if [[ "${ndtl_status}" == "1" ]]
|
if [[ "${ndtl_status}" == "1" ]]
|
||||||
then
|
then
|
||||||
|
if [[ "${ndtl_type}" == "1" ]]
|
||||||
|
then
|
||||||
|
ndtl_start_date="${ovpn_stat_connected_date}"
|
||||||
|
ndtl_uptime="$( echo $(( $(date +%s) - ${ovpn_stat_connected_time_t})) | awk '{days = int($1/86400); print days " day" (( days > 1 ) ? "s" : "") strftime(" %H:%M:%S", $1,1)}')"
|
||||||
|
else
|
||||||
ndtl_start_date="$( stat -c %Z /sys/class/net/${ndtl_device})"
|
ndtl_start_date="$( stat -c %Z /sys/class/net/${ndtl_device})"
|
||||||
ndtl_uptime="$( echo $(( $(date +%s) - ${ndtl_start_date})) | awk '{days = int($1/86400); print days " day" (( days > 1 ) ? "s" : "") strftime(" %H:%M:%S", $1,1)}')"
|
ndtl_uptime="$( echo $(( $(date +%s) - ${ndtl_start_date})) | awk '{days = int($1/86400); print days " day" (( days > 1 ) ? "s" : "") strftime(" %H:%M:%S", $1,1)}')"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
ndtl_start_date=""
|
ndtl_start_date=""
|
||||||
ndtl_uptime=""
|
ndtl_uptime=""
|
||||||
@@ -694,7 +724,7 @@ network_src_tab_load()
|
|||||||
|
|
||||||
if [[ " ${NETWORK_TABLE_LIST} " != *" ${nstl_table} "* ]]
|
if [[ " ${NETWORK_TABLE_LIST} " != *" ${nstl_table} "* ]]
|
||||||
then
|
then
|
||||||
err_echo "Invalid table number: [${nstl_table}] in network src entry: [${nstl_id}]!"
|
echo_error "Invalid table number: [${nstl_table}] in network src entry: [${nstl_id}]!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1089,13 +1119,13 @@ network_table_set()
|
|||||||
|
|
||||||
if [[ "${src_id}" == "" ]]
|
if [[ "${src_id}" == "" ]]
|
||||||
then
|
then
|
||||||
err_echo "IP not found: [${nts_ip}]!"
|
echo_error "IP not found: [${nts_ip}]!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ " ${NETWORK_TABLE_LIST} " != *" ${nts_table} "* ]]
|
if [[ " ${NETWORK_TABLE_LIST} " != *" ${nts_table} "* ]]
|
||||||
then
|
then
|
||||||
err_echo "Table not found: [${nts_table}]!"
|
echo_error "Table not found: [${nts_table}]!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1,23 +1,48 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Rx3 VPN Library
|
||||||
|
#
|
||||||
|
# Copyright (C) 2025-2026 Arnaud G. GIBERT
|
||||||
|
# mailto:arnaud@rx3.net
|
||||||
|
#
|
||||||
|
# This is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this program; If not, see
|
||||||
|
# <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
if [[ "${VPN_BASH}" != "" ]]
|
if [[ "${RX3_VPN_LIB}" != "" ]]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
declare -g VPN_BASH=1
|
declare -g RX3_VPN_LIB=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
# Includes
|
# Includes
|
||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
. /usr/local/lib/network.bash
|
: "${RX3_LIB_DIR:=/usr/lib/rx3}"
|
||||||
|
. "${RX3_LIB_DIR}/network.bash"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
# Global Variable
|
# Global Variable
|
||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
dev=$1
|
|
||||||
|
|
||||||
if [[ "$1" != "" ]]
|
|
||||||
then
|
|
||||||
cat /etc/openvpn/openvpn-status-$dev.log
|
|
||||||
else
|
|
||||||
awk '{print FILENAME ": " $0}' /etc/openvpn/openvpn-status-*.log
|
|
||||||
fi
|
|
||||||
@@ -1,185 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
RETVAL=0
|
|
||||||
prog="rx3-net"
|
|
||||||
|
|
||||||
#DEBUG=""
|
|
||||||
#DEBUG="echo"
|
|
||||||
#DEBUG=":"
|
|
||||||
|
|
||||||
#LOG=":"
|
|
||||||
#LOG="echo"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Includes
|
|
||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
. /usr/local/lib/network.bash
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
# Start
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
start()
|
|
||||||
{
|
|
||||||
echo "Starting..."
|
|
||||||
|
|
||||||
if [ -r /var/lock/subsys/rx3-net ]
|
|
||||||
then
|
|
||||||
echo "already started"
|
|
||||||
RETVAL=0
|
|
||||||
else
|
|
||||||
network_start
|
|
||||||
|
|
||||||
RETVAL=$?
|
|
||||||
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/rx3-net
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
# Stop
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
stop()
|
|
||||||
{
|
|
||||||
echo "Stopping..."
|
|
||||||
|
|
||||||
if [ -r /var/lock/subsys/rx3-net ]
|
|
||||||
then
|
|
||||||
network_stop
|
|
||||||
|
|
||||||
RETVAL=$?
|
|
||||||
else
|
|
||||||
echo "already stopped"
|
|
||||||
RETVAL=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/rx3-net
|
|
||||||
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
# Status
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
status()
|
|
||||||
{
|
|
||||||
network_status
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
# Dump
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
dump()
|
|
||||||
{
|
|
||||||
network_tab_dump
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
# Table_Set
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
table_set()
|
|
||||||
{
|
|
||||||
echo "Setting ip:$1 table:$2"
|
|
||||||
|
|
||||||
network_table_set $1 $2
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
# Address_Refresh
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
address_refresh()
|
|
||||||
{
|
|
||||||
dst_id="$1"
|
|
||||||
|
|
||||||
|
|
||||||
if [[ "${dst_id}" != "" ]]
|
|
||||||
then
|
|
||||||
echo "Refreshing address: [${dst_id}]..."
|
|
||||||
|
|
||||||
network_dst_tab_get ${dst_id}
|
|
||||||
network_dst_address_refresh ${dst_id} ${dst_host_name} ${dst_ip}
|
|
||||||
else
|
|
||||||
echo "Refreshing all address..."
|
|
||||||
|
|
||||||
network_dst_address_refresh_all
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
# Main
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
network_init
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
start
|
|
||||||
;;
|
|
||||||
|
|
||||||
stop)
|
|
||||||
stop
|
|
||||||
;;
|
|
||||||
|
|
||||||
restart)
|
|
||||||
stop
|
|
||||||
sleep 1
|
|
||||||
start
|
|
||||||
;;
|
|
||||||
|
|
||||||
status)
|
|
||||||
status
|
|
||||||
;;
|
|
||||||
|
|
||||||
dump)
|
|
||||||
dump
|
|
||||||
;;
|
|
||||||
|
|
||||||
table_set)
|
|
||||||
table_set $2 $3
|
|
||||||
;;
|
|
||||||
|
|
||||||
refresh_address)
|
|
||||||
address_refresh $2
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 {start|stop|restart|status|dump|table_set|refresh_address}"
|
|
||||||
RETVAL=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
network_deinit
|
|
||||||
|
|
||||||
exit $RETVAL
|
|
||||||
10
usr/sbin/openvpn-status
Executable file
10
usr/sbin/openvpn-status
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
dev=$1
|
||||||
|
|
||||||
|
if [[ "$1" != "" ]]
|
||||||
|
then
|
||||||
|
cat /var/lib/openvpn/$dev.status
|
||||||
|
else
|
||||||
|
awk '{print FILENAME ": " $0}' /var/lib/openvpn/*.status
|
||||||
|
fi
|
||||||
312
usr/sbin/rx3_net_adm
Executable file
312
usr/sbin/rx3_net_adm
Executable file
@@ -0,0 +1,312 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Rx3 Net Adm
|
||||||
|
#
|
||||||
|
# Copyright (C) 2025-2026 Arnaud G. GIBERT
|
||||||
|
# mailto:arnaud@rx3.net
|
||||||
|
#
|
||||||
|
# This is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this program; If not, see
|
||||||
|
# <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Includes
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
: "${RX3_LIB_DIR:=/usr/lib/rx3}"
|
||||||
|
. "${RX3_LIB_DIR}/network.bash"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Global Variables
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
declare -g VERSION="1.0.0"
|
||||||
|
declare -g NAME="rx3_net_adm"
|
||||||
|
declare -g HELP="usage: [-h | --help] | [-V | --version] | [-v | --verbose] {start|stop|restart|status|dump|table_set|refresh_address} [args...]"
|
||||||
|
|
||||||
|
declare -g MODE="DEFAULT"
|
||||||
|
declare -g VERBOSE="FALSE"
|
||||||
|
declare -g DRY_RUN="FALSE"
|
||||||
|
declare -g RETVAL=0
|
||||||
|
declare -g prog="rx3-net"
|
||||||
|
|
||||||
|
declare -g DEBUG=""
|
||||||
|
#declare -g DEBUG="echo"
|
||||||
|
#declare -g DEBUG=":"
|
||||||
|
|
||||||
|
declare -g LOG=""
|
||||||
|
#declare -g LOG=":"
|
||||||
|
#declare -g LOG="echo"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Version Print
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rna_version_print()
|
||||||
|
{
|
||||||
|
version_print
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Help Print
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rna_help_print()
|
||||||
|
{
|
||||||
|
rna_version_print
|
||||||
|
help_print
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Arg Parse
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rna_args_parse()
|
||||||
|
{
|
||||||
|
tmp_args=$(getopt -o hvV --long help,verbose,version -n "${NAME}" -- "$@")
|
||||||
|
|
||||||
|
if [ $? != 0 ]; then echo "Terminating..." >&2; exit 1; fi
|
||||||
|
|
||||||
|
eval set -- "${tmp_args}"
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
# Options
|
||||||
|
-h|--help) MODE="EXIT"; rna_help_print; shift;;
|
||||||
|
-V|--version) MODE="EXIT"; rna_version_print; shift;;
|
||||||
|
-v|--verbose) VERBOSE="TRUE"; shift;;
|
||||||
|
|
||||||
|
# End of options
|
||||||
|
--) shift; break;;
|
||||||
|
*) echo "args_parse internal error [$1]!"; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "${MODE}" != "EXIT" ]]
|
||||||
|
then
|
||||||
|
if [[ "${#}" -lt "1" ]]
|
||||||
|
then
|
||||||
|
MODE="EXIT"
|
||||||
|
|
||||||
|
echo_error "Not enough args!"
|
||||||
|
rna_help_print
|
||||||
|
else
|
||||||
|
case "$1" in
|
||||||
|
start|stop|restart|status|dump|table_set|refresh_address)
|
||||||
|
MODE="$(echo "$1" | tr '[:lower:]' '[:upper:]')"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
MODE="EXIT"
|
||||||
|
|
||||||
|
echo_error "Invalid command: [$1]"
|
||||||
|
rna_help_print
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Start
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rna_start()
|
||||||
|
{
|
||||||
|
echo "Starting..."
|
||||||
|
|
||||||
|
if [ -r /var/lock/subsys/rx3-net ]
|
||||||
|
then
|
||||||
|
echo "already started"
|
||||||
|
RETVAL=0
|
||||||
|
else
|
||||||
|
network_start
|
||||||
|
|
||||||
|
RETVAL=$?
|
||||||
|
[ "${RETVAL}" = 0 ] && touch /var/lock/subsys/rx3-net
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Stop
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rna_stop()
|
||||||
|
{
|
||||||
|
echo "Stopping..."
|
||||||
|
|
||||||
|
if [ -r /var/lock/subsys/rx3-net ]
|
||||||
|
then
|
||||||
|
network_stop
|
||||||
|
|
||||||
|
RETVAL=$?
|
||||||
|
else
|
||||||
|
echo "already stopped"
|
||||||
|
RETVAL=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "${RETVAL}" = 0 ] && rm -f /var/lock/subsys/rx3-net
|
||||||
|
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Status
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rna_status()
|
||||||
|
{
|
||||||
|
network_status
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Dump
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rna_dump()
|
||||||
|
{
|
||||||
|
network_tab_dump
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Table Set
|
||||||
|
#--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rna_table_set()
|
||||||
|
{
|
||||||
|
echo "Setting ip:$1 table:$2"
|
||||||
|
|
||||||
|
network_table_set "$1" "$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Address Refresh
|
||||||
|
#--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rna_address_refresh()
|
||||||
|
{
|
||||||
|
dst_id="$1"
|
||||||
|
|
||||||
|
if [[ "${dst_id}" != "" ]]
|
||||||
|
then
|
||||||
|
echo "Refreshing address: [${dst_id}]..."
|
||||||
|
|
||||||
|
network_dst_tab_get "${dst_id}"
|
||||||
|
network_dst_address_refresh "${dst_id}" "${dst_host_name}" "${dst_ip}"
|
||||||
|
else
|
||||||
|
echo "Refreshing all address..."
|
||||||
|
|
||||||
|
network_dst_address_refresh_all
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
# Main
|
||||||
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rna_args_parse "$@"
|
||||||
|
|
||||||
|
if [[ "${MODE}" == "EXIT" ]]
|
||||||
|
then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
network_init
|
||||||
|
|
||||||
|
case "${MODE}" in
|
||||||
|
START)
|
||||||
|
rna_start
|
||||||
|
;;
|
||||||
|
|
||||||
|
STOP)
|
||||||
|
rna_stop
|
||||||
|
;;
|
||||||
|
|
||||||
|
RESTART)
|
||||||
|
rna_stop
|
||||||
|
sleep 1
|
||||||
|
rna_start
|
||||||
|
;;
|
||||||
|
|
||||||
|
STATUS)
|
||||||
|
rna_status
|
||||||
|
;;
|
||||||
|
|
||||||
|
DUMP)
|
||||||
|
rna_dump
|
||||||
|
;;
|
||||||
|
|
||||||
|
TABLE_SET)
|
||||||
|
rna_table_set "$2" "$3"
|
||||||
|
;;
|
||||||
|
|
||||||
|
REFRESH_ADDRESS)
|
||||||
|
rna_address_refresh "$2"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart|status|dump|table_set|refresh_address}"
|
||||||
|
RETVAL=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
network_deinit
|
||||||
|
|
||||||
|
exit ${RETVAL}
|
||||||
@@ -125,6 +125,8 @@ Destination_Status_Board()
|
|||||||
dst_ip="-"
|
dst_ip="-"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ( "${status}" == "" ) || ( "${status}" == "${dst_status}") ]]
|
||||||
|
then
|
||||||
if [[ "${format}" == "html" ]]
|
if [[ "${format}" == "html" ]]
|
||||||
then
|
then
|
||||||
echo -n "<TR><TD class="header">${dst_id}</TD><TD>${dst_name}</TD><TD>${NETWORK_DST_TYPE[${dst_type}]}</TD><TD>${dst_device}</TD>"
|
echo -n "<TR><TD class="header">${dst_id}</TD><TD>${dst_name}</TD><TD>${NETWORK_DST_TYPE[${dst_type}]}</TD><TD>${dst_device}</TD>"
|
||||||
@@ -132,15 +134,15 @@ Destination_Status_Board()
|
|||||||
case "${dst_status}"
|
case "${dst_status}"
|
||||||
in
|
in
|
||||||
"0")
|
"0")
|
||||||
echo -n "<TD><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Down\" ALT=\"Down\"></TD>"
|
echo -n "<TD><A HREF=\"?admin=${admin}&user=${user}&status=${dst_status}\"><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Down\" ALT=\"Down\"></A></TD>"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"1")
|
"1")
|
||||||
echo -n "<TD><IMG SRC=\"/icons/user-online.png\" TITLE=\"Up\" ALT=\"Up\"></TD>"
|
echo -n "<TD><A HREF=\"?admin=${admin}&user=${user}&status=${dst_status}\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Up\" ALT=\"Up\"></A></TD>"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"2")
|
"2")
|
||||||
echo -n "<TD><IMG SRC=\"/icons/user-unready.png\" TITLE=\"Unready\" ALT=\"Unready\"></TD>"
|
echo -n "<TD><A HREF=\"?admin=${admin}&user=${user}&status=${dst_status}\"><IMG SRC=\"/icons/user-unready.png\" TITLE=\"Unready\" ALT=\"Unready\"></A></TD>"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
@@ -148,11 +150,11 @@ Destination_Status_Board()
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
echo "<TD>${dst_ip:--}</TD><TD>${dst_host_name:--}</TD><TD>${dst_config:--}</TD><TD>${dst_table}</TD><TD>${dst_bytes_received:--}</TD><TD>${dst_bytes_sent:--}</TD><TD>${dst_uptime:--}</TD>"
|
echo "<TD>${dst_ip:--}</TD><TD>${dst_host_name:--}</TD><TD>${dst_config:--}</TD><TD>${dst_table}</TD><TD>${dst_bytes_received:--}</TD><TD>${dst_bytes_sent:--}</TD><TD>${dst_uptime:--}</TD>"
|
||||||
else
|
else
|
||||||
echo "${dst_id};${dst_name};${NETWORK_DST_TYPE[${dst_type}]};${dst_device};${dst_status};${dst_ip};${dst_host_name};${dst_config};${dst_table};${dst_bytes_received};${dst_bytes_sent};${dst_uptime}"
|
echo "${dst_id};${dst_name};${NETWORK_DST_TYPE[${dst_type}]};${dst_device};${dst_status};${dst_ip};${dst_host_name};${dst_config};${dst_table};${dst_bytes_received};${dst_bytes_sent};${dst_uptime}"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "${format}" == "html" ]]
|
if [[ "${format}" == "html" ]]
|
||||||
@@ -179,13 +181,13 @@ Source_Routing_Board_Line()
|
|||||||
|
|
||||||
network_src_tab_get ${src_id}
|
network_src_tab_get ${src_id}
|
||||||
|
|
||||||
if [[ ( "${filter}" == "") || ( "${filter}" == "owner") || ( "${filter}" == "${src_owner}") ]]
|
if [[ ( "${user}" == "") || ( "${user}" == "owner") || ( "${user}" == "${src_owner}") ]]
|
||||||
then
|
then
|
||||||
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
||||||
then
|
then
|
||||||
class="default"
|
class="default"
|
||||||
else
|
else
|
||||||
if [[ "${filter}" == "owner" ]]
|
if [[ "${user}" == "owner" ]]
|
||||||
then
|
then
|
||||||
class="skip"
|
class="skip"
|
||||||
else
|
else
|
||||||
@@ -193,11 +195,16 @@ Source_Routing_Board_Line()
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# filter == user not owner of this line
|
# user == user not owner of this line
|
||||||
|
|
||||||
class="skip"
|
class="skip"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ( "${status}" != "") && ( "${status}" != "${src_status}") ]]
|
||||||
|
then
|
||||||
|
class="skip"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ "${class}" != "skip" ]]
|
if [[ "${class}" != "skip" ]]
|
||||||
then
|
then
|
||||||
@@ -212,19 +219,19 @@ Source_Routing_Board_Line()
|
|||||||
case "${src_status}"
|
case "${src_status}"
|
||||||
in
|
in
|
||||||
"0")
|
"0")
|
||||||
echo -n "<TD><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Down\" ALT=\"Down\"></TD>"
|
echo -n "<TD><A HREF=\"?admin=${admin}&user=${user}&status=${src_status}\"><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Down\" ALT=\"Down\"></A></TD>"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"1")
|
"1")
|
||||||
echo -n "<TD><IMG SRC=\"/icons/user-online.png\" TITLE=\"Up\" ALT=\"Up\"></TD>"
|
echo -n "<TD><A HREF=\"?admin=${admin}&user=${user}&status=${src_status}\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Up\" ALT=\"Up\"></A></TD>"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"2")
|
"2")
|
||||||
echo -n "<TD>-</TD>"
|
echo -n "<TD><A HREF=\"?admin=${admin}&user=${user}&status=${src_status}\">-</A></TD>"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo -n "${src_id};${NETWORK_SRC_TYPE[${src_type}]};${src_ip};${src_host_name};${src_device};${status};"
|
echo -n "${src_id};${NETWORK_SRC_TYPE[${src_type}]};${src_ip};${src_host_name};${src_device};${src_status};"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -246,7 +253,7 @@ Source_Routing_Board_Line()
|
|||||||
|
|
||||||
if [[ ( ${admin} == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
if [[ ( ${admin} == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
||||||
then
|
then
|
||||||
echo -n "<A HREF=\"?cmd=route_set&admin=${admin}&filter=${filter}&ip=${src_ip}&vpn=${dst_id}\"><IMG SRC=\"/icons/user-invisible.png\" TITLE=\"Activate\" ALT=\"Activate\"></A>"
|
echo -n "<A HREF=\"?cmd=route_set&admin=${admin}&user=${user}&status=${status}&ip=${src_ip}&vpn=${dst_id}\"><IMG SRC=\"/icons/user-invisible.png\" TITLE=\"Activate\" ALT=\"Activate\"></A>"
|
||||||
else
|
else
|
||||||
echo -n " "
|
echo -n " "
|
||||||
fi
|
fi
|
||||||
@@ -274,7 +281,7 @@ Source_Routing_Board_Line()
|
|||||||
echo -n "<TD>${src_port_range}</TD><TD>-</TD><TD>-</TD>"
|
echo -n "<TD>${src_port_range}</TD><TD>-</TD><TD>-</TD>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "<TD><A HREF=\"?admin=${admin}&filter=${src_owner}\">${src_owner}</A></TD><TD>${src_bytes_received:--}</TD><TD>${src_bytes_sent:--}</TD><TD>${src_uptime:--}</TD><TD>${src_last_seen:--}</TD></TR>"
|
echo "<TD><A HREF=\"?admin=${admin}&user=${src_owner}&status=${status}\">${src_owner}</A></TD><TD>${src_bytes_received:--}</TD><TD>${src_bytes_sent:--}</TD><TD>${src_uptime:--}</TD><TD>${src_last_seen:--}</TD></TR>"
|
||||||
else
|
else
|
||||||
echo "${src_port_range};${src_port_start};${src_port_end};${src_owner};${src_bytes_received};${src_bytes_sent};${src_uptime};${src_last_seen}"
|
echo "${src_port_range};${src_port_start};${src_port_end};${src_owner};${src_bytes_received};${src_bytes_sent};${src_uptime};${src_last_seen}"
|
||||||
fi
|
fi
|
||||||
@@ -378,13 +385,13 @@ VPN_OpenVPN_Board()
|
|||||||
|
|
||||||
if [[ "${src_type}" == 2 ]]
|
if [[ "${src_type}" == 2 ]]
|
||||||
then
|
then
|
||||||
if [[ ( "${filter}" == "") || ( "${filter}" == "owner") || ( "${filter}" == "${src_owner}") ]]
|
if [[ ( "${user}" == "") || ( "${user}" == "owner") || ( "${user}" == "${src_owner}") ]]
|
||||||
then
|
then
|
||||||
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
||||||
then
|
then
|
||||||
class="default"
|
class="default"
|
||||||
else
|
else
|
||||||
if [[ "${filter}" == "owner" ]]
|
if [[ "${user}" == "owner" ]]
|
||||||
then
|
then
|
||||||
class="skip"
|
class="skip"
|
||||||
else
|
else
|
||||||
@@ -392,30 +399,36 @@ VPN_OpenVPN_Board()
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# filter == user not owner of this line
|
# user == user not owner of this line
|
||||||
|
|
||||||
class="skip"
|
class="skip"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ( "${status}" != "") && ( "${status}" != "${src_status}") ]]
|
||||||
|
then
|
||||||
|
class="skip"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ "${class}" != "skip" ]]
|
if [[ "${class}" != "skip" ]]
|
||||||
then
|
then
|
||||||
if [[ "${format}" == "html" ]]
|
if [[ "${format}" == "html" ]]
|
||||||
then
|
then
|
||||||
echo -n " <TR class=\"${class}\"><TD class=\"header\">${idx}</TD><TD>${src_ip}</TD><TD>${src_host_name}</TD>"
|
echo -n " <TR class=\"${class}\"><TD class=\"header\">${idx}</TD><TD>${src_ip}</TD><TD>${src_host_name}</TD>"
|
||||||
echo -n "<TD><A HREF=\"?cmd=config_download&admin=${admin}&filter=${filter}&ip=${src_ip}&defroute=true&type=ext\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Default Route External Certificates\" ALT=\"Configuration External Certificates\"></A></TD>"
|
echo -n "<TD><A HREF=\"?cmd=config_download&admin=${admin}&user=${user}&status=${status}&ip=${src_ip}&defroute=true&type=ext\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Default Route External Certificates\" ALT=\"Configuration External Certificates\"></A></TD>"
|
||||||
|
|
||||||
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
||||||
then
|
then
|
||||||
echo -n "<TD><A HREF=\"?cmd=config_download&admin=${admin}&filter=${filter}&ip=${src_ip}&defroute=true&type=inline\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Default Route Inline Certificates\" ALT=\"Configuration Inline Certificates\"></A></TD>"
|
echo -n "<TD><A HREF=\"?cmd=config_download&admin=${admin}&user=${user}&status=${status}&ip=${src_ip}&defroute=true&type=inline\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Default Route Inline Certificates\" ALT=\"Configuration Inline Certificates\"></A></TD>"
|
||||||
else
|
else
|
||||||
echo -n "<TD><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Inline Certificates\" ALT=\"Configuration Inline Certificates\"></TD>"
|
echo -n "<TD><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Inline Certificates\" ALT=\"Configuration Inline Certificates\"></TD>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "<TD><A HREF=\"?cmd=config_download&admin=${admin}&filter=${filter}&ip=${src_ip}&defroute=false&type=ext\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration NoDefault Route External Certificates\" ALT=\"Configuration External Certificates\"></A></TD>"
|
echo -n "<TD><A HREF=\"?cmd=config_download&admin=${admin}&user=${user}&status=${status}&ip=${src_ip}&defroute=false&type=ext\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration NoDefault Route External Certificates\" ALT=\"Configuration External Certificates\"></A></TD>"
|
||||||
|
|
||||||
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
||||||
then
|
then
|
||||||
echo -n "<TD><A HREF=\"?cmd=config_download&admin=${admin}&filter=${filter}&ip=${src_ip}&defroute=false&type=inline\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration NoDefault Route Inline Certificates\" ALT=\"Configuration Inline Certificates\"></A></TD>"
|
echo -n "<TD><A HREF=\"?cmd=config_download&admin=${admin}&user=${user}&status=${status}&ip=${src_ip}&defroute=false&type=inline\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration NoDefault Route Inline Certificates\" ALT=\"Configuration Inline Certificates\"></A></TD>"
|
||||||
else
|
else
|
||||||
echo -n "<TD><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Inline Certificates\" ALT=\"Configuration Inline Certificates\"></TD>"
|
echo -n "<TD><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Inline Certificates\" ALT=\"Configuration Inline Certificates\"></TD>"
|
||||||
fi
|
fi
|
||||||
@@ -425,17 +438,17 @@ VPN_OpenVPN_Board()
|
|||||||
|
|
||||||
if [[ "${format}" == "html" ]]
|
if [[ "${format}" == "html" ]]
|
||||||
then
|
then
|
||||||
echo -n "<TD><A HREF=\"?cmd=cert_download&admin=${admin}&filter=${filter}&ip=${src_ip}&type=ca\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"CA Certificate\" ALT=\"CA Certificate\"></A></TD>"
|
echo -n "<TD><A HREF=\"?cmd=cert_download&admin=${admin}&user=${user}&status=${status}&ip=${src_ip}&type=ca\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"CA Certificate\" ALT=\"CA Certificate\"></A></TD>"
|
||||||
|
|
||||||
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
|
||||||
then
|
then
|
||||||
echo -n "<TD><A HREF=\"?cmd=cert_download&admin=${admin}&filter=${filter}&ip=${src_ip}&type=tc\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"TC Certificate\" ALT=\"TC Certificate\"></A></TD>"
|
echo -n "<TD><A HREF=\"?cmd=cert_download&admin=${admin}&user=${user}&status=${status}&ip=${src_ip}&type=tc\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"TC Certificate\" ALT=\"TC Certificate\"></A></TD>"
|
||||||
|
|
||||||
if [[ -f /etc/openvpn/tls/certs/${src_host_name}.crt ]]
|
if [[ -f /etc/openvpn/tls/certs/${src_host_name}.crt ]]
|
||||||
then
|
then
|
||||||
echo -n "<TD><A HREF=\"?cmd=cert_download&admin=${admin}&filter=${filter}&ip=${src_ip}&type=key\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Private Key\" ALT=\"Private Key\"></A></TD>"
|
echo -n "<TD><A HREF=\"?cmd=cert_download&admin=${admin}&user=${user}&status=${status}&ip=${src_ip}&type=key\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Private Key\" ALT=\"Private Key\"></A></TD>"
|
||||||
echo -n "<TD><A HREF=\"?cmd=cert_download&admin=${admin}&filter=${filter}&ip=${src_ip}&type=csr\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Certificate Signing Request\" ALT=\"Certificat Signing Request\"></A></TD>"
|
echo -n "<TD><A HREF=\"?cmd=cert_download&admin=${admin}&user=${user}&status=${status}&ip=${src_ip}&type=csr\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Certificate Signing Request\" ALT=\"Certificat Signing Request\"></A></TD>"
|
||||||
echo "<TD><A HREF=\"?cmd=cert_download&admin=${admin}&filter=${filter}&ip=${src_ip}&type=crt\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Public Certificate\" ALT=\"Public Certificate\"></A></TD></TR>"
|
echo "<TD><A HREF=\"?cmd=cert_download&admin=${admin}&user=${user}&status=${status}&ip=${src_ip}&type=crt\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Public Certificate\" ALT=\"Public Certificate\"></A></TD></TR>"
|
||||||
else
|
else
|
||||||
echo -n "<TD><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Private Key\" ALT=\"Private Key\"></TD>"
|
echo -n "<TD><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Private Key\" ALT=\"Private Key\"></TD>"
|
||||||
echo -n "<TD><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Certificat Signing Request\" ALT=\"Certificat Signing Request\"></TD>"
|
echo -n "<TD><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Certificat Signing Request\" ALT=\"Certificat Signing Request\"></TD>"
|
||||||
@@ -497,22 +510,46 @@ Main_Board_Print()
|
|||||||
admin_mode=""
|
admin_mode=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${filter}"
|
case "${user}"
|
||||||
in
|
in
|
||||||
"owner")
|
"")
|
||||||
filter_mode="My VPN"
|
user_mode="All"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"")
|
"owner")
|
||||||
filter_mode="All VPN"
|
user_mode="My"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
filter_mode="${filter} VPN"
|
user_mode="${user}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo " <H1>VPN Admin Board: ${filter_mode}${admin_mode}</H1>"
|
case "${status}"
|
||||||
|
in
|
||||||
|
"")
|
||||||
|
status_mode="All"
|
||||||
|
;;
|
||||||
|
|
||||||
|
"0")
|
||||||
|
status_mode="Down"
|
||||||
|
;;
|
||||||
|
|
||||||
|
"1")
|
||||||
|
status_mode="UP"
|
||||||
|
;;
|
||||||
|
|
||||||
|
"2")
|
||||||
|
status_mode="Not Conected"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
status_mode="Unkwown"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
echo " <H1>VPN Admin Board: ${user_mode} VPN - ${status_mode} Status${admin_mode}</H1>"
|
||||||
|
|
||||||
|
|
||||||
echo " <P>"
|
echo " <P>"
|
||||||
@@ -539,17 +576,23 @@ Main_Board_Print()
|
|||||||
then
|
then
|
||||||
if [[ "${admin}" == "true" ]]
|
if [[ "${admin}" == "true" ]]
|
||||||
then
|
then
|
||||||
echo -n "<A HREF=\"?filter=${filter}\">Non Admin Mode</A>"
|
echo -n "<A HREF=\"?user=${user}&status=${status}\">Non Admin Mode</A>"
|
||||||
else
|
else
|
||||||
echo -n "<A HREF=\"?admin=true&filter=${filter}\">Admin Mode</A>"
|
echo -n "<A HREF=\"?admin=true&user=${user}&status=${status}\">Admin Mode</A>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n " "
|
echo -n " "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${filter}" != "" ]]
|
if [[ "${user}" != "" ]]
|
||||||
then
|
then
|
||||||
echo -n "<A HREF=\"?admin=${admin}\">All VPN</A>"
|
echo -n "<A HREF=\"?admin=${admin}&status=${status}\">All VPN</A>"
|
||||||
|
echo -n " "
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${status}" != "" ]]
|
||||||
|
then
|
||||||
|
echo -n "<A HREF=\"?admin=${admin}&user=${user}\">All Status</A>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@@ -598,7 +641,8 @@ Main_Board_Print()
|
|||||||
|
|
||||||
cmd=""
|
cmd=""
|
||||||
format=""
|
format=""
|
||||||
filter=""
|
user=""
|
||||||
|
status=""
|
||||||
ip=""
|
ip=""
|
||||||
vpn=""
|
vpn=""
|
||||||
type=""
|
type=""
|
||||||
@@ -638,6 +682,14 @@ then
|
|||||||
filter=${arg}
|
filter=${arg}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
"user")
|
||||||
|
user=${arg}
|
||||||
|
;;
|
||||||
|
|
||||||
|
"status")
|
||||||
|
status=${arg}
|
||||||
|
;;
|
||||||
|
|
||||||
"ip")
|
"ip")
|
||||||
ip=${arg}
|
ip=${arg}
|
||||||
;;
|
;;
|
||||||
@@ -685,7 +737,7 @@ if [[ ( ${admin} == "true") && ( " ${ADMIN_USER_LIST} " != *" ${REMOTE_USER} "*)
|
|||||||
then
|
then
|
||||||
cmd_status="${cmd}: Admin NOT_AUTHORIZED"
|
cmd_status="${cmd}: Admin NOT_AUTHORIZED"
|
||||||
|
|
||||||
redirect="?filter=${filter}"
|
redirect="?user=${user}&up=${up}"
|
||||||
|
|
||||||
Header_Print
|
Header_Print
|
||||||
Footer_Print
|
Footer_Print
|
||||||
|
|||||||
Reference in New Issue
Block a user