mirror of
				https://github.com/Ysurac/openmptcprouter-feeds.git
				synced 2025-03-09 15:40:03 +00:00 
			
		
		
		
	Add mac address to OMR Rename ident
This commit is contained in:
		
							parent
							
								
									db48ca8794
								
							
						
					
					
						commit
						bea2f5f629
					
				
					 2 changed files with 20 additions and 7 deletions
				
			
		|  | @ -20,17 +20,22 @@ _set_intf_name() { | |||
| 	fi | ||||
| 	[ -n "$modalias" ] && { | ||||
| 		if [ -f /sys/class/net/${INTERFACE}/device/uevent ]; then | ||||
| 			mac="" | ||||
| 			if [ -f /sys/class/net/${INTERFACE}/address ]; then | ||||
| 				mac="$(cat /sys/class/net/${INTERFACE}/address | tr -d '\n')" | ||||
| 			fi | ||||
| 			chk_modalias=$MODALIAS | ||||
| 			[ -z "$chk_modalias" ] && chk_modalias="$(cat /sys/class/net/${INTERFACE}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')" | ||||
| 			if [ -n "$chk_modalias" ]; then | ||||
| 				chk_modalias="${chk_modalias}-${mac}" | ||||
| 				logger -t "OMR-Rename" "modalias: $modalias - chk_modalias: $chk_modalias - ifname: $ifname - INTERFACE: $INTERFACE" | ||||
| 				if [ "$modalias" = "$chk_modalias" ] && [ "$INTERFACE" != "$ifname" ]; then | ||||
| 					logger -t "OMR-Rename" "Rename ${INTERFACE} to ${ifname}" | ||||
| 					existif=0 | ||||
| 					existif="0" | ||||
| 					ip link set ${INTERFACE} down 2>&1 >/dev/null | ||||
| 					[ "$(ip link show ${ifname} 2>/dev/null)" != "" ] && { | ||||
| 						ip link set ${ifname} name ${ifname}tmp 2>&1 >/dev/null | ||||
| 						existif=1 | ||||
| 						existif="1" | ||||
| 					} | ||||
| 					ip link set ${INTERFACE} name ${ifname} 2>&1 >/dev/null | ||||
| 					ip link set ${ifname} up 2>&1 >/dev/null | ||||
|  | @ -48,10 +53,10 @@ _set_intf_name() { | |||
| 		logger -t "OMR-Rename" "device: $device - devpath: $DEVPATH - ifname: $ifname - INTERFACE: $INTERFACE" | ||||
| 		logger -t "OMR-Rename" "Rename ${INTERFACE} to ${ifname}" | ||||
| 		ip link set ${INTERFACE} down 2>&1 >/dev/null | ||||
| 		existif=0 | ||||
| 		existif="0" | ||||
| 		[ "$(ip link show ${ifname} 2>/dev/null)" != "" ] && { | ||||
| 			ip link set ${ifname} name ${ifname}tmp 2>&1 >/dev/null | ||||
| 			existif=1 | ||||
| 			existif="1" | ||||
| 		} | ||||
| 		ip link set ${INTERFACE} name ${ifname} 2>&1 >/dev/null | ||||
| 		ip link set ${ifname} up 2>&1 >/dev/null | ||||
|  | @ -62,5 +67,5 @@ _set_intf_name() { | |||
| if [ "$(uci -q get openmptcprouter.settings.disableintfrename)" != "1" ]; then | ||||
| 	config_load network | ||||
| 	config_foreach _set_intf_name interface | ||||
| 	config_foreach _set_intf_name interface | ||||
| #	config_foreach _set_intf_name interface | ||||
| fi | ||||
|  | @ -27,7 +27,11 @@ omr_intf_set() { | |||
| 	if [ "$type" != "macvlan" ] && [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then | ||||
| 		devicepath=$(readlink -f /sys/class/net/${ifname}) | ||||
| 		if [ -n "$devicepath" ] && [ "$(echo ${devicepath} | grep virtual)" = "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" != "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PCI_SLOT_NAME)" = "" ]; then | ||||
| 			uci -q set network.$1.modalias="$(cat /sys/class/net/${ifname}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')" | ||||
| 			mac="" | ||||
| 			if [ -f /sys/class/net/${ifname}/address ]; then | ||||
| 				mac="$(cat /sys/class/net/${ifname}/address | tr -d '\n')" | ||||
| 			fi | ||||
| 			uci -q set network.$1.modalias="$(cat /sys/class/net/${ifname}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')-$mac" | ||||
| 			uci -q set network.$1.product="$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT | cut -d '=' -f2 | tr -d '\n')" | ||||
| 		elif [ -n "$devicepath" ] && ([ "$(echo ${devicepath} | grep virtual)" != "" ] || [ "$(echo ${devicepath} | grep virtual)" = "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" = "" ] || [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PCI_SLOT_NAME)" != "" ] || [ "$(cat /sys/class/net/${ifname}tmp/device/uevent)" != "" ]); then | ||||
| 			uci -q delete network.$1.device | ||||
|  | @ -35,7 +39,11 @@ omr_intf_set() { | |||
| 			uci -q delete network.$1.product | ||||
| 		fi | ||||
| 	elif [ "$type" != "macvlan" ] &&  [ -n "$device" ] && [ -f /sys/bus/usb-serial/devices/${devicename}/device/uevent ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" != "" ]; then | ||||
| 		uci -q set network.$1.modalias="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')" | ||||
| 		mac="" | ||||
| 		if [ -f /sys/class/net/${ifname}/address ]; then | ||||
| 			mac="$(cat /sys/class/net/${ifname}/address | tr -d '\n')" | ||||
| 		fi | ||||
| 		uci -q set network.$1.modalias="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep MODALIAS | cut -d '=' -f2 | tr -d '\n')-$mac" | ||||
| 		uci -q set network.$1.product="$(cat /sys/bus/usb-serial/devices/${devicename}/device/uevent | grep PRODUCT | cut -d '=' -f2 | tr -d '\n')" | ||||
| 	else | ||||
| 		uci -q delete network.$1.modalias | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue