yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] shaneaus:
New update

Just in case you weren't aware (you go to the last post first all of the time as I do) - there has been an update to the program!

It now saves the name of a loaded script, posts a confirmation msg if the script ran successfully, and auto closes the terminal window (unless the user selects the terminal display window), and the saved scripts are placed into their own folder.

Here is the link:

Gscript source code
[G1 Android Development] prash:
I love this thread so much. Thank you for all the contributions.. Gscript is easily one of my top must have apps for G1. I'll contribute something I learned to do just today.

Backup and Restore your SMS and MMS databases. Great for quick restores after wipes.

I sorta based the scripting code on the market cache/restore one posted above, so don't complain.

Backup SMS/MMS

mkdir /sdcard/mmssms
busybox cp /data/data/com.android.providers.telephony/databases/mmssms.db /sdcard/mmssms/mmssms.db
echo done backup

Restore SMS/MMS Backup

busybox rm /data/data/com.android.providers.telephony/databases/assets.db
busybox cp /mmssms/mmssms.db /data/data/com.android.providers.telephony/databases/mmssms.db
echo done restore

Enjoy!
[G1 Android Development] shaneaus:
Thanks Prash!

I just found someone looking for exactly the script you added and pointed him this way!
[G1 Android Development] pascanu:
Market database backup and restore

Here are 2 script files for backing up and restoring Market assets database.

Original here:

http://xdaforums.com/showpost.php?p=3655174&postcount=44
[G1 Android Development] short/y:
I'm not sure why you would want to remove the existing assets.db before copying over it. Doesn't matter, I suppose. One command as opposed to two. BTW, I don't backup to /sdcard, I backup to /system/sd and I use "cp -p". That way I get to keep owner/group and permissions.

Has anyone tried saving assets.db, upgrading to 1.5 and then restoring assets.db? If the database format is the same, it would mean that Market knows what you've got installed and you'll know when there are updates.
[G1 Android Development] Arioch5:
I've been setting up scripts to backup application data since I'm not useing apps2sd and hate having to set everything back up after a clean wipe. Can anyone help with a few more things I'm missing?

1 - Where is the database for your wifi networks? I've got several networks setup and don't want to have to set them all up again post wipe.

2 - Is there any way to save the icon locations on your desktops? Things like shortcuts to applications, anycut shortcuts, etc?

I'm not so sure the 2nd item is something you can just backup, but so far having my notpad/bookmars/todolist/etc backed up is nice.
[G1 Android Development] gadiator:
I tried to restore a modified database, the script works, but i don't see the new data? Is there any restriction or so?
[G1 Android Development] Arioch5:
Did you reboot after you restored the database? I've found that some of my applications (browser bookmarks) don't read in the new changes until after I've rebooted.
[G1 Android Development] gadiator:
Yes, i did, perhaps it could be a problem of my Editor?
[G1 Android Development] short/y:
You want to copy wpa_supplicant.conf from /data/misc/wifi to someplace safe like /system/sd or /sdcard. When you restore it, copy it back to /data/misc/wifi. Note that /sdcard can't retain the original permissions which is why I copy it to /system/sd -- it's an ext2fs partition (you *have* created a 2nd partition on your SD card, haven't you?). I've gone so far as to create a dataBackup directory in /system/sd and do the copy like so

su
cp -p /data/misc/wifi/wpa_supplicant.conf /system/sd/dataBackup/misc/wifi

he directory structure makes it easier for me to remember where the original file came from. To create a directory structure like mine, you need to

su
mkdir /system/sd/dataBackup
mkdir /system/sd/dataBackup/misc

This may nto be the kind of answer you're looking for but MyBackup backs up home screen shortcuts. I use it all the time.
[G1 Android Development] shaneaus:
su

cp -p /system/sd/data/misc/wifi/wpa_supplicant.conf /system/sd/dataBackup/misc/wifi

Didn't work for me. I made the directories just fine. But, the script returns error: Couldn't find the file. I checked the location above with "/system/sd/data/misc/wifi/wpa_supplicant.conf" because I have my data file on the ext2 partition of my sdcard.

Any suggestions?

*********************************************************

Also, I made the following script for Nuubs (like me!) who want to know what is going on with their phone. This is something devs wouldn't think of because...Duh! they know how! But, this was the first script I wrote without any input from anyone. So, hopefully, it helps some other Nuub.

This saves a log of the phone's activity (output) to a text file on your sdcard.

logcat -d >/sdcard/logcatoutput.txt
[G1 Android Development] BSDADON:
So this is where i saw the script! I've been using this since i first saw it (just forgot where I had found the original). Thanks for this. I also started using it to test out new dude builds when I am not home or near a computer. Works great for that as well, and gives me a little peace of mind against a bootloop, and solves my impatience for waiting to be around a computer to try out a new build. Exactly the same as your script, just made an os folder and then put in folder for the build, and the update.zip, just like your script. So thank you for having this originally, because I would have never thought of it:D

echo "boot-recovery
--update_package=SDCARD:os/dude/update.zip" > /cache/recovery/command
reboot recovery
[G1 Android Development] Arioch5:
Thanks for the info, I'll see if I can get mine backing that up and I should have everything backed up. Guess I'll see what I forgot when I do the next wipe!

I'm a little lost by your command. You should always be including the file:

/data/misc/wifi/wpa_supplicant.conf

Weather you're copying from there to your backup, or from your backup to there for the restore. You're looking for the wpa_supplicant.conf in the wrong place form what I can tell.
[G1 Android Development] short/y:
Yeah, what Arioch5 said -- for backing it up, the first filename needs to be /data/misc/wifi/wpa_supplicant.conf.

Good tip
[G1 Android Development] shaneaus:
I altered the comman line because my data is on the sd card... Not, at the location in the original script. But, I ran it the other way withou success as well.
[G1 Android Development] missxoash:
Hmmm this didn't work for me...

It said radiooptions 9 wasn't found or whatever.
[G1 Android Development] short/y:
Did you move the *entire* /data directory/filesystem? Most people only move app and app-private and maybe dalvik-cache. Unless you moved all the directories then misc is still in /data.
[G1 Android Development] shaneaus:
I had.. But, disregard the above. Since I updated to Dude1.1 I reformatted my ext2 partition and only moved over my apps and private files.

I'll try it with the initial script tomorrow and update this reply with the result.

Gotta go to bed now... Too tired from work.

After installing the new Dude ROM it worked like a charm!!! I had to run Unbuntu Live CD and re-format my ext2 partition (I had saved my apps to the fat32 partition so I could copy them back afterwards) to delete all of the files. Then it worked great!

Thanks for the script!
[G1 Android Development] PockyBum522:
Unmount SD?

If I do umount /sdcard and then go look at Settings>Sd Card and Storage it shows up as 0 free space/used space so I'm assuming it unmounted correctly. However the G1 still complains of an unexpected SD removal when you pop out the SD Card if you just use umount as opposed to hitting the Unmount button in settings. What's the proper command to tell the G1 it's unmounted so it doesn't complain at me when I remove the SD card after?

Thanks!
[G1 Android Development] MontAlbert:
i have a basic linux type question.

i have made a basic script to backup my data from the workout manager program so i dont lose it when i reflash....

cp /system/intmem/data/com.wktmngr/MyWorkout /sdcard/workoutmanager

seems to work. my question is (and it is the same for the script for copying file back to data): in linux if i copy a file into a folder and there is already a file there with same name, does it just overwrite the file or does it not copy it?

ie. should i put a rm line first before copying the new file over?

thanks
[G1 Android Development] pershoot:
use the -f flag
[G1 Android Development] geemboomba:
Running a bunch of scripts from one

Is there a way to run a bunch of gscripts from one gscript?
[G1 Android Development] savethechicken:
You would just have to add all the commands from the scripts you want into one script and it will run through them all before it closes the terminal. You would want to make sure that any reboot commands be left until the end. All the scripts do is run the terminal commands for you.
[G1 Android Development] MontAlbert:
thanks for that- had to do a google on the -f but got it now..( http://www.oreillynet.com/linux/cmd/cmd.csp?path=c/cp )... makes the script much easier, cleaner and nicer- thanks.

does the -f get rid of all files with same name in that directory or all files in the directory full stop?
[G1 Android Development] slippylane:
A script to fetch your WAN (internet) IP

A quick script that uses whatismyip.org to get the IP address that the internet sees as yours. Obviously, if you are on WiFi, it will return the router's internet IP.

echo 'script: myip.sh'
echo 'desc: script to fetch your IP address'
echo 'author: Slippy Lane (slippy@slippylane.com)'
echo 'license: public domain'
echo
echo 'Fetching your IP from whatismyip.org - this might take a minute'
wget -O/sdcard/ip -q http://whatismyip.org
echo Your IP address is: `cat /sdcard/ip`

For some reason, directing wget to stdout wouldn't work, so I directed it to a file and pulled the text from there
[G1 Android Development] pershoot:
-f does a replace of the file its acting on.
[G1 Android Development] xidominicanoix:
Mod please delete this post
[G1 Android Development] xidominicanoix:
Toggling Hidden Folder

this is my first script so hope it helps someone out :D

First time you run the script, it will make the folder to use for hiding files.

Afterwards, it will either hide or unhide that folder
[G1 Android Development] xidominicanoix:
Backup and Restore PureRSS files

I've gotten tired of losing all my feeds every time I wipe my phone, so here's a script to backup and one to restore your files.

NOTE: Only works for PureRSS, which is IMO the best RSS reader ;)

NOTE2: Have tested it twice, so I'm sure it works

Backup script:

Restore script:
[G1 Android Development] shaneaus:
Script to apply LucidREM script to newly installed ROM.

Lets say you have used LucidREM's script previously and it is downloaded to the appropriate location on your SDcard. But, you just installed an new ROM and can't run LucidREM scripts. This is just his script from this thread:

http://xdaforums.com/showthread.php?t=480582

But, without the download (wget) and mkdir lines. Easy one - but, I put it up here for any noobs who might not have thought about it. This will need "su" checked. Here you go:

mount -o rw,remount /dev/block/mtdblock3 /system

cd /sdcard/tmp

busybox cp lucid.txt /system/bin/lucid

chmod 755 /system/bin/lucid

busybox chown 0:0 /system/bin/lucid
[G1 Android Development] D-e-v-i-l:
Lucid install and Upgrade script:

if [ -f /system/bin/lucid ]
then
echo "lucid script exist - update"
lucid -u
else
echo "lucid script do not exist - Install"
mount -o rw,remount /dev/block/mtdblock3 /system
if [ -d /sdcard/tmp ]
then
cd /sdcard/tmp
else
mkdir /sdcard/tmp
fi
if [ -f /sdcard/tmp/lucid.txt ]
then
rm /sdcard/tmp/lucid.txt
else
fi
wget http://files.lucidrem.us/jf/system/bin/lucid.txt
busybox cp lucid.txt /system/bin/lucid
chmod 755 /system/bin/lucid
busybox chown 0:0 /system/bin/lucid
fi
[G1 Android Development] haitiankid4lyf:
yeah you should, if there are saved on the sdcard some thing like this should work:

su
cd sdcard
sh *.sh
[G1 Android Development] smasraum:
I installed the gscript.apk using "adb install gscript.apk" and it worked. I have the Gscript icon. I've created and run 2 scripts (backing up and restoring wpa_supplicant.conf, the backup works, haven't tried the restore).

I've also created several ___.sh files and uploaded them to /sdcard/, but if I click "load file" I get the black screen that says "Select a file (.sh from sdcard)", but it doesn't list any files. I'd originally put them in a folder labeled "scripts", but I've since moved them to /sdcard/. I see the files if I cd /sdcard and then ls. What's going on. Did I miss some instructions somewhere? Thanks
[G1 Android Development] savethechicken:
I have wirtten two scripts that i have at sometime had to use on a regular basis. Good for those that don't use Nandroid or the Backup for Root users app. Or for those that just want to see what the script looks like.

Going to post bot scripts as they go together.

All require su

First... backup.

mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
mkdir /sdcard/backup_app
busybox cp -r /data/app /sdcard/backup_app/
Also can include private but will not put this here.

Second install all apps at once...(You HAVE to install Gscript before you can do this) but this is perfect for after a wipe.

mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
cd sdcard/backup_app/app
busybox install *.apk /data/app/
reboot

The install will still take a few minutes after the reboot depending on how many apps you have. I have something like 75 and it took about 1-2 minutes before it rebooted then another 1-2 minutes for it finish installing the apps. Both tend to hang with a blank screen on Gscript then just reboot, seems to be normal.

Third...(Dont know when you would use this I only used it for the testing)

Remove/uninstall all apps at once without a wipe

mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
rm /data/app/*.apk
reboot

Not responsible for any damage caused but i have tested these scripts and they work on my phone.
[G1 Android Development] savethechicken:
You have to put the .sh files in the GScript folder that is created on your sdcard. Then you can see them.
[G1 Android Development] smasraum:
Doh! Yeah, that fixed it.
[G1 Android Development] shaneaus:
I have a request for a script!

I want my hardware keyboard to stay lit up as long as the keyboard is open.

I know that "Power Manager" has a setting within the app. However, I don't really like nor want to use power manager. I use Toggle Settings - I sent an email to the developer via Google source code web page - but, have had no response from him/her as of yet.

So, I want a script that I can run that will alter the permanent setting to keep the light on when the KB is open (shouldn't have to state this here - but, off when it is closed).

Also, from reading the forums many people have been having a problem with the app "Dark Keys" so it might be beneficial to many if we also had a script that would make the hardware KB light stay off.

Please, someone come up with this so I don't have to keep hitting the trackball/menu button to get my light back on when typing in scripts or modifying my Gscripts!

If Power manager can do it - shouldn't be a script we can run?
[G1 Android Development] shaneaus:
I would respectfully suggest using "-r" instead of "-a" in the backup script. I was getting errors in *certain* files with the a. With the r they ALL copied.

Let me know if that is a good change or not.
[G1 Android Development] smasraum:
Unfortunately, I can't offer any assistance with your request, but someone has posted a new app to replace Dark Keys (backlightoff) that will turn the light off and work with rooted phones. So we got our fix, hopefully you get yours. You may have some luck contacting the dark keys and/or backlightoff guys (both have been here on the board) to ask if they could easily alter their code to do what you want.
[G1 Android Development] sacredsoul:
Hey can someone tell me how to create a .bat file so it automatically links to my tools folder for adb? Now i got to run cmd, the cd to it manually...
[G1 Android Development] savethechicken:
Yeah good deal I had -r on my script on the phone but i typed -a my fault. Thanks for the heads up.
[G1 Android Development] th4r:
A simple script that adds a swapfile ;)

#!/system/bin/sh

## change to /sdcard/swapfile if u don't have apps2sd
SWP=/system/sd/swapfile.swp

if [ -f $SWP ]; then
echo "Swapfile exist, removing.."
swapoff $SWP
rm $SWP
fi
echo "Creating new Swapfile.."
dd if=/dev/zero of=$SWP bs=1M count=32 ##Change 'count' if u want smaller or bigger swap
echo 10 > /proc/sys/vm/swappiness
mkswap $SWP
swapon $SWP
echo "Done."

You can use it with gScript or in a term.

And for swapoff

#!/system/bin/sh

## change to /sdcard/swapfile if u don't have apps2sd
SWP=/system/sd/swapfile.swp

if [ -f $SWP ]; then
echo "Swapfile exist, removing.."
swapoff $SWP
rm $SWP
fi
[G1 Android Development] dumfuq:
portknocker script

i use this script to knock on my firewall running a knockd daemon and let me in to my home computer (to check torrents or whatnot).

#!/system/bin/sh

while true
do
echo "knocking ports..."
nc -w1 my.house.org PORT#1 2> /dev/null
nc -w1 my.house.org PORT#2 2> /dev/null
nc -w1 my.house.org PORT#3 2> /dev/null

echo "testing..."
rm /sdcard/tmp/ERROR
nc -w1 my.house.org 22 -e exit 2> /sdcard/tmp/ERROR

TMP=`cat /sdcard/tmp/ERROR`

if [ -z "$TMP" ]; then
echo "success..."
echo " "
echo "starting connectbot..."
am start 'ssh://username@my.house.org:22/#username%40my.house.org#Intent;action=android.intent.action.VIEW;launchFlags=0x4000000;end'
exit
fi
echo "failed..."
echo " "
done
exit
[G1 Android Development] prscott1:
It isn't elegant, but you could use the input keyevent keys to move the cursor and launch the item you want. That is, if the host is first in your list, you could use the input keyevent items.
[G1 Android Development] imbonez9:
I'll prob get flamed for this but I'm trying to run a script that just turns the power off. And another that reboots in recovery mode. Trying to find like a cheat sheet of codes but unable to find any :( Yes I've googled and did the search on here. Can maybe someone help me with these. Thank You
[G1 Android Development] Proxin:
I barely know my way around the commands around to be able to say that a reboot in recovery mode is like so:

reboot recovery

I wanted one to shut it down too but couldn't figure it out myself. Brave of you to ask on the forums, you did what I couldn't. *claps* :p
[G1 Android Development] imbonez9:
Thank you and whats the worst thats gonna happen people i don't know and will never will get all upset? Oh boohoo... haha
[G1 Android Development] dumfuq:
shutdown

reboot -p #poweroff device
[G1 Android Development] imbonez9:
OMG it worked thank you!!!
[G1 Android Development] jbomxda:
Script to edit init.rc

I've been using the Sysctl Tweak to make my phone snappier, and would like to know if it would be possible to modify init.rc thru a script that appends the following line to the end of /system/init.rc file:

service sysctl /system/xbin/bb/sysctl -p

Any help would be appreciated!
[G1 Android Development] imbonez9:
I have a question about this... for some reason when ever i do this and i power my phone back on again will loop at the Android screen forcing me to wipe... Happened multiple times one right after another... Is the reboot -p the cause of this or just my crappy ass phone... Have turned it off and turned back on and didn't have a problem doing it that way just after using this code... Thank you
[G1 Android Development] dumfuq:
I don't see how 'reboot -p' would force you to wipe but anything is possible. It works on my phone with no issue.
[G1 Android Development] imbonez9:
I have no idea my phone hates me. There's the Black Ice theme that i was able to install once but never again... My phone is retarded some how, yes the phone not the opperator! haha
[G1 Android Development] :
For the German Users(tested with CyanogenMod).

Switch to the German qwertz keylayout after applying a update(requires su)

echo "Mounting System as read/write:"
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
echo "Done"
echo "Copy Keychars:"
cp /system/usr/keychars/trout-keypad-qwertz.kcm.bin /system/usr/keychars/trout-keypad-v3.kcm.bin
cp /system/usr/keychars/trout-keypad-qwertz.kcm.bin /system/usr/keychars/qwerty.kcm.bin
cp /system/usr/keychars/trout-keypad-qwertz.kcm.bin /system/usr/keychars/qwerty2.kcm.bin
cp /system/usr/keychars/trout-keypad-qwertz.kcm.bin /system/usr/keychars/trout-keypad-v2.kcm.bin
cp /system/usr/keychars/trout-keypad-qwertz.kcm.bin /system/usr/keychars/trout-keypad.kcm.bin
echo "Done"

echo "Copy Keylayout:"
cp /system/usr/keylayout/trout-keypad-qwertz.kl /system/usr/keylayout/trout-keypad-v3.kl
cp /system/usr/keylayout/trout-keypad-qwertz.kl /system/usr/keylayout/trout-keypad-v2.kl
cp /system/usr/keylayout/trout-keypad-qwertz.kl /system/usr/keylayout/trout-keypad.kl
cp /system/usr/keylayout/trout-keypad-qwertz.kl /system/usr/keylayout/qwerty.kl
cp /system/usr/keylayout/trout-keypad-qwertz.kl /system/usr/keylayout/h2w_headset.kl
cp /system/usr/keylayout/trout-keypad-qwertz.kl /system/usr/keylayout/AVRCP.kl
echo "Done"
echo "rebooting..."
reboot

have to overwrite all files, because a reboot overwrites the -v3 file
[G1 Android Development] prscott1:
backup and restore bookmarks using sqlite3 export / import

I made better scripts for backing up and restoring bookmarks using sqlite3. The first script pulls just the bookmarks table out of the database and writes them to a file. The second script clears the bookmarks from the database then imports the bookmarks that you have in the file.

To pull bookmarks:

echo "Exporting browser bookmarks..."
echo ""
sqlite3 /data/data/com.android.browser/databases/browser.db << EOF
.output /sdcard/backup/browser/bookmarks.txt
select * from bookmarks where bookmark = '1';
.quit
EOF

To import bookmarks:

echo "Importing bookmarks..."
echo ""
sqlite3 /data/data/com.android.browser/databases/browser.db << EOF
delete from bookmarks;
.import /sdcard/backup/browser/bookmarks.txt bookmarks
.quit
EOF
[G1 Android Development] the.snks:
In cupcake, running this script does NOT remove the browser history (which I would think is included with the Browser cache).

Does anyone know what the proper code is now?
[G1 Android Development] bhang:
Huh? whats the deal, did I miss a memo that says we can no longer talk about apps2sd?

the way you wrote the post it seems that its OK to talk about moving those 2 folders to a *nix(ext2/ext3) partition of the card, but its not kosher to talk about moving it to a fat (MS) partition?

I was here when MS sent a C&D letter due to roms being attached to posts, thus having MS property on the XDA servers, but I have never seen any discussion squashed here, am I confused or did somthing change...?

I'd assume its has something to do with "private" aka PAID apps, but his post didn't seem to be about pirating paid apps, as a developer centric site I can see why the admin (and even the users here) would want to protect the android developers, I havent tried but Im sure it wouldn't be to hard to get an app and move it to another phone, I can't see how the.apks could be more pir8able on a fat32 disk than an ext2/3 partition.

please somebody tell me I have this all wrong, cause I have always loved the free wide open discussion that goes on here, and I'd hate to see that go away...

I have to admit I haven't read much outside of the DREAM forums since OCT. 22 when I got my g1, so I could have missed a post...

bhang