35 rivejä
916 B
Bash
35 rivejä
916 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
# This script will accept a text file with standard u-boot commands and
|
||
|
# load it to the U-Boot environment. The original environment is saved
|
||
|
# in a backup file in the current directory
|
||
|
|
||
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||
|
BACKUP_FILE=u-boot_env-$$.bak
|
||
|
|
||
|
if [ -z "$1" ]; then
|
||
|
echo "Usage: $0 U-BOOT_ENV_FILE"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# Backup existing U-Boot environment
|
||
|
env fw_printenv > $BACKUP_FILE || exit 2
|
||
|
|
||
|
# Check if the ethaddr variable is defined
|
||
|
ethaddr=$(fw_printenv ethaddr 2> /dev/null)
|
||
|
|
||
|
while read line
|
||
|
do
|
||
|
# Suppress the ethaddr overwrite warning
|
||
|
[ -z "$ethaddr"] && [[ "$line" =~ "ethaddr" ]] && continue
|
||
|
|
||
|
# ignore comments starting with '#'
|
||
|
if [[ "$line" == *'#'* ]]; then
|
||
|
line=$(echo $line | cut -d\# -f1)
|
||
|
fi
|
||
|
|
||
|
if [[ $line = *[^[:space:]]* ]]; then
|
||
|
env fw_setenv $(echo $line | sed 's/=/ /') || exit 3
|
||
|
fi
|
||
|
done < "$1"
|