version=1 setstring="nvram set" cmdopts="$*" scr_name=$(basename $0) cwd=$(dirname $(readlink -f $0)) outfile="$cwd/restore-mynvram.sh" tmpfile="$outfile.tmp" count=0
echo "#!/bin/sh" >$tmpfile if [[ $# -eq 0 ]]; then echo "Usage: save-mynvram.sh var1 var2 var3 ..." echo -e "\t where var1 var2 var3 ... are the names of the NVRAM vars to save" echo "" exit 0 fi echo "" while [[ $# -gt 0 ]]; do var=$1 value=$(nvram get $1) lval=$(echo ${#value}) if [ $lval -gt 0 ]; then value=${value//$/\\$} # escape $ char value=${value//\"/\\\"} # escape " char value=${value//\`/\\\`} # escape ` char esc=`expr index "$value" $'\n'` # check for lf escape sequence else echo "Skipping $var (empty or does not exist)" shift continue fi let count=count+1 echo "Saving $var" echo "echo \"Restoring $var\"" >>$tmpfile if [ $esc -gt 0 ]; then valuex=${value//$'\r'/} # remove cr valuex=${valuex//$'\n'/\\n} # convert lf to escape sequence echo "$setstring $var=\"\$(echo -e \"$valuex\")\"" >>$tmpfile else echo "$setstring $var=\"$value\"" >>$tmpfile fi shift done if [[ $count -gt 0 ]]; then if [[ -e "$outfile" ]]; then echo "Backing up previous restore script to $outfile.bak" cp -f $outfile $outfile.bak fi echo "echo \"\"" >>$tmpfile echo "echo \"Restore complete - $count NVRAM variable(s)\"" >>$tmpfile echo "echo \"Enter 'nvram commit' then reboot to activate your restored settings\"" >>$tmpfile cp -f $outfile.tmp $outfile chmod a+rx $outfile rm $outfile.tmp echo "" echo "Saved $count NVRAM variable(s)" echo "Run $outfile to restore your saved settings" echo "" fi exit 0 -- =========== Saksikan drone Telkomsel dari Sabang dan Merauke melalui video streaming interaktif selama 30 hari di >> tsel.me/elangnusa #ElangNusa --------------------- Toko Headphone & Earphone Terlengkap dan Terbaru Kunjungi >> http://bassaudio.net ---------------------- Kontak Admin, Twitter @agushamonangan ----------------------- FB Groups : https://www.facebook.com/groups/android.or.id Aturan Umum ID-ANDROID >> goo.gl/mL1mBT ========== --- Anda menerima pesan ini karena Anda berlangganan grup "[id-android] Indonesian Android Community" dari Google Grup. Untuk berhenti berlangganan dan berhenti menerima email dari grup ini, kirim email ke id-android+unsubscr...@googlegroups.com. Kunjungi grup ini di https://groups.google.com/group/id-android.