- Start migration of dns, network & vpn lib,
- Start migration of rx3_net_adm.
This commit is contained in:
217
usr/sbin/rx3_net_adm
Executable file
217
usr/sbin/rx3_net_adm
Executable file
@@ -0,0 +1,217 @@
|
||||
#!/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 Variable
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
RETVAL=0
|
||||
prog="rx3-net"
|
||||
|
||||
#DEBUG=""
|
||||
#DEBUG="echo"
|
||||
#DEBUG=":"
|
||||
|
||||
#LOG=":"
|
||||
#LOG="echo"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
Reference in New Issue
Block a user