User-agent: Mediapartners-Google Disallow: User-agent: * Disallow: /search Allow: / Sitemap: http://nano7mobile.blogspot.com/sitemap.xml Nano Mobile: Modifying build.prop via script topic

Modifying build.prop via script topic






I'm trying to create a script to modify the build.prop file 'automatically'.
I want the script to check for entries I define and:
1. If they do not exist add them
2. If they do exist, check the value, and if it does not match what I've define modify it.

I found a much older (2012) thread and took a script from there. But it doesn't work.
It runs but outputs nothing, not changing the build.prop

I've attached the script. Is it correct?


Code:


#!/system/bin/sh

# Definitions
file=/system/build.prop
tmpf=/system.buildprop.bak
line_list="wifi.supplicant_scan_interval=120 ro.sf.lcd_density=480"

# Function to get args as needed for loop
getargs() {

par=
line=`echo $par |cut -d"=" -f1`
arg=`echo $par |cut -d"=" -f2`
}

# Loop to make all changes in line_list
for x in $line_lst; do

# Get all needed arguments
getargs $x

# Write this change to a tmp file to check on it
oldarg=`grep $line $file |cut -d"=" -f2`
sed "s/$line=.*/$line=${arg}/g" $file > $tmpf

# Check if the change was made
chknewarg=`grep $line $tmpf |cut -d"=" -f2`
if [ "$chknewarg" = "$arg" ]; then
cp $tmpf $file
if [ -f $tmpf ]; then
rm $tmpf
fi
echo "File edited"
else
if [ -f $tmpf ]; then
rm $tmpf
fi
echo "Expected $arg, got $chknewarg instead"
exit 1
fi
# If it doesn't exist at all append it to the file
chkexists=`grep -c $line $file`
if [ $chkexists -eq 0 ]; then
echo "$x" >> $file
fi
done
exit 0








Aucun commentaire:

Enregistrer un commentaire