Related
*** v2.1 Updated 2009-Jul-29 : Integrated into CyanogenMod ROM v3.9.3 (experimental) ***
WHAT IT DOES:
Gets ROMs: Gets a particular version of the CyanogenMod series of ROMs, verifies the MD5sum of the downloaded ROM file and sticks it on your SD card as update.zip, ready for you to flash. You can even fetch experimental and test versions of CM ROMs with this script.
List ROMs: You can list available ROMs on cyanogen's server. You can choose to list the latest available, the latest 5, or all available ROMs in the STABLE, EXPERIMENTAL and TESTING branches on cyanogen's server.
Automatically Reboot into recovery: It has an option to automatically reboot into recovery mode after a successful ROM download, to ease the flashing process. If you use this option, it counts down 10 seconds to give you a chance to change your mind in case you decide you do not want to reboot. During this countdown, you can ctrl+c out of the script (If you're doing this on the phone, to type "ctrl+c" you press the trackball, then hit the "c" key). I recommend that you install cyanogen's Recovery image
Backward compatibility mode: For those who prefer the way the old 1.0 script behaved, and fetch a ROM with a minimum of fuss without messing with pesky command line parameters
PRE-REQUISITES:
Busybox (for all the script goodness)
Root access (makes life easier)
Apps2SD (not mandatory)(the script goes on your ext2 partition)
HOW TO INSTALL:
In case the script is not already present in your CM ROM (or if you want to upgrade), simply follow the steps below to install/upgrade it.
Unzip the attached zip file
Push the "getcyan" script to your SD card, onto the ext2 partition. This is usually at "/system/sd". You can use adb push as follows:
Code:
adb push <PATH_TO_EXTRACTED_SCRIPT>/getcyan /system/sd
If you want to create a softlink to the getcyan script so you don't have to keep typing the full path to the script, do the following on the phone (or after running "adb shell"):
Code:
su
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
rm -f /system/bin/getcyan
ln -s /system/sd/getcyan /system/bin/getcyan
mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system
OR
Note that from adb, instead of typing in the whole mount command as above, you could also do the following
Code:
adb remount
adb shell
rm -f /system/bin/getcyan
ln -s /system/sd/getcyan /system/bin/getcyan
(thanks to Karolis for this tip)
Change the permissions on the script:
Code:
su
chmod 755 /system/sd/getcyan
USAGE:
You really should open up terminal and get a root shell using "su" before running the script. It has the following options:
Code:
OPTIONS :
-g VER - get/fetch CM ROM with version VER.
VER can be (see NOTE below):
latest - The latest available
x.x[.x]* - A particular version number
like 3.4 or 3.6 or 3.6.8.1
-G - get latest version. Shorthand for "-g latest"
-x - Get/list ROM(s) from experimental branch
-t - Get/list ROM(s) from testing branch
-l NUM - list/show NUM number of ROM(s).
NUM can be (see NOTE below):
latest - Show latest available ROM
some - Show the 5 latest ROMs
all - Show all available ROMs
-L - list latest. Shorthand for "-l latest"
-r - reboot into recovery after fetch
-f - override filename
-h - Help/usage (This message)
-v - Show version number of this script
NOTE:
For both the -g and the -l options above:
The ROMs listed/fetched depend on whether -t or -x
were passed in or not.
If -t was specified, then ROMs from the testing
directory will be shown/fetched
If -x was specified, then experimental ROMs will
be shown or fetched
If neither -x or -t was specified, then stable ROMs
are fetched
SHORTCUTS :
-6 - Get latest stable ROM and reboot into recovery
shorthand for "-g latest -r"
-8 - Get latest experimental ROM and reboot into recovery
shorthand for "-g latest -x -r"
EXAMPLES:
To see what the latest stable ROM is
Code:
getcyan -l latest
OR
Code:
getcyan -L
To see the last 5 experimental ROMs
Code:
getcyan -l some -x
To see all testing ROMs
Code:
getcyan -l all -t
To see what the latest experimental ROM is
Code:
getcyan -l latest -x
OR
Code:
getcyan -L -x
To get the latest stable ROM
Code:
getcyan -g latest
OR
Code:
getcyan -G
To get the latest stable ROM and automatically reboot into recovery mode
Code:
getcyan -g latest -r
OR
Code:
getcyan -G -r
OR
Code:
getcyan -6
To get the latest experimental ROM and automatically reboot into recovery mode
Code:
getcyan -g latest -x -r
OR
Code:
getcyan -G -r -x
OR
Code:
getcyan -8
To get a particular version of a ROM - say 3.6
Code:
getcyan -g 3.6
To get a particular version of a ROM - say 3.9 from the experimental branch, then reboot into recovery
Code:
getcyan -g 3.9 -x -r
To get a ROM with a particular filename. In this example, we get the "donuthole-20090725.zip" ROM from the testing branch (Notice the use of the "-f" parameter to force the filename override)
Code:
getcyan -g donuthole-20090725.zip -f -t
Backward Compatibility Mode - For that old-timey feeling. In this example, we get CM ROM version 3.6
Code:
getcyan 3.6
ACKNOWLEDGEMENTS:
ttabbal - For the md5sum idea
spacezorro - For the "latest" idea
Cyanogen - For the ROMs, man, for the ROMs
CHANGELOG:
2.1
Added (actually fixed) backward compatibility mode
Added version number (with option to display it, for scripting)
Cleaned up help message to remove irrelevant faff
This script is present in CyanogenMod Experimental ROM 3.9.3
2.0
List available ROMs - latest, latest 5 or all
Listing/fetching ROMs from stable, experimental and testing branches
Get latest ROM or a particular version
Ability to fetch an unconventionally-named ROM by specifying the filename on the command line
Automatically reboot into recovery mode after a successful fetch
This script is present in CyanogenMod Experimental ROM 3.9.2
Excellent job. Can't wait till Cyanogen just packages it with his mods.
beast.in.black said:
Apps2SD (the script goes on your ext2 partition)
Click to expand...
Click to collapse
Wouldn't it also work to stick this into /data/local/bin, which is already in the PATH variable by default (at least on cyan's ROMs). Of course, that way it would disappear on wipe, but it would be easier to run the script.
I tried adding a 'export PATH="$PATH:/system/sd/bin"' line to my userinit.sh, but it didn't have any effect. It probably runs too early...
@firetech : Yes, you could definitely stick it in your /data/local/bin...but as you pointed out, it will be lost on wipe. In case you don't have (or want) apps2sd, then this is an option for you. I would, however, recommend apps2sd along with the symlink method I outlined in the "How to install" section.
@overpower: Thanks
Used your original one from CM thread. Great that you added the experimental version download option.
When I came to read this post, I thought you were talking about switching between multiple versions of ROMs from cyano.
Do you think this can be extended to other ROMs as well?
Do you think writing peripheral code for really installing/reinstalling a ROM version would be a good idea to add to this script? For example:
1. Backup current /system/sd, along with the nandroid backup of the system and the ROM ZIP.
2. Mark the above with a ROM version and create a folder for it on /sdcard.
3. Provide the reverse to go back and forth between ROM versions. Make the nandroid backup from the selected ROM folder the latest so that recovery can restore it, copy the ZIP file in /sdcard as update.zip in case a wipe is needed.
Right now, this is a painstaking job to toggle between 2 ROMs.
If you are doing these steps in ADB, step #3 can be done much easier. Just type adb remount and that's it!
Also, at least on my phone it does not seem to want to work unless I su first.
Otherwise great script! Makes life much more easier. I like taking risks and downloading experimental ROM 15 minutes before my flight to foreign country, where if my phone is dead, I'm dead. This script will definitely allow me to do crazy stuff with more confidence
Oh, and I wish Cyanogen would add it to the ROM itself. At least until the OTA updater is built.
devsk said:
Do you think writing peripheral code for really installing/reinstalling a ROM version would be a good idea to add to this script?
Click to expand...
Click to collapse
devsk, interesting idea indeed...Let me put some thought into this
Karolis said:
If you are doing these steps in ADB, step #3 can be done much easier. Just type adb remount and that's it!
Also, at least on my phone it does not seem to want to work unless I su first.
Click to expand...
Click to collapse
Karolis, the script needs to run as root since otherwise wget has problems. I'll make this explicit in the instructions. Also, thanks for pointing out the "adb remount" command, I've added it to the instructions
I will try this, sounds like a great idea... thanks
Is there any way to add this to gscript? Since there needs to be interaction from the user, I would guess you would have to edit each time to make it work.
Yeah I will put it in 3.9.1 until we get a proper OTA updated finished.
cyanogen said:
Yeah I will put it in 3.9.1 until we get a proper OTA updated finished.
Click to expand...
Click to collapse
Sweet! Thank you.
Also, I know you must be sick of questions like this, but: is there an ETA for 3.9.1. I've seen you are playing with donut. Hopefully that won't postpone 3.9.1. too much...
You're the best!
beast.in.black, I've just had an idea for the future of this script. How about posting "a call to action" ir development and theme forums asking for all devs to use the same naming convention for their roms and themes + provide checksums. That way you could expand the script beyond CM's ROMs (that is if you want).
Of course not everyone would join this cause as some people don't have server resources to post stuff and it wouldn't work with file sharing services, but hey, it's worth a try.
What do you think?
Gscriptable getcyan
pixel-painter said:
I will try this, sounds like a great idea... thanks
Is there any way to add this to gscript? Since there needs to be interaction from the user, I would guess you would have to edit each time to make it work.
Click to expand...
Click to collapse
I hacked mine to use...
Code:
wget -q -O- http://n0rp.chemlab.org/android/ |grep "${FNAME_PREFIX}.*${FNAME_SUFFIX}\""|sed "s/.*<a href=\"//;s/\".*//"|tail -n1
Then I got the "scripting bug" and I rewrote it a bit so it wasn't hacked up.
Code:
#!/system/bin/sh
FNAME_PREFIX="update-cm-"
FNAME_SUFFIX="-signed.zip"
MD5NAME_SUFFIX="${FNAME_SUFFIX}.md5sum"
SAVEFNAME=/sdcard/update.zip
MD5CMD="md5sum -c"
MOD_FILENAME=""
MOD_MD5NAME=""
MIRROR="http://n0rp.chemlab.org/android/"
usage()
{
echo
echo "Usage : $0 ( [VERSION] [-x] | -h )"
echo " Gets a particular version of the CyanogenMod"
echo " series of ROMs, and sticks it on your SD card"
echo " as update.zip, ready for you to flash."
echo
echo "Args :"
echo " -h - Help (This Message!)"
echo " VERSION - The CM ROM version to fetch."
echo " -x - Specify that the version you want to fetch"
echo " is an EXPERIMENTAL version."
echo
exit
}
cleanup()
{
rm -f ${SAVEFNAME}
rm -f ${MOD_FILENAME}
rm -f ${MOD_MD5NAME}
}
latest()
{
wget -q -O- ${MIRROR}${EXPER} |grep "${FNAME_PREFIX}.*${FNAME_SUFFIX}\""|sed "s/.*<a href=\"//;s/\".*//"|tail -n1
}
if [ "$1" = "-h" ];
then
usage
fi
# check if user wants an experimental build
EXPER=""
if [ "$1" == "-x" ];
then
EXPER="experimental/"
echo "Experimental build specified"
elif [ "$2" == "-x" ];
then
EXPER="experimental/"
echo "Experimental build specified"
fi
if [ -z $1 ];
then
MOD_FILENAME=`latest`
MOD_MD5NAME=${MOD_FILENAME}.md5sum
VER="Latest"
elif [ "$1" == "-x" ];
then
MOD_FILENAME=`latest`
MOD_MD5NAME=${MOD_FILENAME}.md5sum
VER="Latest Experimental"
else
MOD_FILENAME=${FNAME_PREFIX}${1}${FNAME_SUFFIX}
MOD_MD5NAME=${FNAME_PREFIX}${1}${MD5NAME_SUFFIX}
VER="${1}"
fi
cd /sdcard
echo "Deleting any previous update.zip..."
cleanup
# Download update ROM and MD5Sum
echo "Getting CyanogenMod ROM version $VER : ${MOD_FILENAME}"
echo
wget ${MIRROR}${EXPER}${MOD_FILENAME}
RES=$?
if [ ${RES} -ne 0 ];then
echo "Could not download ${MOD_FILENAME}"
echo "If you want to fetch an experimental version,"
echo "specify -x in the call to this script"
echo
echo "Nothing downloaded, exiting"
cleanup
exit
fi
# get the md5sum file
echo "Getting CyanogenMod ROM MD5 version $VER : ${MOD_MD5NAME}"
echo
wget ${MIRROR}${EXPER}${MOD_MD5NAME}
RES=$?
if [ ${RES} -ne 0 ];then
echo "Could not download ${MOD_MD5NAME}, exiting"
cleanup
exit
fi
# Verify downloaded ROM
echo "Checking ${MOD_FILENAME} MD5..."
MD5SUM_RESULT=`${MD5CMD} ${MOD_MD5NAME} | cut -d":" -f2 | grep OK`
echo " md5sum result : $MD5SUM_RESULT"
if [ ! -z $MD5SUM_RESULT ]
then
echo "${MOD_FILENAME} Downloaded Successfully"
mv ${MOD_FILENAME} ${SAVEFNAME}
rm ${MOD_MD5NAME}
echo "You may now reboot and flash"
else
echo "ERROR : ${MOD_FILENAME} Download Unsuccessful"
echo "Deleting bad download and exiting..."
cleanup
fi
So there it is...
I haven't try this yet but so far the only think I woudl ask for besides an GUI is to be able to know what versions are out there. What if i don't know what's the new version. i woudl have to go and check online. but if we have a command on the script to tell us the roms available it woudl be easier and great. I wouldn't even ask for a GUI then.
Rafase282 said:
I haven't try this yet but so far the only think I woudl ask for besides an GUI is to be able to know what versions are out there. What if i don't know what's the new version. i woudl have to go and check online. but if we have a command on the script to tell us the roms available it woudl be easier and great. I wouldn't even ask for a GUI then.
Click to expand...
Click to collapse
Until there is a way to do something like LucidREM has done with his script (such as lucid -u), I think your only options are
Subscribe to his Twitter page
Bookmark his server where his updates are stored.
Subscribe or check back frequently here on XDA.
I personally do all three.
beast.in.black said:
[*]Fetching Experimental builds: to fetch an experimental build from Cyanogen (Applicable from CyanogenMod v3.9 onwards), simply add the "-x" command line option to the script, after specifying the VERSION. Like so:
Code:
getcyan 3.9 -x
Click to expand...
Click to collapse
Recommendation
Add a "-t" for his testing builds as well.
They are not anywhere near as frequently used as experimental... but nonetheless it is still available on his server.
I added this on to the end so that the completed build would be flashed\
Code:
#Flash the Rom
echo "Rebooting and flashing update..."
echo "boot-recovery --update_package=SDCARD:update.zip" > /cache/recovery/command
reboot recovery
Sounds coll that you can do that, but still, I prefer making a backup first
This is amazing, thank you for making cyan updates even easier! Got it set up and running in no time!
Karolis said:
How about posting "a call to action" ir development and theme forums asking for all devs to use the same naming convention for their roms and themes + provide checksums.
Click to expand...
Click to collapse
Karolis, this is a great idea. I'll put the call to action out
spacezorro said:
I hacked mine to use...
So there it is...
Click to expand...
Click to collapse
spacezorro, you have already done what was on my roadmap for this script Thank you very much indeed. I am right now hacking the script up to recognize "latest" as a keyword and testing the changes now, and will update the script and post a fresh download (in the original post) once i've tested it out.
Rafase282 said:
What if i don't know what's the new version. i woudl have to go and check online. but if we have a command on the script to tell us the roms available it woudl be easier and great
Click to expand...
Click to collapse
Rafase282, I've put this on the roadmap as the next thing to work on.
Binary100100 said:
Recommendation
Add a "-t" for his testing builds as well.
They are not anywhere near as frequently used as experimental... but nonetheless it is still available on his server.
Click to expand...
Click to collapse
Excellent recommendation, will add it to the script.
indiekid97 said:
I added this on to the end so that the completed build would be flashed
Click to expand...
Click to collapse
Nice, will make it an option in the script to automatically reboot and flash if the md5sum checks out OK.
Thanks to everyone for all the great ideas
@cyanogen: Since you'll be adding this to your ROM, how do I keep you informed of changes to the script? PM you or something?
Okay. If this is not where the MODs want this post, please move it.
[UPDATE] - Jump over to Post #12 for some of my recent ideas and changes for this application.
I have been using mods for the G1 and the myTouch 3G for a little while now. I have used Backup for Root, and I use Nandroid. I created just a little simple script to backup your device to your linux-based machine and restore from there too. The concept behind this is having your backup on your computer, not your sd-card. Please, feel free to contribute. (If this is not your cup of tea, please do not leave a comment). I am limited on time, and wanted to contribute a little to the community. All this script is a compilation of adb commands. Anyone could compile these commands, I just wanted it organized and in one place.
README
After using all of the backup tools for root, I have ran into random FCs and bugs. This script uses Android SDK's adb tool and was designed to be simple. This script goes through and backs up your applications, bookmarks, sms, alarm clocks, settings, launcher settings and dictionary. There are plans for this script to be interactive in the future. As for now, it is a very basic script that will backup your device then restore your device.
Notes. As for now this script requires sudo. On every other linux pc tested, sudo was required (maybe because user did not install adb correctly?). This will change in future versions.
= Details =
REQUIREMENTS
1. Android SDK Toolkit 1.5 or higher
2. Bash v4.0.33
3. Root access to your device
4. Root access to your pc
HOWTO
Backing-Up
1. Plug your device in
2. Open command-line (On PC)
3. Run ./abrtool -b
4. Done.
Restoring
1. Reboot from flash of rom (Enter credentials and let phone setup first)
2. Open command-line (on PC)
3. Run ./abrtool -r
4. Restart device
5. Done
Changelog
Version 0.1.5
- Merged into Android-Linux-Tools (alt)
- Changed zenity commands (shows restore progress)
- Option to restart device after restore
- Can install abrtool via command-line (./abrtool --install)
Version 0.1.4
- Added Icons
- Runs Fix Permissions after restoration of applications
Version 0.1.3
- Fixed Restore (Again) - Sets $BACKUPDIR as $PATH
Version 0.1.2
- Restore applications now uses adb install instead of push
Version 0.1.1
- Fixed Restore arugement (-r restores now)
Version 0.1
- Created initial script
- Creates backups for Apps, Sms, Bookmarks, Alarms, Settings, User Dictionary, and Launcher
- Restores device
Download
Project Page for Android-Linux-Tools (ALT) http://code.google.com/p/android-linux-tools
Project Page for abrtool http://code.google.com/p/abrtool
Download abrtool ConvertVideoToAndroid
Download InstallOnAndroid Nautilus Script
InstallOnAndroid
Disclaimer
I am not responsible for anything. Anything at all. I'm just not. Blame someone else if something goes horribly wrong.
[Reserved]
[Reserved for future post]
Nice script but bart.sh can accomplish a full backup of your Android environment for restoration at a later date. While it does it to the SD card initially, these "barts" can easily be copied to any computer. I can, however, see a use for this as it serves a slightly different purpose. Thanks.
I wasn't sure what response I would get to this post. I have had to flash, partition, format, wipe.. enough times that I just wanted to plugin into my computer, backup, wipe-flash then restore. Thanks!
nice. I don't use linux myself, but i see the point of having the backup else where (not an SD card attached to the phone itself).
will this, in theory be made to work on windows? Cause that will be awesome.
@str4vag It would be really simple to just use a .bat file for Windows. I don't have any plans on making a windows script anytime soon. Sorry. Same commands especially though.
This is exactly what I've been looking for, now I just need to mod it to sync apps/bookmarks/etc automatically whenever I plug in my phone, and to only sync the new items to keep it speedy, great work dev!
@ggolemg I can play around with some "real" features soon. I plan on having it archive your backups and allow you to select which backup (default is most recent) you would like to use. I am sure I can play around with your idea too. Thanks.
subscribing to the thread, idea is very interesting. i've been looking for a foolproof way to backup and restore bookmarks, sms messages, and different alarms, without all the issues of backup for root users. gonna check out the script tonight.
Update coming by the end of the week.
- Will only backup apps not already backed up.
- Possibly apply the Python interface I have developed.
- More goodies.
How about switchrom?
Android-Linux-Tools
Okay, so this week has been crazy for me. (Mind you I am a restaurant manager first and a developer (primary web) second). I think I am going to gear this project in a different direction. First off, I have created GTK2 Dialogs and a settings panel for this application. I would like to gear towards general linux tools on the pc side. So over the next two weeks you can expect,
- Graphical Interface for abrtool (Android-Backup-Restore)
- Configuration for each application.
- Nautilus Scripts for all applications.
- Right-Click to Encode Video (With GTK2 Dialog progress)
- Right-Click to Install APK (With GTK2 Dialog progress)
- Right-Click to Sign APK (With GTK2 Dialog progress)
- Right-Click to Copy Files to SD Card
- abrtool will backup to Ubuntu One Cloud (Simple adb pull ~/Ubuntu\ One/? or maybe play with the API?)
Ideas and Possibilities
- User.conf editor
- Select with applications to backup
- Switchrom features?
Any other thoughts or suggestions are welcome. I want to start simple, keep working on the abrtool and then make my way out to some other useful tools for us linux (Ubuntu) users. Let me know what you think and what would be helpful.
i had to make a bynch of edits so this dosent run as root, id recomend everyone do the same, only run root when you must. Also changed ,.adb to adb so i dont have to run it in my android sdk dir
@ahronzombi Can you post those changes?
I am a firm believer of only running root when needed, Like I mentioned before I don't really have a huge amount of time, and when I tested this on a friends notebook adb required root to atleast kill-server then you could perform shell/push/pull.
AFAIK, adb server only requires root if ou haven't set the proper udev rules for the device.
Exactly. If we want this script to run universally we cannot rely on all users to have added the udev rules. If they don't they have to run sudo. Maybe a quick check for the udev file then sudo if not?
boulderjams said:
Exactly. If we want this script to run universally we cannot rely on all users to have added the udev rules. If they don't they have to run sudo. Maybe a quick check for the udev file then sudo if not?
Click to expand...
Click to collapse
no i think it would be wise to have people understand there udev permissions rather than run root so its universal. that kind of thinking leads to very big security problems. with root in the script most of the simplest linux users could exploit anyone
I fully understand that. Do you mind posting your changes to the script?
this is the secure version of the script that dosent run as root
keep in mind i set my own adb and home directorys so you'll have to change those
Code:
#! /bin/bash
# abrtool version 0.1
# Last Updated Wednesday, November 18, 2009
# Android Backup Data and Restore Data Script
#TODO
# 1- See if config file exists
# 2- If not, create config file (for now, select directory to backup to)
# 3- See if arguments are specified
# 4- If not, return an error via dialog
# 5- If argument -b exists, run backup
# 6- If argument -r exsists, run restore
export PATH=${PATH}:/home/ahron/android/android-sdk-linux/tools:/home/ahron/android/abr
BACKUPDIR=/home/ahron/android/backups
USER=${username-`whoami`}
backupscript() {
export PATH=$PATH:$BACKUPDIR
adb kill-server
adb pull /system/sd/app $BACKUPDIR/apps
adb pull /system/app $BACKUPDIR/apps/device
echo "---------- Backed Applications"
adb pull /data/data/com.android.providers.telephony/databases/mmssms.db $BACKUPDIR/msgs/mmssms.db
echo "---------- Backed Text Messages"
adb pull /data/data/com.android.browser/databases/browser.db $BACKUPDIR/bookmarks/browser.db
echo "---------- Backed Bookmarks"
adb pull /data/data/com.android.alarmclock/databases/alarms.db $BACKUPDIR/other/alarms.db
adb pull /data/data/com.google.android.providers.settings/databases/googlesettings.db $BACKUPDIR/other/googlesettings.db
adb pull /data/data/com.android.launcher/databases/launcher.db $BACKUPDIR/other/launcher.db
adb pull /data/data/com.android.providers.userdictionary/databases/user_dict.db $BACKUPDIR/other/user_dict.db
echo "---------- Backed Other Settings"
chown -R $USER $BACKUPDIR
zenity --info --text "Successfully Backed-up to $BACKUPDIR"
}
restorescript() {
export PATH=$PATH:$BACKUPDIR
adb kill-server
#sudo adb push $BACKUPDIR/apps /system/sd/app
echo "----------- Installing Applications"
cd $BACKUPDIR/apps
for searchfile in ./*.apk
do
echo "------------ Processing $searchfile"
sudo adb install "$searchfile"
done
echo "---------- Restored Applications"
adb shell su
adb shell fix_permissions
echo "---------- Fixed Application Permissions"
adb push $BACKUPDIR/msgs/mmssms.db /data/data/com.android.providers.telephony/databases/mmssms.db
echo "---------- Restored Messages"
adb push $BACKUPDIR/bookmarks/browser.db /data/data/com.android.browser/databases/browser.db
echo "---------- Restored Bookmarks"
echo "---------- (Please, make sure to restart your browser)"
adb push $BACKUPDIR/other/alarms.db /data/data/com.android.alarmclock/databases/alarms.db
adb push $BACKUPDIR/other/googlesettings.db /data/data/com.google.android.providers.settings/databases/googlesettings.db
adb push $BACKUPDIR/other/launcher.db adb pull /data/data/com.android.launcher/databases/launcher.db
adb push $BACKUPDIR/other/user_dict.db /data/data/com.android.providers.userdictionary/databases/user_dict.db
echo "---------- Restored Other Settings"
zenity --info --text "Successfully Restored Android device from $BACKUPDIR"
}
if [ "$#" -eq 0 ]
then
echo "Usage $0"
echo " -b Backup"
echo " -r Restore"
exit $E_OPTERR
fi
set -- `getopt "br:" "[email protected]"`
while [ ! -z "$1" ]
do
case "$1" in
-b) backupscript;;
-r) restorescript;;
esac
shift
done
okay so im creating a batch file for a little automation just mainly for rebooting the device into bootloader/recovery.. i have gotten most of the way through but at the end i would like for the batch file to stop and allow for further manual input (like i have it set to reboot the device into bootloader and then i would like the window to stop and allow me to MANUALLY input the next command such as flash/reboot/whatever) however i cant seem to find any way of doing that
HERE IS WHAT I HAVE CURRENTLY
it all works perfectly just for the issue i cant seem to work out
ECHO OFF
ECHO ============== CHANING DIRECTORY ==============
CD c:\program files (x86)\android\android-sdk\tools
TIMEOUT 2 /NOBREAK >nul
ECHO ........ Done
ECHO ============== CHECKING ADB DEVICE CONNECTION ==============
TIMEOUT 2 /NOBREAK >nul
adb devices
ECHO ........ Done
PAUSE
:MENU
ECHO.
ECHO ================== ADB MENU ==================
ECHO PRESS 1 or 2 to select your task, or 3 to EXIT.
ECHO.
ECHO 1 - Reboot Device into Bootloader [FASTBOOT]
ECHO 2 - Reboot Device into Recovery [CLOCKWORK MOD]
ECHO 3 - EXIT
ECHO.
SET /P M=Type 1, 2, or 3, then press ENTER:
IF %M%==1 GOTO BOOTLOADER
IF %M%==2 GOTO RECOVERY
IF %M%==3 GOTO EOF
:BOOTLOADER
adb reboot bootloader
GOTO FASTBOOT
:RECOVERY
adb reboot recovery
GOTO RECOVERY
:FASTBOOT
ECHO .
ECHO Waiting for device to reconnect
TIMEOUT 15 /NOBREAK >nul
ECHO ........ Done
ECHO ================== FASTBOOT ==================
ECHO manually type fastboot commands
:RECOVERY
ECHO .
ECHO Waiting for device to reconnect
TIMEOUT 15 /NOBREAK >nul
ECHO ........ Done
ECHO ================== RECOVERY ==================
ECHO Manually handle Clockwork Recovery tasks
ECHO .
ECHO .
ECHO Will automatically close in about 5 Seconds =]
TIMEOUT 5 /NOBREAK >nul
ECHO ....... bye!
I am not sur to understand exactly what you want to do, but you can do what you want in you batch file, it is what you did with for exemple :
- "Reboot Device into Bootloader [FASTBOOT]"
- "Reboot Device into Recovery [CLOCKWORK MOD]"
You have just check the choice with a number and after execute your "code".
So, if you know the "adb script" in addiction of the command you want, go to "code" it.
I remake your script and i especially add an exemple.
- "Execution" and "Code" are more clear.
- It is better for checking error.
- Now, this script is able to check if you are in "64bit" or "32bit", and check if the "ADB Tool" is in his correct way.
- Now, this script is able to check if you have connect or not your device.
- You can see the BootAnimation without "Power OFF" and then "Power ON" your phone.
- It is more beautiful, even if it is not very important.
The new "code", with your previous "started code" :
Code:
Even this topic is solved, i remove my code.
cheers for the reply.. but that was not really what i was after... i did some more googling and what i found was (in the last 2 minutes) that i needed a CMD /K at the end of the file.. which leaves the command window open and i can now enter in fastboot commands manually (for flashing etc)... i have attached the file as a.txt for anyone to use themselves if they were so inclined..
1. just make sure the directory of your adb/fastboot.exe is in the same directory as mine (CD c:\program files (x86)\android\android-sdk\tools) and change the 2 lines if necessary with note pad by opening the .txt normally as yours might be in program files or in platform-tools not tools, etc
2. change the extension to .bat and not .txt
3. chuck it in your task bar/start bar etc for quicker acess
and should be good to go =]
edit: i see the checking that the other fellow put it can do the checking for you.. but for me i knew the directory, etc
So, i did not exaclty understand your aim, but you have found it, so it is perfect.
I remake my previous script to do exactly what you want, and i always check every thing during the execution, to know the mistake when we have a problem. Because my version is for everybody, even if i think it is just for us. (Views: 45)
So if you want it, or someone else, just ask me.
ptit developer said:
So, i did not exaclty understand your aim, but you have found it, so it is perfect.
I remake my previous script to do exactly what you want, and i always check every thing during the execution, to know the mistake when we have a problem. Because my version is for everybody, even if i think it is just for us. (Views: 45)
So if you want it, or someone else, just ask me.
Click to expand...
Click to collapse
no worries mate it was my first time writing an entire script so im pretty stoked with the outcome i tried to keep it looking as real as scripts i have seen as possible.. =]
I will continue to develop this idea : "A easy way to use ADB Menu".
When i will have finish, if you want i will post a link here to it.
ptit developer said:
I will continue to develop this idea : "A esay way to use ADB Menu".
When i will have finish, if you want i will post a link here to it.
Click to expand...
Click to collapse
sure mate.. ill edit the op if you like and can sort something out?
i think the simpler nature allows for much to be automated for mundane tasks... as long as you keep the fastboot commands manual so noobs dont do anything incorrect
I will use what you want, and i will add what i post in my first answer here.
In addition of this, i will post the final "A easy way to use ADB Menu" on a new topic on other section.
And i will post news here, because i think you will look it.
Most Android ROMs use toolbox as primary binary with symlinks in /system/bin and /system/xbin. The problem with toolbox is that it sucks. On some ROMs it's even so limited that it does not even allow for --prefix
Busybox is a great replacement for toolbox, but in order to use it, you have to call it using 'busybox cmd'. I would much rather use it by calling 'cmd' but this would execute toolbox instead of busybox.
Most would think the command 'busybox --install' would fix this, but it does'nt. It tries to install links at /bin and /sbin.
The script below will replace any toolbox links in /system/bin and /system/xbin that is supported by the busybox version installed on the Android device running the script. This will make busybox the default binary when executing regular commands without adding 'busybox' at the beginning of the command.
For an example 'ls' instead of 'busybox ls'
Download as an update.zip
v1.3.0 (Nov 17, 2012) (MD5: c233964f0f62a16d7376739041e8b250) - busybox_installer.zip (Only for ArmV7 devices)
v1.3.0 (Nov 17, 2012) (MD5: e921a6c4119644a18d4feea565824ab1) - busybox_installer-nobin (Without binaries)
busybox.sh
Code:
#!/sbin/sh
for cmd in test find basename readlink ln rm; do
eval export "_$cmd=\"/sbin/busybox $cmd\""
done
_busybox=$($_find /system -type f -name "busybox")
_toolbox=$($_find /system -type f -name "toolbox")
if $_test -e "$_busybox" && $_test -e "$_toolbox"; then
sToolboxList="watchprops wipe vmstat date uptime reboot getevent getprop setprop id iftop ioctl ionice log lsof nandread newfs_msdos notify ps r schedtop sendevent setconsole setprop sleep smd start stop top"
sBusyboxList="`$_busybox --list`"
for applet in $sBusyboxList; do
if $_test -L /system/bin/$applet; then
if $_test "`$_basename $($_readlink -f /system/bin/$applet)`" = "toolbox"; then
$_ln -sf $_busybox /system/bin/$applet
if $_test -L /system/xbin/$applet; then
$_rm -rf /system/xbin/$applet
fi
fi
elif $_test -L /system/xbin/$applet; then
if $_test "`$_basename $($_readlink -f /system/xbin/$applet)`" = "toolbox"; then
$_ln -sf $_busybox /system/xbin/$applet
fi
elif ! $_test -e /system/bin/$applet && ! $_test -e /system/xbin/$applet; then
$_ln -sf $_busybox /system/bin/$applet
fi
done
for applet in $sToolboxList; do
$_ln -sf $_toolbox /system/bin/$applet
done
fi
Toolbox install links
watchprops, wipe, vmstat, date, uptime, reboot, getevent, getprop, setprop, id, iftop, ioctl, ionice, log, lsof, nandread, newfs_msdos, notify, ps, r, su, schedtop, sendevent, setconsole, setprop, sleep, smd, start, stop, top
Busybox install links
Whatever the currently installed busybox supports that is not in the list of toolbox install links
Change log
Dec 10 2011, 21:39 UTC:
The script will now leave skip replacing /system/bin/reboot as it needs to be pointed at toolbox
Dec 11 2011, 10:08 UTC:
Added an update zip that will configure busybox and it provides an extended 1.4MB binary instead of the regular 480KB most ROM's provide
Dec 12 2011, 09:25 UTC:
Added new busybox build (1.20.0.git 2011-12-11) since there was problem with the old one for some people
Added more busybox search dirs (/system/sbin and /sbin)
Added Toolbox install to make sure that some android specific links uses toolbox instead of busybox. See list above.
Jun 27 2012, 13:45 UTC:
Better Busybox and Toolbox search
Added symlink check to make sure that busybox only replaces toolbox links and not things like "sh -> mksh"
Nov 17 2012, 10:30 UTC:
Added a custom toolbox binary to the ArmV7 installer
Added latest CM9 busybox binary to the ArmV7 binary
Added an auto search function to locate the binaries on the device
Fixed both installers to work with newer devices that uses EXT4 file system
Thanks, dk_zero-cool. I've been looking for a guide to installing BusyBox, since I can only find an add-supported installer in the Android Market.
Thanks, nice job!!
Ran the script, worked and did fine....ONE BIG ISSUE....now if you have any script or app that relies on the "reboot" function, it no longer works. For example, rom manager & bootstrapper will not boot into recovery. I even open up terminal and typed:
Code:
$ su
# reboot
...and nothing...does the reboot in /bin need to not be linked to busybox?
KMDonlon said:
Ran the script, worked and did fine....ONE BIG ISSUE....now if you have any script or app that relies on the "reboot" function, it no longer works. For example, rom manager & bootstrapper will not boot into recovery. I even open up terminal and typed:
Code:
$ su
# reboot
...and nothing...does the reboot in /bin need to not be linked to busybox?
Click to expand...
Click to collapse
Try to relink it back to toolbox and then I will update the script to leave reboot alone.
1: mount -o remount,rw /system
2: rm -r /system/bin/reboot
3: ln -s /system/bin/toolbox /system/bin/reboot
Great! Will try again!
Cool... can I steal this?
I'd implement it with a busybox install script
I'm not a super expert on the subject but is /system/sbin a possible location?
zeppelinrox said:
Cool... can I steal this?
I'd implement it with a busybox install script
I'm not a super expert on the subject but is /system/sbin a possible location?
Click to expand...
Click to collapse
You can use this as you like.
And you can type "echo $PATH" in an adb shell, if /system/sbin is there, then it will work. But why? /system/xbin is usually the default dir for placing busybox, otherwise /system/bin. And you will have to change the script since it will only check in /system/bin and /system/xbin
All times in my scripts report UTC time instead of system time, I am sure there is one other applet in /bin that was linked to toolbox that is now linked to busybox and reporting the date wrong or at least the date/time that busybox says (UTC time).
KMDonlon said:
All times in my scripts report UTC time instead of system time, I am sure there is one other applet in /bin that was linked to toolbox that is now linked to busybox and reporting the date wrong or at least the date/time that busybox says (UTC time).
Click to expand...
Click to collapse
Do the same as before, only this time replace 'reboot' with 'date'
This must be a setting in the busybox compile menu. A new binary might fix this because busybox should be able to display system time. But for now point date back to toolbox and it will work for you.
Yup, did what you just said and all is fine. Thanks! Is there a way you can implement the reboot and date applet ignore in the script within the .zip you made.... I think it will save users some headaches.
dk_zero-cool said:
You can use this as you like.
And you can type "echo $PATH" in an adb shell, if /system/sbin is there, then it will work. But why? /system/xbin is usually the default dir for placing busybox, otherwise /system/bin. And you will have to change the script since it will only check in /system/bin and /system/xbin
Click to expand...
Click to collapse
Well bb is sometimes installed elsewhere.
At first SuperCharger only looked in those 2 locations and stopped when it wasn't found.
What would happen if there was a second version elsewhere?
I suppose it wouldn't matter because of the symlinks.
KMDonlon said:
Yup, did what you just said and all is fine. Thanks! Is there a way you can implement the reboot and date applet ignore in the script within the .zip you made.... I think it will save users some headaches.
Click to expand...
Click to collapse
The reboot fix is already in the zip file.
The date fix I don't want in it, I would much rather fix busybox to work properly.
I'm currently looking at that.
zeppelinrox said:
Well bb is sometimes installed elsewhere.
At first SuperCharger only looked in those 2 locations and stopped when it wasn't found.
What would happen if there was a second version elsewhere?
I suppose it wouldn't matter because of the symlinks.
Click to expand...
Click to collapse
No that does not mater because of the symlinks.
That's why I referrer to the complete path, f.eks, "/system/xbin/busybox" and not just the binary name "busybox".
I am going to try your binary for Busybox and see, I am currently using JRummy's BB installer which installed v1.19.3 which is about 1.06MB....
EDIT: Just flashed the .zip, my phone will not boot past the logo....did a battery pull several times and can't get into CWR....SBF time
KMDonlon said:
I am going to try your binary for Busybox and see, I am currently using JRummy's BB installer which installed v1.19.3 which is about 1.06MB....
EDIT: Just flashed the .zip, my phone will not boot past the logo....did a battery pull several times and can't get into CWR....SBF time
Click to expand...
Click to collapse
Put in your USB cable, open a terminal/console on your computer and try "adb logcat" to see what it says when it stops booting.
You must of cause have adb installed on your computer, and USB drivers if you use windows, which I don't and cant help with.
Already reflashed phone back....sorry, no logcat....
Do it again...
C'mon take one for the team... hehe...
LMFAO!!!! Sorry dude, I ain't gonna do it....will let some other poor soul ....I got honey do's today, it's Sunday!!
Whatever it was I can't recreate it. Works fine when I flash the damn thing.
Here's a thought.....make a script that reverses the toolbox links, I can undo it and try to flash again....I was unable to manually install your busybox version so I think some other toolbox applet is causing me trouble.....
I have been trying to customise my MTK phones with a pre-defined user experience, with sepcific settings etc.
Perhaps one way to achieve this is to check if the device has been facory reset, then use a script to insert specific settings once. For this I need to launch a script early in the boot sequence.
This could be achieved by dismantling the boot.img, altering the init.rc, then re-building, which requires significant work and risks bricking the device. So I looked for a way to run a script without significant re-flashing. here goes:
xlog changes the system log level, and is called just a few times at boot-up. Xlog is run early, and as root, with the parameter boot.
This script renames xlog as xlogboot, introduces a script in place of xlog, which runs another script, startup.sh when xlog is called with parameter boot. All the original parameters are passed to the renamed xlog binary, so the system functionality should not be changed.
I pushed the script to the device, then run it as root. I can now edit /system/bin/startup.sh to run whatever initialisation commands I wish. I have so far tested on a ZTE v965 .
Code:
#!/system/bin/sh
#This script creates a hook into the bootup system of Android
#This hook operates when /system/bin/xlog is called with
#the first parameter 'boot'
#Use this script entirely at your own risk. I highly recommend
#you ensure YOU have a backup of YOUR device before going further
#Public Domain Nick Hill 2014
if [ -e /system/bin/xlogboot ] || [ -e /system/bin/startup.sh ]; then
echo "This script may have already been run, exiting.."
exit 1
fi
if [ ! -e /system/bin/xlog ]
then
echo "This script is not running in an expected environment. Exiting.."
exit 2
fi
if [ $USER != "root" ]
then
echo "This script must be run as root. try running su. Exiting.."
exit 3
fi
touch /system/bin/atestfile
if [ ! -e /system/bin/atestfile ]
then
echo "It appears system folder is not mounted read-write. Remounting..."
mount -o remount,rw /system
else
rm /system/bin/atestfile
fi
echo -e '#!/system/bin/sh\n' > /system/bin/startup.sh
chown root:root /system/bin/startup.sh
chmod 755 /system/bin/startup.sh
mv /system/bin/xlog /system/bin/xlogboot
echo -e '#!/system/bin/sh\n/system/bin/xlogboot $*\nif [ "$1" == "boot" ] \nthen\n/system/bin/startup.sh\nfi\n' >/system/bin/xlog
chown root:shell /system/bin/xlog
chmod 755 /system/bin/xlog
Enjoy!
Make your own custom rom
Problem: You have an android device which you want to give/sell in USA or England. The device has come with an array of auto-starting chinese pop-ups, horrible wallpaper, and a Chinese clock applet. You uninstall all those system apps, replace your widgets with nice English ones. The phone when factory reset, starts in Chinese. Returns the user to tacky wallpaper, and you have lost the nice theming and widgets you have painstakingly installed and set up in the system folder.
Solution: This backup script. I have tested it on a v965, it also appears the file system would be OK on an A766 and many other android devices.
Instructions:
Use my previous script on this thread to create a hacked startup sequence. You must already have the /system/bin/startup.sh in place.
Unpack the tarball
Check the script lists the files you intend to back up. You will need to edit the script for that. I have set it to preserve settings for language, launcher, the 3D clock app factory.widgets.ThreeDDigitalWeatherClock-1.apk , which I think is really cool, wallpaper and the ADB mode.
Copy the install.sh and busybox to a writable directory on your android device.
su (go to root)
In a shell, cd to the directory where you uploaded the files.
sh install.sh
This will create a directory /system/perm-config
When you have the device as you would like it,
cd /system/perm-config
./make-backup.sh
This will ceate a directory tree in /system/perm-config/data folder, containing the backups of specific app data.
If all goes well, next time the phone is factory reset, the defaults are reloaded.
You could then re-flash the system partition of devices, perform a factory reset to take the device to your own defaults. You can use the last script (to hack the startup sequence), and this script to make your own custom ROMs. The script should do it's job even after un-rooting a device.
As usual, use at your own risk. I take no responsibility if your phone bricks, explodes, turns to antimatter, suddenly drops into a parallel dimension or starts receiving calls from the future.