diff options
Diffstat (limited to 'script/script.config')
-rwxr-xr-x | script/script.config | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/script/script.config b/script/script.config new file mode 100755 index 0000000..3f85083 --- /dev/null +++ b/script/script.config @@ -0,0 +1,42 @@ +#!/bin/sh + +IP=192.168.0.1 +MODEL=vusolo2 +OETOP=/openembedded/path/here + +CONFIG_PATH=$PWD/../config.mk + +function getValue() { + IN=$1 + set -- "$IN" + IFS="="; declare -a Array=($*) + echo "${Array[1]}" +} + +# set default config value from old config. +if [ -e $CONFIG_PATH ]; then + IP="$(getValue `cat $CONFIG_PATH | grep 'IP='`)" + MODEL="$(getValue `cat $CONFIG_PATH | grep 'MODEL='`)" + OETOP="$(getValue `cat $CONFIG_PATH | grep 'OETOP='`)" +fi + +# input new config. +read -p "Please, input target ip [$IP] : " NEW_IP +read -p "Please, input model name [$MODEL] : " NEW_MODEL +read -p "Please, input openembeded root path [$OETOP] : " NEW_OETOP + +# check new config value. +if [ ! -z $NEW_IP ]; then IP=$NEW_IP; fi +if [ ! -z $NEW_MODEL ]; then MODEL=$NEW_MODEL; fi +if [ ! -z $NEW_OETOP ]; then OETOP=$NEW_OETOP; fi + +# backup config file. +if [ -e $CONFIG_PATH ]; then + cp -a $CONFIG_PATH $CONFIG_PATH.bak +fi + +# write config file. +echo "MODEL=$MODEL" > $CONFIG_PATH +echo "OETOP=$OETOP" >> $CONFIG_PATH +echo "" >> $CONFIG_PATH +echo "IP=$IP" >> $CONFIG_PATH |