Compare commits

..

3 Commits

Author SHA1 Message Date
garywill 200b6d4451 show distro and kernel 2022-01-05 20:07:15 +08:00
garywill 2ea1dfd5b7 Merge branch 'master' 2022-01-05 20:02:39 +08:00
garywill f6995bc30c get device pci info 2022-01-05 20:01:38 +08:00
2 changed files with 48 additions and 17 deletions

View File

@ -4,7 +4,7 @@ Set Linux as router in one command. Able to provide Internet, or create WiFi hot
It wraps `iptables`, `dnsmasq` etc. stuff. Use in one command, restore in one command or by `control-c` (or even by closing terminal window).
[📰 News & Developer Notes](https://github.com/garywill/linux-router/issues/28) | [More tools and projects 🛠️](https://garywill.github.io) | [🍻 Buy me a coffee ❤️](https://github.com/garywill/receiving/blob/master/receiving_methods.md)
[Linux-Router News & Developer Notes 📰](https://github.com/garywill/linux-router/issues/28) | [More tools and projects 🛠️](https://garywill.github.io) | [🍻 Buy me a coffee ❤️](https://github.com/garywill/receiving/blob/master/receiving_methods.md)
## Features
@ -413,16 +413,15 @@ On exit of a linux-router instance, script **will do cleanup**, i.e. undo most c
## TODO
<details>
Sooner is better:
- Detect firewalld and make sure it won't interfere our interface
Future:
- WPA3
- Global IPv6
- Explictly ban forwarding if not needed
- Bring bridging method back
</details>
## License
linux-router is LGPL licensed
@ -486,7 +485,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit [**my homepage** 🏡](https://garywill.github.io) to see **more tools and projects** 🛠️.
> [❤️ Buy me a coffee](https://github.com/garywill/receiving/blob/master/receiving_methods.md) , this project took me lots of time! ([❤️ 扫码打赏一个!](https://github.com/garywill/receiving/blob/master/receiving_methods.md))
> [❤️ Buy me a coffee](https://github.com/garywill/receiving/blob/master/receiving_methods.md) , this project took me lots of time! ([❤️ 扫码领红包并打赏一个!](https://github.com/garywill/receiving/blob/master/receiving_methods.md))
>
> 🥂 ( ^\_^) o自自o (^_^ ) 🍻

View File

@ -626,6 +626,32 @@ get_interface_mac() {
cat "/sys/class/net/${1}/address"
}
get_interface_pci_info() { # pci id / model / virtual
is_interface "$1" || return
local device_path
local pci_id
local pci_full
device_path="$(readlink -f /sys/class/net/$1)"
if [[ "$device_path" == "/sys/devices/pci"* ]]; then
pci_id="$(echo $device_path | sed 's/\//\n/g' | tail -n 3 |sed -n 1p)"
if which lspci >/dev/null 2>&1 ; then
pci_full="$( lspci -D -nn | grep -E "^$pci_id " )"
echo " PCI: $pci_full"
else
echo " PCI: $pci_id"
fi
elif [[ "$device_path" == *"/virtual/"* ]]; then
echo " virtual interface"
fi
# TODO usb
# TODO current driver
}
alloc_new_vface_name() { # only for wifi
local i=0
local v_iface_name=
@ -1589,7 +1615,7 @@ decide_ip_addresses() {
prepare_wifi_interface() {
sleep 6
sleep 1
echo; echo; echo;
echo "Trying to set power_save off ..."
if [[ $USE_IWCONFIG -eq 0 ]]; then
@ -1936,8 +1962,7 @@ echo " ============ In dev branch for issue #12 ==========="
echo "PID: $$"
TARGET_IFACE="$(decide_target_interface)" || exit 1 # judge wired (-i CONN_IFACE) or wireless hotspot (--ap $WIFI_IFACE)
echo "Target interface is ${TARGET_IFACE} ($(get_interface_mac $TARGET_IFACE))"
# TODO: show interface type, device model and pci/usb id (hwdata pci.ids), current driver
echo "Target interface is ${TARGET_IFACE} ($(get_interface_mac $TARGET_IFACE)) $(get_interface_pci_info $TARGET_IFACE)"
if [[ "$MAC_USE_RANDOM" -eq 1 ]] ; then
NEW_MACADDR="$(generate_random_mac)"
@ -1957,6 +1982,13 @@ init_trap
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
@ -1996,7 +2028,7 @@ fi
#===================================================
#===================================================
sleep 6
sleep 1
echo; echo; echo;
ip addr show dev ${SUBNET_IFACE}
echo "Trying to set NM unmanage ..."
@ -2009,7 +2041,7 @@ fi
#===========================
sleep 6
sleep 1
echo; echo; echo;
ip addr show dev ${SUBNET_IFACE}
echo "Trying to set ${SUBNET_IFACE} down ..."
@ -2017,32 +2049,32 @@ echo "Trying to set ${SUBNET_IFACE} down ..."
# take subnet interface down first
ip link set down dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} down"
sleep 6
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 6
sleep 1
echo; echo; echo;
ip addr show dev ${SUBNET_IFACE}
dealwith_mac # setting MAC should be after setting NM unmanaged
sleep 6
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
sleep 6
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 6
sleep 1
echo; echo; echo;
echo "Finished test. Exiting ..."
clean_exit
@ -2121,7 +2153,7 @@ fi
[[ $NO_DNSMASQ -eq 0 ]] && ( allow_dhcp ; start_dnsmasq )
echo
echo "== Setting up completed, now linux-router is working =="
echo "== Setting up completed, now linux-router should be working =="
#============================================================
#============================================================