mirror of
https://github.com/garywill/linux-router.git
synced 2025-12-30 18:58:28 +01:00
Compare commits
1 Commits
dev-12
...
workaround
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cebea4a988 |
92
lnxrouter
92
lnxrouter
@@ -1119,10 +1119,6 @@ backup_interface_status() {
|
|||||||
# nm managing status is saved when nm_set_unmanaged()
|
# nm managing status is saved when nm_set_unmanaged()
|
||||||
}
|
}
|
||||||
restore_interface_status() {
|
restore_interface_status() {
|
||||||
# virtual wifi interface will be destroyed, so no need to restore status
|
|
||||||
# don't use [[ $VWIFI_IFACE ]] to judge, if creating virtual wifi failed, VWIFI_IFACE is empty
|
|
||||||
[[ "$WIFI_IFACE" && "$NO_VIRT" -eq 0 ]] && return
|
|
||||||
|
|
||||||
restore_ipv6_bits
|
restore_ipv6_bits
|
||||||
|
|
||||||
if [[ -n "$OLD_MACADDR" && "$(get_interface_mac $SUBNET_IFACE)" != "$OLD_MACADDR" ]] ; then
|
if [[ -n "$OLD_MACADDR" && "$(get_interface_mac $SUBNET_IFACE)" != "$OLD_MACADDR" ]] ; then
|
||||||
@@ -1132,7 +1128,6 @@ restore_interface_status() {
|
|||||||
|
|
||||||
nm_restore_manage
|
nm_restore_manage
|
||||||
|
|
||||||
[[ $SUBNET_IFACE_ORIGINAL_UP_STATUS -eq 1 ]] && ip link set up dev ${SUBNET_IFACE} && echo "Restore ${SUBNET_IFACE} to link up"
|
|
||||||
}
|
}
|
||||||
#---------------------------------------
|
#---------------------------------------
|
||||||
|
|
||||||
@@ -1155,12 +1150,7 @@ kill_processes() { # for this instance
|
|||||||
_cleanup() {
|
_cleanup() {
|
||||||
local x
|
local x
|
||||||
|
|
||||||
ip addr flush ${SUBNET_IFACE}
|
|
||||||
|
|
||||||
rm -rf $CONFDIR
|
rm -rf $CONFDIR
|
||||||
|
|
||||||
ip link set down dev ${SUBNET_IFACE}
|
|
||||||
|
|
||||||
if [[ $VWIFI_IFACE ]]; then # the subnet interface (virtual wifi interface) will be removed
|
if [[ $VWIFI_IFACE ]]; then # the subnet interface (virtual wifi interface) will be removed
|
||||||
iw dev ${VWIFI_IFACE} del
|
iw dev ${VWIFI_IFACE} del
|
||||||
dealloc_vface_name $VWIFI_IFACE
|
dealloc_vface_name $VWIFI_IFACE
|
||||||
@@ -1596,15 +1586,13 @@ decide_target_interface() {
|
|||||||
|
|
||||||
decide_ip_addresses() {
|
decide_ip_addresses() {
|
||||||
if [[ ! -n $GATEWAY ]]; then
|
if [[ ! -n $GATEWAY ]]; then
|
||||||
GATEWAY="$(generate_random_ip4)"
|
echo
|
||||||
echo "Use random LAN IPv4 address $GATEWAY"
|
|
||||||
elif [[ ! "$GATEWAY" =~ "." ]]; then
|
elif [[ ! "$GATEWAY" =~ "." ]]; then
|
||||||
GATEWAY="192.168.${GATEWAY}.1"
|
GATEWAY="192.168.${GATEWAY}.1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $IPV6 -eq 1 && ! -n $PREFIX6 ]]; then
|
if [[ $IPV6 -eq 1 && ! -n $PREFIX6 ]]; then
|
||||||
PREFIX6="$(generate_random_lan_ip6_prefix)"
|
echo
|
||||||
echo "Use random LAN IPv6 address ${PREFIX6}${IID6}"
|
|
||||||
elif [[ ! "$PREFIX6" =~ ":" ]]; then
|
elif [[ ! "$PREFIX6" =~ ":" ]]; then
|
||||||
PREFIX6="fd00:0:0:${PREFIX6}::"
|
PREFIX6="fd00:0:0:${PREFIX6}::"
|
||||||
fi
|
fi
|
||||||
@@ -1614,10 +1602,6 @@ decide_ip_addresses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prepare_wifi_interface() {
|
prepare_wifi_interface() {
|
||||||
|
|
||||||
sleep 1
|
|
||||||
echo; echo; echo;
|
|
||||||
echo "Trying to set power_save off ..."
|
|
||||||
if [[ $USE_IWCONFIG -eq 0 ]]; then
|
if [[ $USE_IWCONFIG -eq 0 ]]; then
|
||||||
iw dev ${WIFI_IFACE} set power_save off
|
iw dev ${WIFI_IFACE} set power_save off
|
||||||
fi
|
fi
|
||||||
@@ -1640,9 +1624,7 @@ prepare_wifi_interface() {
|
|||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 6
|
|
||||||
echo; echo; echo;
|
|
||||||
echo "Creating a virtual WiFi interface... "
|
echo "Creating a virtual WiFi interface... "
|
||||||
VWIFI_IFACE=$(alloc_new_vface_name)
|
VWIFI_IFACE=$(alloc_new_vface_name)
|
||||||
if iw dev ${WIFI_IFACE} interface add ${VWIFI_IFACE} type __ap; then
|
if iw dev ${WIFI_IFACE} interface add ${VWIFI_IFACE} type __ap; then
|
||||||
@@ -1957,7 +1939,9 @@ phead
|
|||||||
phead2
|
phead2
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo " ============ In dev branch for issue #12 ==========="
|
echo
|
||||||
|
echo "This is workaround for #31. Must use with '-g' and for wired interface !"
|
||||||
|
echo
|
||||||
|
|
||||||
echo "PID: $$"
|
echo "PID: $$"
|
||||||
|
|
||||||
@@ -1982,33 +1966,10 @@ init_trap
|
|||||||
|
|
||||||
init_conf_dirs # CONFDIR , COMMON_CONFDIR . make dir
|
init_conf_dirs # CONFDIR , COMMON_CONFDIR . make dir
|
||||||
|
|
||||||
echo -e "\nDistro:"
|
|
||||||
cat /etc/os-release
|
|
||||||
|
|
||||||
echo -e "\nKernel:"
|
|
||||||
uname -a
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "setting NM log level: nmcli general logging level TRACE domains ALL"
|
|
||||||
nmcli general logging level TRACE domains ALL
|
|
||||||
|
|
||||||
echo "Logging journalctl -f"
|
|
||||||
journalctl -f &
|
|
||||||
echo $! > $CONFDIR/journalctl.pid
|
|
||||||
|
|
||||||
echo "Logging dmesg -W"
|
|
||||||
dmesg -W &
|
|
||||||
echo $! > $CONFDIR/dmesg.pid
|
|
||||||
|
|
||||||
echo "Logging wpa_supplicant.log"
|
|
||||||
tail -f /var/log/wpa_supplicant.log &
|
|
||||||
echo $! > $CONFDIR/wpa_supplicant_log.pid
|
|
||||||
|
|
||||||
[[ $WIFI_IFACE ]] && prepare_wifi_interface # this will create virtual ap interface (if needed) and set VWIFI_IFACE and AP_IFACE (if success)
|
[[ $WIFI_IFACE ]] && prepare_wifi_interface # this will create virtual ap interface (if needed) and set VWIFI_IFACE and AP_IFACE (if success)
|
||||||
|
|
||||||
SUBNET_IFACE="$(decide_subnet_interface)" # SUBNET_IFACE can be TARGET_IFACE (wired) or AP_IFACE (ap) .this is after prepare_wifi_interface()
|
SUBNET_IFACE="$(decide_subnet_interface)" # SUBNET_IFACE can be TARGET_IFACE (wired) or AP_IFACE (ap) .this is after prepare_wifi_interface()
|
||||||
echo "$SUBNET_IFACE" > "$CONFDIR/subn_iface"
|
echo "$SUBNET_IFACE" > "$CONFDIR/subn_iface"
|
||||||
ip addr show dev ${SUBNET_IFACE}
|
|
||||||
|
|
||||||
# if virtual wifi interface, will be destroyed, so only need to save status when not
|
# if virtual wifi interface, will be destroyed, so only need to save status when not
|
||||||
[[ -z $VWIFI_IFACE ]] && backup_interface_status
|
[[ -z $VWIFI_IFACE ]] && backup_interface_status
|
||||||
@@ -2028,10 +1989,6 @@ fi
|
|||||||
#===================================================
|
#===================================================
|
||||||
#===================================================
|
#===================================================
|
||||||
|
|
||||||
sleep 1
|
|
||||||
echo; echo; echo;
|
|
||||||
ip addr show dev ${SUBNET_IFACE}
|
|
||||||
echo "Trying to set NM unmanage ..."
|
|
||||||
# set interface unmanaged by networkManager
|
# set interface unmanaged by networkManager
|
||||||
if [[ $NM_RUNNING -eq 1 ]] && nm_knows $TARGET_IFACE; then # if nm knows target iface, should know subnet iface too. but need to wait until nm finds subnet iface (waiting code is in nm_set_unmanaged()
|
if [[ $NM_RUNNING -eq 1 ]] && nm_knows $TARGET_IFACE; then # if nm knows target iface, should know subnet iface too. but need to wait until nm finds subnet iface (waiting code is in nm_set_unmanaged()
|
||||||
nm_set_unmanaged ${SUBNET_IFACE} # will write NM_UNM_LIST
|
nm_set_unmanaged ${SUBNET_IFACE} # will write NM_UNM_LIST
|
||||||
@@ -2041,51 +1998,14 @@ fi
|
|||||||
#===========================
|
#===========================
|
||||||
|
|
||||||
|
|
||||||
sleep 1
|
|
||||||
echo; echo; echo;
|
|
||||||
ip addr show dev ${SUBNET_IFACE}
|
|
||||||
echo "Trying to set ${SUBNET_IFACE} down ..."
|
|
||||||
# initialize subnet interface
|
|
||||||
# take subnet interface down first
|
|
||||||
ip link set down dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} down"
|
|
||||||
|
|
||||||
sleep 1
|
|
||||||
echo; echo; echo;
|
|
||||||
ip addr show dev ${SUBNET_IFACE}
|
|
||||||
echo "Trying to flush ${SUBNET_IFACE} ..."
|
|
||||||
# flush old IPs of subnet interface
|
|
||||||
ip addr flush ${SUBNET_IFACE} || die "Failed flush ${SUBNET_IFACE} IP"
|
|
||||||
|
|
||||||
sleep 1
|
|
||||||
echo; echo; echo;
|
|
||||||
ip addr show dev ${SUBNET_IFACE}
|
|
||||||
dealwith_mac # setting MAC should be after setting NM unmanaged
|
dealwith_mac # setting MAC should be after setting NM unmanaged
|
||||||
|
|
||||||
sleep 1
|
|
||||||
echo; echo; echo;
|
|
||||||
ip addr show dev ${SUBNET_IFACE}
|
|
||||||
echo "Trying to check and do rfkill unblock ..."
|
|
||||||
[[ $WIFI_IFACE ]] && check_rfkill_unblock_wifi
|
[[ $WIFI_IFACE ]] && check_rfkill_unblock_wifi
|
||||||
|
|
||||||
sleep 1
|
|
||||||
echo; echo; echo;
|
|
||||||
ip addr show dev ${SUBNET_IFACE}
|
|
||||||
echo "Trying to bring interface ${SUBNET_IFACE} up ..."
|
|
||||||
# bring subnet interface up
|
|
||||||
ip link set up dev ${SUBNET_IFACE} || die "Failed bringing ${SUBNET_IFACE} up"
|
|
||||||
|
|
||||||
sleep 1
|
|
||||||
echo; echo; echo;
|
|
||||||
echo "Finished test. Exiting ..."
|
|
||||||
clean_exit
|
|
||||||
exit
|
|
||||||
|
|
||||||
|
|
||||||
# hostapd , haveged
|
# hostapd , haveged
|
||||||
[[ $WIFI_IFACE ]] && run_wifi_ap_processes
|
[[ $WIFI_IFACE ]] && run_wifi_ap_processes
|
||||||
|
|
||||||
# add ipv4 address to subnet interface
|
|
||||||
ip -4 addr add ${GATEWAY}/24 broadcast ${GATEWAY%.*}.255 dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} IPv4 address"
|
|
||||||
|
|
||||||
set_ipv6_bits
|
set_ipv6_bits
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user