mirror of https://github.com/OpenIPC/firmware.git
				
				
				
			
		
			
				
	
	
		
			76 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
			
		
		
	
	
			76 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
| #!/bin/sh
 | |
| CMD=$(echo "$0" | cut -d / -f 4)
 | |
| ARCH=$(uname -m)
 | |
| 
 | |
| if echo "$ARCH" | grep -q mips; then
 | |
| 	ARC="-mips32"
 | |
| fi
 | |
| 
 | |
| case "$CMD" in
 | |
| 	cli)
 | |
| 		yaml-cli -i /etc/majestic.yaml "$@"
 | |
| 		;;
 | |
| 
 | |
| 	sensor_cli)
 | |
| 		yaml-cli -i /etc/sensor/"$(fw_printenv -n sensor)".yaml "$@"
 | |
| 		;;
 | |
| 
 | |
| 	ipctool)
 | |
| 		IPCTOOL=/tmp/ipctool
 | |
| 		if [ ! -x $IPCTOOL ]; then
 | |
| 			curl -s -L -f -o $IPCTOOL https://github.com/OpenIPC/ipctool/releases/download/latest/ipctool"$ARC"
 | |
| 			response=$?
 | |
| 			if [ "$response" -ne 0 ]; then
 | |
| 				echo "Unable to download ipctool. cUrl error code is $response."
 | |
| 				exit $response
 | |
| 			else
 | |
| 				chmod +x $IPCTOOL
 | |
| 				echo "The ipctool installed as remote GitHub plugin"
 | |
| 			fi
 | |
| 		fi
 | |
| 		$IPCTOOL "$@"
 | |
| 		;;
 | |
| 
 | |
| 	check_mac)
 | |
| 		VENDOR=$(ipcinfo -v)
 | |
| 		if [ "$VENDOR" = "hisilicon" ] || [ "$VENDOR" = "goke" ]; then
 | |
| 			if [ "$(fw_printenv -n ethaddr)" = "00:00:23:34:45:66" ]; then
 | |
| 				XMMAC=$(ipcinfo --xm-mac)
 | |
| 				if [ -n "$XMMAC" ] && [ "$XMMAC" != "Nothing found." ]; then
 | |
| 					fw_setenv ethaddr "$XMMAC"
 | |
| 					reboot -f
 | |
| 				else
 | |
| 					echo "Warning. Wired network interface has default MAC address, please change it."
 | |
| 				fi
 | |
| 			fi
 | |
| 		fi
 | |
| 		;;
 | |
| 
 | |
|         sysinfo)
 | |
| 		echo ""
 | |
| 		echo "Firmware:"
 | |
| 		echo -e "  $(grep -e OPENIPC_VERSION /etc/os-release)\n"
 | |
| 		echo "Majestic:"
 | |
| 		echo -e "  internal - $(/rom/usr/bin/majestic -v)"
 | |
| 		echo -e "  external - $(/usr/bin/majestic -v)\n"
 | |
| 		echo "USB devices:"
 | |
| 		echo -e "  $(lsusb | awk '{print $6}' | sort | tr '\n' ' ')\n"
 | |
| 		echo "Memory:"
 | |
| 		echo -e "  totalmem - $(fw_printenv -n totalmem)"
 | |
| 		echo -e "  osmem    - $(fw_printenv -n osmem || echo 'not set')\n"
 | |
| 		echo "Processor:"
 | |
| 		echo -e "  detected - $(ipcinfo -ci | tr '\n' '\t')"
 | |
| 		echo -e "  recorded - $(fw_printenv -n soc)\n"
 | |
| 		echo "Sensor:"
 | |
| 		echo -e "  detected - $(ipcinfo -s)"
 | |
| 		echo -e "  recorded - $(fw_printenv -n sensor)\n"
 | |
|                 ;;
 | |
| 
 | |
|         netip_hash)
 | |
|                 echo -n "$@" | md5sum | fold -w 2 | awk 'NR<17{printf "%d\n", "0x"$0}' | sed 'N;s/\n/ /' | awk '{c=($1+$2)%62; if (c<10) c+=48; else if (c<36) c+=55; else c+=61; printf "%c", c}'
 | |
|                 ;;
 | |
| 
 | |
| 	*)
 | |
| 		;;
 | |
| esac
 |