mirror of
https://github.com/OpenMANET/morse-feed.git
synced 2025-12-10 03:43:06 -06:00
persistent-vars-storage: (PR #752): Add READ -a flag to read all vars
Define all the known vars and a flag that prints them all. This is only useful for developers who forget the names of vars. Missing vars are printed like `mm_mode=`, so there is no way to distinguish empty and missing vars. Non printable characters are not escaped, nor are newlines or = signs. This is only useful for developers. This works on EKH01, although it is not very useful. It spews a lot of text to stderr. Approved-by: James Haggerty Approved-by: Sophronia Koilpillai
This commit is contained in:
parent
4d44171796
commit
eec5432f7c
@ -20,10 +20,12 @@ get_key_from_persistent_storage()
|
||||
|
||||
print_usage()
|
||||
{
|
||||
echo "persistent_vars_storage.sh OPERATION(READ|WRITE|ERASE) KEY [VALUE]" 1>&2;
|
||||
echo "persistent_vars_storage.sh OPERATION(READ|READALL|WRITE|ERASE) KEY [VALUE]" 1>&2;
|
||||
}
|
||||
|
||||
|
||||
all_keys="device_password default_wifi_key dpp_priv_key mm_region
|
||||
mm_virtual_wire mm_mode dropbear_authorized_keys dropbear_ed25519_host_key
|
||||
dropbear_rsa_host_key"
|
||||
|
||||
case "$operation" in
|
||||
READ)
|
||||
@ -38,6 +40,12 @@ case "$operation" in
|
||||
fi
|
||||
;;
|
||||
|
||||
READALL)
|
||||
for key in $all_keys; do
|
||||
printf '%s=%s\n' "$key" "$($0 READ "$key")"
|
||||
done
|
||||
;;
|
||||
|
||||
WRITE|ERASE)
|
||||
echo "Writing to persistent memory isn't implemented on bcm2711, yet." 1>&2;
|
||||
exit 1
|
||||
@ -49,5 +57,3 @@ case "$operation" in
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ trap exit_handler EXIT
|
||||
exit_handler()
|
||||
{
|
||||
if [ "$?" -ne 0 ]; then
|
||||
echo "Usage: $0 OPERATION(READ|WRITE|ERASE) KEY [VALUE]" 1>&2
|
||||
echo "Usage: $0 OPERATION(READ|READALL|WRITE|ERASE) KEY [VALUE]" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@ -82,6 +82,10 @@ fi
|
||||
operation="$1"
|
||||
key="$2"
|
||||
|
||||
all_keys="device_password default_wifi_key dpp_priv_key mm_region
|
||||
mm_virtual_wire mm_mode dropbear_authorized_keys dropbear_ed25519_host_key
|
||||
dropbear_rsa_host_key"
|
||||
|
||||
case "$operation" in
|
||||
READ)
|
||||
if ! fw_printenv -n -c "$conffile" "$key" 2> /dev/null; then
|
||||
@ -91,6 +95,12 @@ case "$operation" in
|
||||
fi
|
||||
;;
|
||||
|
||||
READALL)
|
||||
for key in $all_keys; do
|
||||
printf '%s=%s\n' "$key" "$($0 READ "$key")"
|
||||
done
|
||||
;;
|
||||
|
||||
WRITE)
|
||||
value="$3"
|
||||
fw_setenv -c "$conffile" "$key" "$value"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user