fcc-unlock: Make scripts POSIX shell compatible
This allows us to not rely on bash which may not be available on constrained systems, e.g. Yocto-built embedded systems. The scripts now pass shellcheck. Signed-off-by: Sven Schwermer <sven.schwermer@disruptive-technologies.com>
This commit is contained in:
@@ -15,20 +15,20 @@ shift
|
|||||||
# second and next arguments are control port names
|
# second and next arguments are control port names
|
||||||
for PORT in "$@"; do
|
for PORT in "$@"; do
|
||||||
# match port type in Linux 5.14 and newer
|
# match port type in Linux 5.14 and newer
|
||||||
grep -q MBIM /sys/class/wwan/${PORT}/type 2>/dev/null && {
|
grep -q MBIM "/sys/class/wwan/$PORT/type" 2>/dev/null && {
|
||||||
MBIM_PORT=$PORT
|
MBIM_PORT=$PORT
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
# match port name in Linux 5.13
|
# match port name in Linux 5.13
|
||||||
[[ $PORT == *"MBIM"* ]] && {
|
echo "$PORT" | grep -q MBIM && {
|
||||||
MBIM_PORT=$PORT
|
MBIM_PORT=$PORT
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
# fail if no MBIM port exposed
|
# fail if no MBIM port exposed
|
||||||
[ -n "${MBIM_PORT}" ] || exit 2
|
[ -n "$MBIM_PORT" ] || exit 2
|
||||||
|
|
||||||
# run qmicli operation over MBIM
|
# run qmicli operation over MBIM
|
||||||
qmicli --device-open-proxy --device=/dev/${MBIM_PORT} --dms-foxconn-set-fcc-authentication=0
|
qmicli --device-open-proxy --device="/dev/$MBIM_PORT" --dms-foxconn-set-fcc-authentication=0
|
||||||
exit $?
|
exit $?
|
||||||
|
@@ -19,15 +19,15 @@ shift
|
|||||||
# second and next arguments are control port names
|
# second and next arguments are control port names
|
||||||
for PORT in "$@"; do
|
for PORT in "$@"; do
|
||||||
# match port name
|
# match port name
|
||||||
[[ $PORT == *"cdc-wdm"* ]] && {
|
echo "$PORT" | grep -q cdc-wdm && {
|
||||||
CDC_WDM_PORT=$PORT
|
CDC_WDM_PORT=$PORT
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
# fail if no cdc-wdm port exposed
|
# fail if no cdc-wdm port exposed
|
||||||
[ -n "${CDC_WDM_PORT}" ] || exit 2
|
[ -n "$CDC_WDM_PORT" ] || exit 2
|
||||||
|
|
||||||
# run qmicli operation
|
# run qmicli operation
|
||||||
qmicli --device-open-proxy --device=/dev/${CDC_WDM_PORT} --dms-set-fcc-authentication
|
qmicli --device-open-proxy --device="/dev/$CDC_WDM_PORT" --dms-set-fcc-authentication
|
||||||
exit $?
|
exit $?
|
||||||
|
@@ -15,20 +15,20 @@ shift
|
|||||||
# second and next arguments are control port names
|
# second and next arguments are control port names
|
||||||
for PORT in "$@"; do
|
for PORT in "$@"; do
|
||||||
# match port type in Linux 5.14 and newer
|
# match port type in Linux 5.14 and newer
|
||||||
grep -q MBIM /sys/class/wwan/${PORT}/type 2>/dev/null && {
|
grep -q MBIM "/sys/class/wwan/$PORT/type" 2>/dev/null && {
|
||||||
MBIM_PORT=$PORT
|
MBIM_PORT=$PORT
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
# match port name in Linux 5.13
|
# match port name in Linux 5.13
|
||||||
[[ $PORT == *"MBIM"* ]] && {
|
echo "$PORT" | grep -q MBIM && {
|
||||||
MBIM_PORT=$PORT
|
MBIM_PORT=$PORT
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
# fail if no MBIM port exposed
|
# fail if no MBIM port exposed
|
||||||
[ -n "${MBIM_PORT}" ] || exit 2
|
[ -n "$MBIM_PORT" ] || exit 2
|
||||||
|
|
||||||
# run mbimcli operation
|
# run mbimcli operation
|
||||||
mbimcli --device-open-proxy --device=/dev/${MBIM_PORT} --quectel-set-radio-state=on
|
mbimcli --device-open-proxy --device="/dev/$MBIM_PORT" --quectel-set-radio-state=on
|
||||||
exit $?
|
exit $?
|
||||||
|
Reference in New Issue
Block a user