[Script] Simple tar backup and restore for devs [FINISHED!] - Epic 4G Android Development

To all of the ROM makers here, please stop using those bonsai data-backup/data-restore scripts, as they don't work. I'm assuming they used to work since everyone here seems to be using them, but something has changed (maybe something in CWM 5.x?) and now all those data-backup and data-restore scripts do is make phones not work.
I've taking those scripts and rewritten them using the tar command. busybox's tar doesn't have many options, but it does preserve file permissions and ownership, so it makes for an adequate backup tool. HUGE thanks to SenseiSimple for the ideas and improvements. See SenseiSimple's post, here.
EDIT: Here is the final version!
updater-script BACKUP EXAMPLE
Code:
ui_print("************************************************");
ui_print(" TAR BACK UP / RESTORE EXAMPLE");
ui_print("************************************************");
show_progress(1.000, 0);
set_progress (0.100);
#EXTRACT BACKUP SCRIPT
ui_print("Preparing tools...");
package_extract_file("tools/busybox", "/tmp/busybox");
package_extract_file("tools/tar-backup", "/tmp/tar-backup");
set_perm(0, 0, 0755, "/tmp/tar-backup");
set_perm(0, 0, 0755, "/tmp/busybox");
#CREATE BACKUP
set_progress (0.350);
ui_print("Backing up - this may take a while...");
run_program("/sbin/mount","/sdcard");
run_program("/sbin/mount","/data");
run_program("/tmp/tar-backup","backup");
unmount("/data");
#RECOVER BACKUP
set_progress (0.600);
ui_print("Recovering backed up data...");
run_program("/sbin/mount","/data");
run_program("/tmp/tar-backup","recover");
# run_program("/tmp/tar-backup","recover","delete");
# run_program("/tmp/tar-backup","recover","archive");
unmount("/data");
set_progress(1.000);
show_progress(1.000, 0);
tar-backup script
edit the value of ROMName=YourROMName (you should only have to edit this file once for all your ROM versions, it's not version-dependent), that's it.
Code:
#!/tmp/busybox sh
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# License GPLv2+: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>
#
# toadlife, SenseiSimple, XDA Community, Bonsai
# invoke with
# run_program("/tmp/tar-backup","backup");
# run_program("/tmp/tar-backup","recover" [,"delete"|"archive"]);
# - "delete" option deletes the backup file
# - "archive" option renames the backup file for archiving (otherwise, it is left alone and replaced on next backup/flash)
ROMName=MyAwesomeROM
platbuild=EI22
PATH=/tmp:/sbin:$PATH
datadir=/data
backdir=/sdcard/ROMBackup-$platbuild
backfile=$backdir/$ROMName.tgz
TEST="busybox test"; TAR="busybox tar"; MKDIR="busybox mkdir"
if [ "$1" = "backup" ]; then
rm /data/dalvik-cache/*
rm /data/lost+found/*
rm $backfile
if $TEST -d $datadir ; then
$TEST ! -d $backdir && $MKDIR $backdir
$TAR pczf $backfile $datadir
if $TEST $? -ne 0 ; then
echo "Backup failed!"; exit 1
else
echo "Backup completed"; exit 0
fi
fi
elif [ "$1" = "recover" ]; then
if $TEST -f $backfile; then
$TAR pxzf $backfile
if [ "$2" = "delete" ]; then
rm $backfile;
elif [ "$2" = "archive" ]; then
archdate=`date +%Y%m%d-%I%M`
archfile=$backdir/$ROMName-$archdate.tgz
mv $backfile $archfile
fi
echo "Restore Completed!"; exit 0
else
echo "Restore failed!"; exit 1
fi
else
echo "Backup - Invalid argument"; exit 1
fi
Example CWM package (unsigned) that uses the script.

BTW, I have tested this script several times with test builds of my ROM and also tested it going from SleeperROM 1.x to my ROM. In sleeper ROM I started with blank slate, installed a few apps, configured my email and set a wallpaper. I then installed a test build of my ROM CleanGB with this backup restore script and I had no problems after flashing; all of my data and settings, including the apps in /data from sleeper ROM came over.

Thank you for this. I proposed this to ERA for Legendary and also to the Bonsai crew.
Sent from my SPH-D700 using XDA App

UNIFIED BACKUP SCRIPT - INSTRUCTIONS/DIFFERENCES
SUMMARY The motivation is threefold, as Toadlife initiated with the purpose of modernizing the backup scripts to better protect the data file attributes in backup by using Tar rather than streaming to Cpio, it's possible with adding this improvement to add new functionality and prevent cluttering up users' sdcards with various ROM folders/editions. They will now all be located by ROM name (i.e. SleeperROM, CleanGB, StarskyROM, RandomROM, LegendaryROM *.tgz) in the /sdcard/ROMBackup-EI22/*.tgz directory.
In your ROM package
1. REPLACE /tools/data-backup and /tools/data-restore
2. WITH /tools/tar-backup (script below)
3. UPDATE ROMName=CleanGB with your rom name
in your updater-script, replace
Code:
package_extract_file("tools/data-backup", "/tmp/data-backup");
package_extract_file("tools/data-restore", "/tmp/data-restore");
set_perm(0, 0, 0755, "/tmp/data-backup");
set_perm(0, 0, 0755, "/tmp/data-restore");
with
Code:
package_extract_file("tools/tar-backup", "/tmp/tar-backup");
set_perm(0, 0, 0755, "/tmp/tar-backup");
updater-script USAGE:
1. REPLACE: run_program("/tmp/data-backup");
2. WITH run_program("/tmp/tar-backup", "backup");
3. REPLACE: run_program("/tmp/data-restore");
4a. WITH run_program("/tmp/tar-backup", "recover"); - Leave the backup in place, will be overwritten in the future
4b. OR run_program("/tmp/tar-backup", "recover","delete"); To delete the backup file when complete
4c. OR run_program("/tmp/tar-backup", "recover","archive"); To archive (with date) the backup file when complete
MINIMAL updater-script BACKUP EXAMPLE
Code:
ui_print("************************************************");
ui_print(" TAR BACK UP / RESTORE EXAMPLE");
ui_print("************************************************");
show_progress(1.000, 0);
set_progress (0.100);
#EXTRACT BACKUP SCRIPT
ui_print("Preparing tools...");
package_extract_file("tools/busybox", "/tmp/busybox");
[B]package_extract_file("tools/tar-backup", "/tmp/tar-backup");[/B]
[B]set_perm(0, 0, 0755, "/tmp/tar-backup");[/B]
set_perm(0, 0, 0755, "/tmp/busybox");
#CREATE BACKUP
set_progress (0.350);
ui_print("Backing up - this may take a while...");
run_program("/sbin/mount","/sdcard");
run_program("/sbin/mount","/data");
[B]run_program("/tmp/tar-backup","backup");[/B]
unmount("/data");
#RECOVER BACKUP
set_progress (0.600);
ui_print("Recovering backed up data...");
run_program("/sbin/mount","/data");
[B]run_program("/tmp/tar-backup","recover");
# run_program("/tmp/tar-backup","recover","delete");
# run_program("/tmp/tar-backup","recover","archive");[/B]
unmount("/data");
set_progress(1.000);
show_progress(1.000, 0);
FILE: /tools/tar-backup
edit the value of ROMName=YOURROMNAME (you should only have to edit this file once for all your ROM versions, it's not version-dependent), that's it.
Code:
#!/tmp/busybox sh
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# License GPLv2+: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>
#
# toadlife, SenseiSimple, XDA Community, Bonsai
# invoke with
# run_program("/tmp/tar-backup","backup");
# run_program("/tmp/tar-backup","recover" [,"delete"|"archive"]);
# - "delete" option deletes the backup file
# - "archive" option renames the backup file for archiving (otherwise, it is left alone and replaced on next backup/flash)
[B]ROMName=CleanGB[/B]
platbuild=EI22
PATH=/tmp:/sbin:$PATH
datadir=/data
backdir=/sdcard/ROMBackup-$platbuild
backfile=$backdir/$ROMName.tgz
TEST="busybox test"; TAR="busybox tar"; MKDIR="busybox mkdir"
if [ "$1" = "backup" ]; then
rm /data/dalvik-cache/*
rm /data/lost+found/*
rm $backfile
if $TEST -d $datadir ; then
$TEST ! -d $backdir && $MKDIR $backdir
$TAR pczf $backfile $datadir
if $TEST $? -ne 0 ; then
echo "Backup failed!"; exit 1
else
echo "Backup completed"; exit 0
fi
fi
elif [ "$1" = "recover" ]; then
if $TEST -f $backfile; then
$TAR pxzf $backfile
if [ "$2" = "delete" ]; then
rm $backfile;
elif [ "$2" = "archive" ]; then
archdate=`date +%Y%m%d-%I%M`
archfile=$backdir/$ROMName-$archdate.tgz
mv $backfile $archfile
fi
echo "Restore Completed!"; exit 0
else
echo "Restore failed!"; exit 1
fi
else
echo "Backup - Invalid argument"; exit 1
fi
Example CWM package (unsigned) to augment these instructions - pay attention to your version of Busybox vs the one included.

SenseiSimple said:
Thanks, i'll be giving it a spin for the next release!
I'm wondering, should we perhaps standardize the directory the backups go into and name the actual backup file accordingly?
I for one hate my sd card filling up with a bunch of random folders, backups included. (i know this is trivial, but since you've provided a good change to the backup method...)
will put the backup into /sdcard/EI22_ROM_Backup/CleanGB.tgz
since we don't automatically delete the backup, i assume for precautionary reasons, best for them to pile up in one place, no?
Click to expand...
Click to collapse
Couldn't agree more. Seems like I'm constantly cleaning backup files off my sdcard.

Why not delete the backup file after the restore? Otherwise a flashaholic will have a whole bunch of these files on their card as well as their nandroids, titanium backups, ROMs, pics etc. Just add a delete to the script.

kennyglass123 said:
Why not delete the backup file after the restore? Otherwise a flashaholic will have a whole bunch of these files on their card as well as their nandroids, titanium backups, ROMs, pics etc. Just add a delete to the script.
Click to expand...
Click to collapse
That's my mentality on it. But in case something goes wrong with the restore, maybe, you have the whole backup file to dissect? that was the only reason i could think of to keep all the cruft in which case, at least have them all consolidated.

I will definitely include this in my rom. Thanks
Sent from my SPH-D700 using XDA App

SenseiSimple said:
That's my mentality on it. But in case something goes wrong with the restore, maybe, you have the whole backup file to dissect? that was the only reason i could think of to keep all the cruft in which case, at least have them all consolidated.
Click to expand...
Click to collapse
Everyone should already be making a nandroid before flashing anything and then can always use advanced restore data. My issue is until you start looking at your sd card, you don't know ROMs have left backups behind. Nuke em...lol.

SenseiSimple said:
Thanks, i'll be giving it a spin for the next release!
I'm wondering, should we perhaps standardize the directory the backups go into and name the actual backup file accordingly?
I for one hate my sd card filling up with a bunch of random folders, backups included. (i know this is trivial, but since you've provided a good change to the backup method...)
(my edits in bold)
Click to expand...
Click to collapse
Sounds good to me. Putting them both in one script would be easier too. I'll use the second revision. You could allways pass another varible to the script to tell it weather or not to delete the backup.

SenseiSimple said:
That's my mentality on it. But in case something goes wrong with the restore, maybe, you have the whole backup file to dissect? that was the only reason i could think of to keep all the cruft in which case, at least have them all consolidated.
Click to expand...
Click to collapse
Ten years sysadminning had led me to be extremely wary of deleting data, so I'm always inclined to keep backups.

Ten years sysadminning had led me to be extremely wary of deleting data, so I'm always inclined to keep backups.
Click to expand...
Click to collapse
I know that personally if something messed up with the re-install phase of the flashing, i'd want the backup file to still be available... it would be nice to have a unified backup dir, and maybe even an option in CWM to delete backups left by roms - it becomes somewhat of a redundancy of CWM's backup at that point, but it's not as if we can invoke the CWM backup routine from script anyway...
toadlife said:
Sounds good to me. Putting them both in one script would be easier too. I'll use the second revision. You could allways pass another varible to the script to tell it weather or not to delete the backup.
Click to expand...
Click to collapse
i deleted my script from the post, on testing, i just can't get it to run - in theory it's a great idea - the single script file is sound but running it from the updater_script with run_program("/tmp/data_save","backup"); for example, just doesn't run it... i've tried variations using
run_program("/sbin/sh","/tmp/data_save","backup");
run_program("/tmp/busybox","sh","/tmp/data_save","backup");
each are no-go...
individually, the scripts work... is there a limitation that the only way run_program can pass arguments is to a binary and not a shell script? that's all i can think of
EDIT:
I GOT IT, will post up the revision in a moment

SenseiSimple said:
EDIT:
I GOT IT, will post up the revision in a moment
Click to expand...
Click to collapse
Crud. I just posted updated version at the top that contains a variable to control deletion of the backup file.
Can you update the script to take a variable that controls whether or not the backup file gets deleted?

It may be worthwhile to add the current date to the filename - it keeps the current backup and restore for a flash fresh, but allows archival copies to be trivially stored ala Nandroid.

k0nane said:
It may be worthwhile to add the current date to the filename - it keeps the current backup and restore for a flash fresh, but allows archival copies to be trivially stored ala Nandroid.
Click to expand...
Click to collapse
This could be done right after the restore finishes...if the file is not set to be deleted...
Code:
date=`date +.%m.%d.%Y.%I:%M`;
newromname={$romname}{$date}
newbackfile=/sdcard/${build}_ROM_Backup/$newromname.tgz
mv $backfile $newbackfile

SenseiSimple said:
EDIT:
I GOT IT, will post up the revision in a moment
Click to expand...
Click to collapse
Sorry, I got impatient and rolled them into one script myself. It tags the files with the date if the delete option is not set. The script is in the first post.

toadlife said:
To all of the ROM makers here, please stop using those bonsai data-backup/data-restore scripts, as they don't work. I'm assuming they used to work since everyone here seems to be using them, but something has changed (maybe something in CWM 5.x?) and now all those data-backup and data-restore scripts do is make phones not work.
I've taking those scripts and rewritten them using the tar command. busybox's tar doesn't have many options, but it does preserve file permissions and ownership, so it makes for an adequate backup tool.
EDIT: I've rewritten the scripts so that both backup and restore functionality are in one script. Thanks SenseiSimple for the idea!
tar-backup
Code:
#!/tmp/busybox sh
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# License GPLv2+: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>
#
#
# tar data backup and restore
# based on bonsai data backup/restore scripts
# by toadlife , SenseiSimple and the Epic 4G XDA community
#
# Call from your updater script like so...
#
# Backup: run_program("/tmp/tar-backup", "backup");
# Restore: run_program("/tmp/tar-backup", "restore"[, "delete"]);
#
# optional "delete" switch will cause the backup file to be deleted after
# restore
#
#
romname=CleanGB
build=EI22
datadir=/data
PATH=/tmp:/sbin:$PATH
BB=/tmp/busybox
backfile=/sdcard/${build}_ROM_Backup/$romname.tgz
if [ "$1" = "backup" ]; then
$BB rm /data/dalvik-cache/*
$BB rm /data/lost+found/*
$BB rm $backfile
if $BB test -d $datadir; then
$BB test ! -d /sdcard/${build}_ROM_Backup && $BB mkdir /sdcard/${build}_ROM_Backup
$BB tar pczf $backfile $datadir
if $BB test $? -ne 0; then
echo "Backup failed!"
exit 1
else
echo "Backup completed"
exit 0
fi
fi
fi
if [ "$1" = "restore" ]; then
if $BB test -f $backfile; then
$BB tar pxzf $backfile
echo Restore Completed!
if [ "$2" = "delete" ]; then
rm $backfile
else
DATE=`date +%Y.%m.%d.%I%M`;
newromname=$romname.$DATE
newbackfile=/sdcard/${build}_ROM_Backup/$newromname.tgz
mv $backfile $newbackfile
fi
exit 0
else
echo Restore failed!
exit 1
fi
fi
Here is an example package that uses the script.
Click to expand...
Click to collapse
From looking at it, it doesn't look like there should be issues... Nice work!
and with the improved handling of tarballs through CWM, this thing should be nice and fast! =)

Your version still didn't work for me, same issue i was facing with mine.
I updated post #4 with an updated version based on a combination of yours and the one i was late providing, i've tested it several times with the three options.
What are you thoughts? Try it out and if it works update your code detail with it, my mini-tutorial can be linked complementary to it
EDIT I just remembered/experienced that CWM (5.0.2.7 afaik) has a bug in which it doesn't provide the right datetime. So the archive feature may be broken until that is fixed. http://forum.xda-developers.com/showthread.php?p=19689193#post19689193 - mine shows several years off "jan 01, 2005 01:00" and the archives overwrite themselves... perhaps we need to serialize/number rather than date

SenseiSimple said:
Your version still didn't work for me, same issue i was facing with mine.
Click to expand...
Click to collapse
What issue? It worked great for me.
SenseiSimple said:
EDIT I just remembered/experienced that CWM (5.0.2.7 afaik) has a bug in which it doesn't provide the right datetime. So the archive feature may be broken until that is fixed. http://forum.xda-developers.com/showthread.php?p=19689193#post19689193 - mine shows several years off "jan 01, 2005 01:00" and the archives overwrite themselves... perhaps we need to serialize/number rather than date
Click to expand...
Click to collapse
IIRC, Jan 1 2005 is the date you get when you pull the battery. Apparently it resets the internal clock on the device. When doing a normal reboot or power down the current date is retained.
Anyhow, yours looks fine. I'll test it out later today and will edit my top post with your revision.

toadlife said:
What issue? It worked great for me.
IIRC, Jan 1 2005 is the date you get when you pull the battery. Apparently it resets the internal clock on the device. When doing a normal reboot or power down the current date is retained.
Anyhow, yours looks fine. I'll test it out later today and will edit my top post with your revision.
Click to expand...
Click to collapse
Cool thanks, sorry for the delay. about the time, i had indeed recently pulled the battery without booting in between.
The issue i had with my original script and yours was something to do with busybox applets/builtins between /tmp/busybox and /sbin/busybox... i'm not sure what version of busybox i had included with my rom, but i substituted mine with yours (mine was 1.9MB which i've noticed in a few different roms, yours and the one in ICS releases are 2MB), and for good measure combined our two scripts, everything magically came together, oddly enough with the combined script, both busybox versions work.

Related

[UTIL] a2sd Updated script w/ error checking! 10/12/09

**New version in the works. See last page for my post**
**Updated 5:51pm CST**
-Made sweeping changes to the script. Thanks Farmatito for the suggestions. Output from script also goes to adb logcat
-See script for additional changelog
**Updated 11:00am CST**
-Changed a couple "cp" commands to "ln" as this is a smarter way of doing it. Script has been updated and re-uploaded
After having issues with the current a2sd script floating around (under certain environments the script would erase all user & system apps) I decided to update it so that there is proper error checking, logging, and back-out procedures on failure. The log is stored in /data/a2sd.log so if you get stuck at a black screen or it won't boot, now you can check the log and find out where its failing! By the way, if your phone won't boot or you have a black screen obviously the only way you can read the log is by connecting the phone to a pc and using adb shell cat /data/a2sd.log .
Anyways here it is, enjoy.
Procedure
Code:
adb remount
adb shell cp /system/bin/a2sd /system/bin/a2sd.bak
adb shell push a2sd.txt /system/bin/a2sd
adb shell chmod 777 /system/bin/a2sd
adb shell reboot
Everything should work like before. But you can rest at night knowing if your phone won't boot you now have a way to know if it was related to a2sd and what the cause was
**NOTE: If you get stuck at the boot screen it's probably b/c your /system/sd partition is failing the fsck. You should probably fsck it on your own to fix any corruption. If you don't want the fsck then comment it out of the script.
Very cool, lets hope a developer picks this up and uses it.
bubonik said:
Very cool, lets hope a developer picks this up and uses it.
Click to expand...
Click to collapse
I could toss this in my next build if the masses like it (sure they will)
I was going to read through this and give a full opinion but it is too long for me to do it this late. My eyes are crossing trying to read it. But at first glance it looks good (logs are always good right ). And I've never seen shafty not do good work. I'll try to look it over in full tomorrow. Plus you've inspired me to try to think of same way to contribute to this file. So now I have to put that on my todo list.
miketaylor00 said:
I was going to read through this and give a full opinion but it is too long for me to do it this late. My eyes are crossing trying to read it. But at first glance it looks good (logs are always good right ). And I've never seen shafty not do good work. I'll try to look it over in full tomorrow. Plus you've inspired me to try to think of same way to contribute to this file. So now I have to put that on my todo list.
Click to expand...
Click to collapse
O hell yea, mike the masters on it!
miketaylor00 said:
I was going to read through this and give a full opinion but it is too long for me to do it this late. My eyes are crossing trying to read it. But at first glance it looks good (logs are always good right ). And I've never seen shafty not do good work. I'll try to look it over in full tomorrow. Plus you've inspired me to try to think of same way to contribute to this file. So now I have to put that on my todo list.
Click to expand...
Click to collapse
The more the merrier. It's too bad everyone doesn't have bash installed or we'd be able to take advantage of all the features bash includes (functions, advanced iteration loops, arithmetic).
That would be on all the ROM devs to include it though. Oh and I'm a UNIX Admin so writing shell scripts is like 60% of my job. We try and make our lives easier by writing scripts to do the work for us
shafty023 said:
The more the merrier. It's too bad everyone doesn't have bash installed or we'd be able to take advantage of all the features bash includes (functions, advanced iteration loops, arithmetic).
That would be on all the ROM devs to include it though. Oh and I'm a UNIX Admin so writing shell scripts is like 60% of my job. We try and make our lives easier by writing scripts to do the work for us
Click to expand...
Click to collapse
I figured you did something like that. Your scripts are always good. I've learned a lot from reading through stuff that you have posted. I wish I had your experience with it. I always have to fumble through to find the right syntax to do what I want to do.
miketaylor00 said:
I figured you did something like that. Your scripts are always good. I've learned a lot from reading through stuff that you have posted. I wish I had your experience with it. I always have to fumble through to find the right syntax to do what I want to do.
Click to expand...
Click to collapse
Ya I started out fumbling around just as well. Keep at it and if you ever have any questions about how to do something feel free to PM me. Shell scripting, among the other 10 programming languages I code in fluently, come second nature after years of coding in them. Java/C/C++/Sh/Bash/Lisp/Javascript/Html/Php/Jquery.
shafty023 said:
Ya I started out fumbling around just as well. Keep at it and if you ever have any questions about how to do something feel free to PM me. Shell scripting, among the other 10 programming languages I code in fluently, come second nature after years of coding in them. Java/C/C++/Sh/Bash/Lisp/Javascript/Html/Php/Jquery.
Click to expand...
Click to collapse
Sweet, i will probably take you up on that offer sometime. I have a question about running e2fsck. I always run it with the -f option because it seems like it never finds problems unless they are really bad if I don't. Would there be a problem running it in your a2sd with -fy? I've always wondered why no one uses the -f option.
miketaylor00 said:
Sweet, i will probably take you up on that offer sometime. I have a question about running e2fsck. I always run it with the -f option because it seems like it never finds problems unless they are really bad if I don't. Would there be a problem running it in your a2sd with -fy? I've always wondered why no one uses the -f option.
Click to expand...
Click to collapse
Well there's two sides to this. One could argue we should force a fsck at every boot, and then the other side is to let Android mark the partition as dirty so fsck will run only when needed. Normally the filesystem is supposed to be marked dirty if in fact it is dirty.
So if we force a fsck at every boot then that would add to the boot time of the OS but then again would ensure the filesystem isn't corrupted. It's really personal preference. It breaks down to "Speed of boot" vs "filesystem integrity"
I can't even find a2sd in cm4.1.999. Seems to have gone missing. Anyone know if it exists, and if so, where it's at?
overground said:
I can't even find a2sd in cm4.1.999. Seems to have gone missing. Anyone know if it exists, and if so, where it's at?
Click to expand...
Click to collapse
The default location is /system/bin/a2sd . If it's not there not sure where else it could be hidden at
shafty023 said:
The default location is /system/bin/a2sd . If it's not there not sure where else it could be hidden at
Click to expand...
Click to collapse
That's where it should be and used to be. I looked in the original zip and it's not there either. Checked sbin and xbin and other places where it also shouldn't be, and can't find it...weird.
overground said:
That's where it should be and used to be. I looked in the original zip and it's not there either. Checked sbin and xbin and other places where it also shouldn't be, and can't find it...weird.
Click to expand...
Click to collapse
Perhaps it was integrated into the swap file. And I don't mean swap file as in the literal swap file. I mean /system/bin/swap which is a conf file & shell script in one. I would check there to see if it was incorporated in there.
Hi,
just some comments about the "monster" a2sd script. ;-)
Hope they will help you to imprrove it further.
I would suggest to change the logging so that
it could be seen during a adb logcat of the boot process, from:
echo "Beginning a2sd `date`" >$LOG;
to e.g:
echo "Beginning a2sd `date`" | busybox tee -a $LOG;
(LOG must be initialized if it not exists)
Line 40:
e2fsck -y /dev/block/mmcblk0p2;
if [ $? -ne 0 ];
then
echo "Fail" >>$LOG;
exit 1;
fi;
else
echo "Ok" >>$LOG;
fi;
# set property with exit code in case an error occurs
setprop cm.e2fsck.errors $?;
Setprop is not executed in case of errors as we do exit. Is this intended?
Line 144:
# don't allow /data/data on sd because of upgrade issues - move it if possible
if [ -d /system/sd/data ];
then
echo -n "Found /system/sd/data which is a no-no, removing: " >>$LOG;
busybox cp -a /system/sd/data/* /data/data/;
busybox rm -rf /system/sd/data;
echo "Ok" >>$LOG;
fi;
I suggest cp -ap to preserve permissions and ownership of the copied files
I suggest to mv /system/sd/data to /system/sd/data.bak if cp fails
rather than rm all the data
Line 195:
if [ `ls -l /data/$i/ | wc -l` -ne 0 ];
then
echo -n "Moving /data/$i: " >>$LOG;
busybox cp -a /data/$i/* /system/sd/$i/;
if [ $? -ne 0 ];
then
echo "Fail" >>$LOG;
busybox umount /system/sd;
exit 1;
else
echo "Ok" >>$LOG;
fi;
fi;
I suggest to use cp -ap to preserve permissions and ownership
Line 206:
echo -n "Deleting contents in /data/$i: " >>$LOG;
busybox rm -f /data/$i/*;
I suggest rm -fR /data/$i;
Line 329:
if [ -f /system/lib/hw/lights.msm7k.so ] && [ ! -e /system/lib/hw/lights.trout.so ];
then
busybox cp /system/lib/hw/lights.msm7k.so /system/lib/hw/lights.trout.so;
fi;
if [ -f /system/lib/hw/copybit.msm7k.so ] && [ ! -e /system/lib/hw/copybit.trout.so ];
then
busybox cp /system/lib/hw/copybit.msm7k.so /system/lib/hw/copybit.trout.so;
fi;
if [ -f /system/lib/hw/sensors.msm7k.so ] && [ ! -e /system/lib/hw/sensors.trout.so ];
then
busybox ln -s /system/lib/hw/sensors.msm7k.so /system/lib/hw/sensors.trout.so;
fi;
I suggest to use ln for all.
Line 353:
/system/bin/sh /system/bin/swap;
Cannot find /system/bin/swap on my rom, maybe
if [ -e /system/bin/swap ] ; then.
shafty023 said:
The default location is /system/bin/a2sd . If it's not there not sure where else it could be hidden at
Click to expand...
Click to collapse
update-cm-4.1.99-signed/system/etc/init.d/04apps2sd
farmatito said:
update-cm-4.1.99-signed/system/etc/init.d/04apps2sd
Click to expand...
Click to collapse
Thank you...knew it had to be in there. Love your work, BTW.
echo "Beginning a2sd `date`" >$LOG;
to e.g:
echo "Beginning a2sd `date`" | busybox tee -a $LOG;
Click to expand...
Click to collapse
Unfortunately during boot anything thrown to console is not caught by adb logcat, BUT! You gave me a good idea, it will now look like this
Code:
/system/bin/logwrapper echo "Beginning a2sd `date`";
# set property with exit code in case an error occurs
setprop cm.e2fsck.errors $?;
Click to expand...
Click to collapse
Removed
Line 144:
# don't allow /data/data on sd because of upgrade issues - move it if possible
if [ -d /system/sd/data ];
then
echo -n "Found /system/sd/data which is a no-no, removing: " >>$LOG;
busybox cp -a /system/sd/data/* /data/data/;
busybox rm -rf /system/sd/data;
echo "Ok" >>$LOG;
fi;
I suggest cp -ap to preserve permissions and ownership of the copied files
I suggest to mv /system/sd/data to /system/sd/data.bak if cp fails
rather than rm all the data
Click to expand...
Click to collapse
Great catch, this has been changed
Line 195:
if [ `ls -l /data/$i/ | wc -l` -ne 0 ];
then
echo -n "Moving /data/$i: " >>$LOG;
busybox cp -a /data/$i/* /system/sd/$i/;
if [ $? -ne 0 ];
then
echo "Fail" >>$LOG;
busybox umount /system/sd;
exit 1;
else
echo "Ok" >>$LOG;
fi;
fi;
I suggest to use cp -ap to preserve permissions and ownership
Click to expand...
Click to collapse
Changed
Line 206:
echo -n "Deleting contents in /data/$i: " >>$LOG;
busybox rm -f /data/$i/*;
I suggest rm -fR /data/$i;
Click to expand...
Click to collapse
This was already being done in the following FOR loop but after inspecting further I merged the app symlinks FOR loop with this IF statement.
Line 329:
if [ -f /system/lib/hw/lights.msm7k.so ] && [ ! -e /system/lib/hw/lights.trout.so ];
then
busybox cp /system/lib/hw/lights.msm7k.so /system/lib/hw/lights.trout.so;
fi;
if [ -f /system/lib/hw/copybit.msm7k.so ] && [ ! -e /system/lib/hw/copybit.trout.so ];
then
busybox cp /system/lib/hw/copybit.msm7k.so /system/lib/hw/copybit.trout.so;
fi;
if [ -f /system/lib/hw/sensors.msm7k.so ] && [ ! -e /system/lib/hw/sensors.trout.so ];
then
busybox ln -s /system/lib/hw/sensors.msm7k.so /system/lib/hw/sensors.trout.so;
fi;
I suggest to use ln for all.
Click to expand...
Click to collapse
This change has already been made and I uploaded a new script earlier today.
Line 353:
/system/bin/sh /system/bin/swap;
Cannot find /system/bin/swap on my rom, maybe
if [ -e /system/bin/swap ] ; then.
Click to expand...
Click to collapse
Added.
Thanks for all your suggestions, I will re-upload a new version in an hour or so soon as I get a chance to change the echo commands to use logwrapper. Well I'm keeping the existing echo commands which spit output to my log but will also add another which will spit output to logcat.
miketaylor00 said:
Sweet, i will probably take you up on that offer sometime. I have a question about running e2fsck. I always run it with the -f option because it seems like it never finds problems unless they are really bad if I don't. Would there be a problem running it in your a2sd with -fy? I've always wondered why no one uses the -f option.
Click to expand...
Click to collapse
I take it back, after having suffered yet another file system corruption on my /system/sd partition I'm putting that darn "-f" in there. I'll re-upload a new copy with other changes shortly
Posted a new copy of the a2sd script with lots of changes. Check it out everyone. As always suggestions & questions are welcome

[DEV][SCRIPT] Enhanced init.d support

Okay, I worked a bit on something to add a little more options to init.d scripts for my ROM's. I came up with the below solution and thought I should share it with whomever would like a bit more options in their own ROM's. This is a first draft so some of things can properly be done in other ways, but it works and it does add a lot more options when building startup scripts while it is compatible with regular init.d scripts as well. But fell free to pitch in with ideas if you like.
Note that this thread is directed to ROM cookers, but can be used by anyone that knows how to edit ramdisk's.
So there are several problems with the regular init.d methods. First of all there are two different ways of executing the scripts and it differs from ROM to ROM which method has been implemented. We have the "exec /system/bin/sysinit" which will execute all of the scripts before continuing with the normal boot and we have the service sysinit which will execute all scripts while the normal boot is running. Both are useful for different things but no ROM has both.
Also init.d will just start executing the scripts before/during the normal boot, depended on the method, but what if we need it to execute something at a specific time during boot. Before folder structures and such are created in /data? Or when the phone has completely booted into the GUI. Or before the phone is turned off and so on.
This method will implement different states where different parts of a script can be executed depended on where in the boot process we are. All it requires is a more extended sysinit file and a couple of extra lines in the init.rc file.
File: /init.rc
Code:
on early-init
##
# Whatever goes here
##
on init
##
# Whatever goes here
##
on fs
##
# Mount /system
##
# Make sure that we have the synlinks we need to use sysinit
symlink /system/bin/sysinit /system/bin/sysinit.onstart
symlink /system/bin/sysinit /system/bin/sysinit.onfs
symlink /system/bin/sysinit /system/bin/sysinit.onpostfs
symlink /system/bin/sysinit /system/bin/sysinit.onpostfsdata
symlink /system/bin/sysinit /system/bin/sysinit.onboot
symlink /system/bin/sysinit /system/bin/sysinit.onsysinit
symlink /system/bin/sysinit /system/bin/sysinit.onfinalize
symlink /system/bin/sysinit /system/bin/sysinit.oncomplete
symlink /system/bin/sysinit /system/bin/sysinit.onshutdown
exec /system/bin/sysinit.onstart
##
# Mount the rest of the partitions and remount /system without write permissions
##
exec /system/bin/sysinit.onfs
on post-fs
##
# Whatever goes here
##
exec /system/bin/sysinit.onpostfs
on post-fs-data
##
# Whatever goes here
##
exec /system/bin/sysinit.onpostfsdata
##
# If you want to include an additional *.rc file, do it here at the end of post-fs-data
##
on boot
##
# Whatever goes here
##
exec /system/bin/sysinit.onboot
start sysinit
##
# Start any other services
##
on property:init.svc.bootanim=stopped
start syscomplete
on property:sys.boot_completed=1
exec /system/bin/sysinit.onfinalize
on property:sys.shutdown.requested=1
exec /system/bin/sysinit.onshutdown
service sysinit /system/bin/sysinit.onsysinit
disabled
oneshot
service syscomplete /system/bin/sysinit.oncomplete
disabled
oneshot
##
# The rest of the file
##
File: /system/bin/sysinit
Code:
#!/system/bin/sh
export PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
if [ -d /system/etc/init.d ]; then
case $(basename $0) in
"sysinit") INIT_STATE="$1" ;;
*) INIT_STATE="`basename $0 | cut -d '.' -f2`" ;;
esac
while :
do
if [ ! -f /sysinit.stage.prop ]; then
mount -o remount,rw /
touch /sysinit.stages.prop
mount -o remount,ro /
fi
if ( [ "$INIT_STATE" != "onfinalize" ] && [ "$INIT_STATE" != "oncomplete" ] ) || ( [ "$INIT_STATE" = "onfinalize" ] && [ ! -z "`grep onpostsysinit /sysinit.stages.prop`" ] ) || ( [ "$INIT_STATE" = "oncomplete" ] && [ ! -z "`grep onfinalize /sysinit.stages.prop`" ] ); then
if [ "$INIT_STATE" = "onsysinit" ]; then
RUN_STATES="onsysinit onpostsysinit"; sleep 1
elif [ "$INIT_STATE" = "oncomplete" ]; then
RUN_STATES="onservice oncomplete"
else
RUN_STATES="$INIT_STATE"
fi
for x in $RUN_STATES; do
log -p v -t sysinit "Switching to state '$x'..."
case $x in
# Make it compatible with old init scripts
onboot|"") FILES="`find /system/etc/init.d -type f | sort`" ;;
*) FILES="`find /system/etc/init.d -type f -iname '*.rc' | sort`" ;;
esac
for i in $FILES; do
if [ ! -d $i ] && [ -x $i ]; then
log -p v -t sysinit "Executing $i..."
if [ "$x" = "onservice" ]; then
logwrapper $i $x > /dev/null &
else
logwrapper $i $x
fi
else
log -p w -t sysinit "Skipping $i. Not an executable!"
fi
done
mount -o remount,rw /
echo $x >> /sysinit.stages.prop
mount -o remount,ro /
done
break
fi
sleep 1
done
fi
To use this you need to end the names of your init script with .rc like "55<name>.rc" instead of just "55<name>". This is to keep it compatible with regular init.d scripts.
This will allow you to build init.d scripts like this
Code:
#!/system/bin/sh
case $1 in
onstart)
# Do something right after the system partition has been mounted RW (No other partitions at this time)
;;
onfs)
# Do something right after the rest of partitions has been mounted and system has been remounted RO, before any of them are used or changed in any way.
;;
onpostfs)
# This is almost the same as onfs, only minor changes has normally been made here
;;
onpostfsdata)
# Do something after the /data partition has been rebuild with folders, permission, ownership and so on
;;
onboot)
# Do something right before Android starts booting and it's services are triggered
;;
onsysinit)
# Do something while Android is booting. This will NOT stall the boot process but run along side it
;;
onpostsysinit)
# Do something as soon as onsysinit has finished
;;
onfinalize)
# Do something when the system is almost booted, this also includes the sysinit parts above
;;
onservice)
# Do some constant work in the background (Service/Daemon)
;;
oncomplete)
# Do something when the phone is fully booted and the boot animation is gone
;;
onshutdown)
# Do something before the phone is turned off or rebooted
;;
esac
EDIT 1
Added 'onfinalize' which is actually the old oncomplete. The new oncomplete runs as a service like onsysinit and onpostsysinit to ensure that you are able to use things like "sleep" without stalling the system.
Rewrote sysinit, much cleaner now
EDIT 2
Added 'onservice' which can be used to run a constant task in the background after the phone has booted
Great concept and great work
I can see how this would be very handy!
Sent from my PG86100 using Tapatalk 2
looks intresting..Hmmmmm
Genius man. Awesome stuff.
Sent from my SCH-I500 using Tapatalk 2
Awesome great work. The last line say do comething before the phone is turned off or rebooted. is it suppose to say something.
Sent from my HTC Desire CDMA using Tapatalk 2
jayallen1980 said:
Awesome great work. The last line say do comething before the phone is turned off or rebooted. is it suppose to say something.
Sent from my HTC Desire CDMA using Tapatalk 2
Click to expand...
Click to collapse
'something' is correct, have been changed
Some examples would be good
Can you please? (Example of Executing Juwe's RAM script will be nice in all cases)
What if I want to keep init.d folder empty and integrate my scripts inside boot.img? and then execute them inside it?
varun.chitre15 said:
Some examples would be good
Can you please? (Example of Executing Juwe's RAM script will be nice in all cases)
What if I want to keep init.d folder empty and integrate my scripts inside boot.img? and then execute them inside it?
Click to expand...
Click to collapse
Why would you integrate scripts into the boot.img? The point of init.d is to be able to add things to boot without changing the boot.img. If you want to execute things from within the boot.img, then just place your scripts in it (sbin would be a good place) and execute it the same way my example executes /system/bin/sysinit.
And as for examples, it's easy. Just place your code in that section (onboot, onfs etc) where you want the code to be executed. The onboot is the default in process in most ROM's and also where regular init.d scripts is executed in this example.
dk_zero-cool said:
Why would you integrate scripts into the boot.img? The point of init.d is to be able to add things to boot without changing the boot.img. If you want to execute things from within the boot.img, then just place your scripts in it (sbin would be a good place) and execute it the same way my example executes /system/bin/sysinit.
And as for examples, it's easy. Just place your code in that section (onboot, onfs etc) where you want the code to be executed. The onboot is the default in process in most ROM's and also where regular init.d scripts is executed in this example.
Click to expand...
Click to collapse
because the point of this is to start scripts when you want.. there is a few scripts I have that can't be ran until os is loaded, there for making this a great setup for me.
init.d & boot.img runs everything at boot... not after boot.
eugene373 said:
because the point of this is to start scripts when you want.. there is a few scripts I have that can't be ran until os is loaded, there for making this a great setup for me.
init.d & boot.img runs everything at boot... not after boot.
Click to expand...
Click to collapse
The 'oncomplete' runs everything when the system is fully loaded, that's the point of this init.d system, to be able to run scripts in different ways during different stages.
dk_zero-cool said:
The 'oncomplete' runs everything when the system is fully loaded, that's the point of this init.d system, to be able to run scripts in different ways during different stages.
Click to expand...
Click to collapse
yeah I got it..... I've been having one hell of a time starting script until I cam across this...
If it starts like a normal init.d file it hangs the boot process... with this edit I can trigger it to run on bootcomplete with out hanging the service
sorry, I just noticed I quoted you and not the other guy
eugene373 said:
yeah I got it..... I've been having one hell of a time starting script until I cam across this...
If it starts like a normal init.d file it hangs the boot process... with this edit I can trigger it to run on bootcomplete with out hanging the service
sorry, I just noticed I quoted you and not the other guy
Click to expand...
Click to collapse
Yes oncomplete, oninit and onservice will not stall the process, oninit will however stall onfinalize, oncomplete and onservice. onservice will run the script in a seperate process in the background, so that will not even stall the rest of the init.d scripts while executing, making that great for scripts that should keep running, or where you don't know how long they should run.
dk_zero-cool said:
Yes oncomplete, oninit and onservice will not stall the process, oninit will however stall onfinalize, oncomplete and onservice. onservice will run the script in a seperate process in the background, so that will not even stall the rest of the init.d scripts while executing, making that great for scripts that should keep running, or where you don't know how long they should run.
Click to expand...
Click to collapse
Adding this into all my boot.img from now on & I'll be sure to link this thread...
I think this should be the new standard for all Devs, this method is not only a great idea!
But for the End User, there's so much more control over what can / should be done on starting process...
I personally want to thank you for this, as this truely is one of the better methods I've ever seen!!
~Eugene
dk_zero-cool, I'd like to ask you, why you use soft-links and not parameters?
It will remove all
Code:
symlink /system/bin/sysinit /system/bin/sysinit.*
from init.rc and you will not need to use case in sysinit.
Because this whole construction:
Code:
case $(basename $0) in
"sysinit") INIT_STATE="$1" ;;
*) INIT_STATE="`basename $0 | cut -d '.' -f2`" ;;
esac
seems to me like overload.
hashnon said:
dk_zero-cool, I'd like to ask you, why you use soft-links and not parameters?
It will remove all
Code:
symlink /system/bin/sysinit /system/bin/sysinit.*
from init.rc and you will not need to use case in sysinit.
Because this whole construction:
Code:
case $(basename $0) in
"sysinit") INIT_STATE="$1" ;;
*) INIT_STATE="`basename $0 | cut -d '.' -f2`" ;;
esac
seems to me like overload.
Click to expand...
Click to collapse
Because I have had bad experience using arguments along with the exec command, so I try to avoid that. Mostly because I can't remember the issues anymore.
As for overload, this is to small to be noticed, specially when this is only executed a couple of times during startup. If this was to be executed every couple of minute during the phone on state, then sure. But when the phone has booted, sysinit is no longer used.
Pretty neat design. I've found that having to deal with some of the escaping of an exec can be a nightmare too.
In the kernel ramdisk of my Xperia ray, there are two kinds of inits, init.rc and init.semc.rc.
The "on fs" exists in init.semc.rc (where i can see the commands to mount the partitions). In init.rc there's no "on fs" between "on early-fs" and "on post-fs".
So i've put the "on fs"-part in init.semc.rc and the rest of your fabulous work into init.rc. When i look after booting into the /system/bin/ directory i can see all the "sysinit.on........." symlinks. Is that proof that i did everything right so far? Haven't tried any script yet to be honest.
Kaskade said:
In the kernel ramdisk of my Xperia ray, there are two kinds of inits, init.rc and init.semc.rc.
The "on fs" exists in init.semc.rc (where i can see the commands to mount the partitions). In init.rc there's no "on fs" between "on early-fs" and "on post-fs".
So i've put the "on fs"-part in init.semc.rc and the rest of your fabulous work into init.rc. When i look after booting into the /system/bin/ directory i can see all the "sysinit.on........." symlinks. Is that proof that i did everything right so far? Haven't tried any script yet to be honest.
Click to expand...
Click to collapse
Yes some phones have extra init files for onfs. Mostly if they use different file system types. What you did is correct in this case.
You can check the file /sysinit.stages.prop to see if all stages was executed. If one stage is missing from that file, it was not executed.
Deleted.
hi is ths still working in android marshmallow? cant find sysinit file in system/bin/sysinit

[MOD][SCRIPTS] Boot Script Utilities

About this thread
In this thread i will post my work on a init.d like support for stock rom which i call "Boot Script Utilities".
This work was developed for personal use and for my personal purposes.
If you do not like to use it please do not.
Click to expand...
Click to collapse
Just to be clear
I am not responsible for whatever happens to your phone.
Some Info
What is init.d?
Init.d is a folder located in "/system/etc/init.d/", but not all roms have his folder (stock rom don't have the folder).
What is special with this folder is that any script inside this folder will run on phone boot.
Why to run scripts on boot?
On boot many system variables are initiated before any application run, so you can make automatic tweaks on every boot.
ex. Swap external storage to internal.
Click to expand...
Click to collapse
Boot Script Utilities on stock Samsung Galaxy Core
This was developed for personal use. This is not the original init.d support.
I developed a similar support in order to implement some more features.
This do not means that this is a better way to roon scripts on boot.
What do i need?
A rooted Samsung Galaxy Core (I used I8260, for how to root search the forum)
A good root explorer (well Root Explorer worked)
A recovery with backup/restore support (to backup your rom in case you soft brick your phone)
What we will do?
We will edit a system file to run a script i wrote. This script will run all scripts (or not all read more below) inside /system/etc/init.d/ folder.
Step 0 - Backup your rom
Boot into your recovery and make a backup.
Step 1 - init.d folder
Create a directory on "/system/etc/" and name it "init.d".
So now directory "/system/etc/init.d/" exist.
Step 2 - Boot Script Utilities main script
Copy "init.bsu.boot.sh" file (link on the end of the post) in "/system/etc/".
So now file "/system/etc/init.bsu.boot.sh" exist.
Step 3 - Edit system file, run Boot Script Utilities
The system file we will edit is "/system/etc/init.qcom.post_boot.sh"
Insert this code on the bottom of the script
Code:
# Run Boot Script Utilities
# For galaxy core stock rom
# by DarkThanos
/system/bin/sh /system/etc/init.bsu.boot.sh > /data/tmp/init.bsu.log 2>&1 &
Step 4 - Ready
Insert your scripts inside "/system/etc/init.d/" and whey will run on boot.
Click to expand...
Click to collapse
Boot Script Utilities features
Disable all scripts
If file "/system/etc/init.d/disabled" exist no script will run.
Disable scripts
Any script named like "*.disabled" or "*.disabled.sh" will not run.
ex. "/system/etc/init.d/testscript.disabled.sh" will not run.
Run scripts asynchronous
Any script named like "*.async" or "*.async.sh" will run asynchronous.
ex. "/system/etc/init.d/testscript.async.sh" will run asynchronous.
Scripts run order
Scripts run in name order.
Log on every boot
All scripts results-errors output (stdout/stderr) will be printed on "/data/tmp/init.bsu.log"
Click to expand...
Click to collapse
[Change log]
1.0 Version
Script Public for first time.
init.d like support
Click to expand...
Click to collapse
[Dev Doc]
It does not really matters from where the script is called.
The script first checks if boot is completed, if not it sleeps for 2 seconds.
(so you need to call the script after boot, or before but asynchronous)
Code:
# Get boot complete state
isBootCompleted=`getprop dev.bootcomplete`
# Wait For boot complete event
# Probably useless unless script called from other file
while [ "$isBootCompleted" -ne '1' ]
do
# Wait and check again
sleep 2
# Check if boot completed
isBootCompleted=`getprop dev.bootcomplete`
done
The next step is to check if "/system/etc/init.d/disabled" file exist.
If it do not exist, it will run all not disabled scripts inside "/system/etc/init.d/".
It will check every file inside and analyze its name so it knows if the script is disabled or asynchronous.
Code:
# Create a init.d Support
# Implement /system/etc/init.d/ folder
# Check if init.d is disabled
# If /system/etc/init.d/disabled file exist, then init.d is disabled
if [[ ! -f /system/etc/init.d/disabled ]]
then
echo "[$manager_name] Initiating init.d scripts"
# Run every script on init.d folder
for scriptfile in /system/etc/init.d/*
do
if test -f "$scriptfile"
then
# Get script name
scriptname=$(basename $scriptfile)
# Check if script is disabled
# ex1 : 'testscript.sh.disabled' is disabled
# ex1 : 'testscript.disabled.sh' is disabled
echo "$scriptname" | grep -q -E '\.(disabled|disable\.sh)$'
if [ $? -eq 0 ]
then
echo "[$manager_name] Script $scriptname is disabled"
else
# check if script is asynchronous
# ex1 : 'testscript.sh.async' is asynchronous
# ex2 : 'testscript.async.sh' is asynchronous
echo "$scriptname" | grep -q -E '\.(async|async\.sh)$'
if [ $? -eq 0 ]
then
echo "[$manager_name] Run Script $scriptname asynchronous"
/system/bin/sh "$scriptfile" | script_log &
else
echo "[$manager_name] Run Script $scriptname"
/system/bin/sh "$scriptfile" | script_log
fi
fi
fi
done
else
echo '[$manager_name] init.d is disabled'
fi
That's all.
Please suggest any fixes or any improvements by messaging me.
Thanks for your time.
Click to expand...
Click to collapse
All Scripts
Links to all scripts posts
Optimize apks using ZipAlign
Optimize SQlite databases of apps
Swap External SD with Internal SD
Click to expand...
Click to collapse
[Script][Swap External SD with Internal SD][v1.0]
Name : Swap External SD with Internal SD
Version : v1.0
Author : DarkThanos
Thanks to: codlab
Click to expand...
Click to collapse
This script wait for your external sd card to be mounted and swap it with internal if it is bigger.
One minute after boot it will stop waiting.
(Fastest swap method I found)
I am not responsible for whatever happens to your phone.
Tested on my Samsung Galaxy Core (I8260)
[Change log]
1.0 Version
Script Public for first time.
Swap internal sd with external (if external>internal)
Click to expand...
Click to collapse
[Dev Doc]
The script first creates 2 directories to mount external sd and internal sd,
so that it can distinguish them from each other ("/data/sd_cards/internal/", "/data/sd_cards/external/").
Code:
# Mount root rw
mount -o remount,rw /
# Create directory to mount sd cards
# Make directory to save cards
mkdir -p /data/sd_cards
# Make directory to save internal
mkdir -p /data/sd_cards/internal
# Make directory to save external
mkdir -p /data/sd_cards/external
In the next step, the script waits for an external sd to be mounted.
This wait time is the reason why the script is better to be asynchronous.
The script checks every 5 seconds for an external sd, but after 1 minute (12 tries) it stops.
Code:
# Wait for external sd card to be mounted
# Max wait time is 1 minute
maxWaitTime=60
# While external Sd Card has 0 Capacity
while [[ $(du -s /storage/extSdCard | awk '{print $1}') == "0" && $maxWaitTime>0 ]]
do
# Check again in 5 seconds
sleep 5
# Count down max wait time
maxWaitTime=maxWaitTime-5
done
As soon as an external sd is mounted, the script mounts the external sd on "/data/sd_cards/external/"
and the internal on "/data/sd_cards/internal/".
Code:
# Save mount points on folders
# Mount bind internal SD in folder /data/sd_cards/internal
mount -o bind /storage/sdcard0 /data/sd_cards/internal
# Mount bind external SD in folder /data/sd_cards/external
mount -t vfat -o rw,nosuid,nodev,noexec,relatime,user_id=1023,group_id=1023,default_permissions,allow_other /dev/block/vold/179:33 /data/sd_cards/external
So now the real internal sd can be found in the directory "/data/sd_cards/internal/"
and the real external sd can be found in the directory "/data/sd_cards/external/".
The reason we do this is to be able to make a script swap them again.
Then it checks the size of each, so that it knows if it ia worthing of swapping them.
Code:
# Get sd cards sizes
internalSdSize=$(du -s /storage/sdcard0 | awk '{print $1}')
externalSdSize=$(du -s /storage/extSdCard | awk '{print $1}')
If external sd is bigger, then on "/storage/sdcard0/" we mount "/data/sd_cards/external/"
and on "/storage/extSdCard/" we mount "/data/sd_cards/internal/".
Code:
# Swap sd cards
# If external sd card is bigger than internal swap
if [ $externalSdSize -gt $internalSdSize ]
then
# Swap
mount -o bind /data/sd_cards/internal /storage/extSdCard
mount -o bind /data/sd_cards/external /storage/sdcard0
fi
Click to expand...
Click to collapse
[Script][Optimize SQlite databases of apps][v1.0]
Name : Optimize SQlite databases of apps
Version : v1.0
Rewritten by : DarkThanos
Based on work of: pikachu01
Click to expand...
Click to collapse
This script optimize applications' database using sqlite3 (Vacuum/Reindex) every 5 boots or 5 days.
On any other boot it optimize only databases of phone, contacts, mms and settings .
Before use make a folder "libs" inside "/system/etc/init.d/",
insert the "sqlite3" file inside and give it execute permissions (the file is given with the script)
Bugs: (Its safe for use, its a warning not an error)
Contacts database is always locked, so can't be optimized.
I am not responsible for whatever happens to your phone.
Tested on my Samsung Galaxy Core (I8260)
[Change log]
1.0 Version
Script Public for first time.
SQlite databases on "/data/" optimize every 5 boots or 5 days.
SQlite databases of phone, contacts, mms and settings optimize on every boot.
Click to expand...
Click to collapse
[Dev Doc]
Script first initiate some variables
(path to Sqlite lib, path to a folder to save scripts data, minimum time between optimizes)
Code:
# Some variables
# SQLite path
sql_lib="/system/etc/init.d/libs/sqlite3";
# Data folder path
data_folder="/data/boot_scripts_data/";
# Data counter file name
data_file_counter="sql_optimize_counter";
# Data last run file name
data_file_lastrun="sql_optimize_lastrun";
# Max time between optimizes (in sec)
# 5 days = $(expr 5 \* 24 \* 60 \* 60 )
max_time_dif=432000
Check how many boots passed since last optimize
and when the last optimize was by reading scripts data.
Code:
# Create data folder if not exist
mkdir -p "$data_folder"
# Get data from files
# Run Counter
if [[ ! -f "$data_folder$data_file_counter" ]]
then
# File do not exist
touch "$data_folder$data_file_counter"
echo "0" > "$data_folder$data_file_counter"
runCount="0"
else
runCount=$(cat $data_folder$data_file_counter)
fi
# Last run date
if [[ ! -f "$data_folder$data_file_lastrun" ]]
then
# File do not exist
touch "$data_folder$data_file_lastrun"
echo "0" > "$data_folder$data_file_lastrun"
lastRun=0
else
lastRun=$(cat $data_folder$data_file_lastrun)
fi
If boots passed since last optimize equals with 5 or last optimized more than 5 days before,
then make a full database optimization.
Code:
# Check if its time for optimize
if [ $(( $(date +%s) - $lastRun )) -ge $max_time_dif -o $runCount -ge 5 ]; then
echo "Full mode optimize"
# Save data
echo "0" > "$data_folder$data_file_counter"
echo $(date +%s) > "$data_folder$data_file_lastrun"
# Optimize /data/
optimize_folder "/data/"
echo "All applications' databases were optimized"
Else make a light optimize.
(only phone, contacts, mms and settings)
Code:
else
echo "Light mode optimize"
# Save data
echo $((runCount+1)) > "$data_folder$data_file_counter"
# Only for Galaxy Core
# Count databases optimized
count=0
# phone optimize
optimize_folder "/data/data/com.android.phone/databases/"
# contacts optimize
optimize_folder "/data/data/com.android.providers.contacts/databases/"
# mms optimize
optimize_folder "/data/data/com.android.mms/databases/"
# email optimize
optimize_folder "/data/data/com.android.mms/databases/"
# settings optimize
optimize_folder "/data/data/com.android.settings/databases/"
echo "Important databases were optimized"
fi;
Optimize functions
Code:
# Some functions
# Optimize db
optimize_db(){
# Vacuum and then reindex
$sql_lib $1 'VACUUM;';
$sql_lib $1 'REINDEX;';
#echo $(basename $1)" was optimized."
}
# Optimize every db on folder
optimize_folder(){
local path=$1
count_result=0;
find $path -type f -iname "*.db" -print0 | while IFS= read -r -d $'\0' database; do
optimize_db $database
done
#echo "Databases inside $path were optimized."
}
Use the sqlite binary to VACUUM and REINDEX the given database.
Click to expand...
Click to collapse
[Script][Optimize apks using ZipAlign][v1.0]
Name : Optimize apks using ZipAlign
Version : v1.0
Author : Wes Garner
Suggestions : oknowton
Edited by : DarkThanos
Click to expand...
Click to collapse
This script zipalign applications' apk (only the apks that are not already zipaligned) on every boot.
First boot may take a while.
Before use make a folder "libs" inside "/system/etc/init.d/",
insert the "zipalign" file inside and give it execute permissions (the file is given with the script)
Bugs:(Not for use, more testing needed)
Some apps return an error after zipaligned, and need to be reinstalled.
(Found fix. Zipaligned apk do not holds read rights after copy. Command "cp -p" do not hold permissions. Temp fix "chmod 644". [I need help with that])
A download will be posted when it is stable.
I am not responsible for whatever happens to your phone.
Tested on my Samsung Galaxy Core (I8260)
Need to be tested for stable use.
[Change log]
1.0 Version
Script Public for first time.
Optimize apks using ZipAlign (on every boot check apps).
Click to expand...
Click to collapse
[Dev Doc]
Script code
Code:
#!/system/bin/sh
# Optimize apks using ZipAlign
#
# Work of:
# Wes Garner (Script code)
# oknowton (Suggestions)
#
# Modifications by:
# DarkThanos
#
# For the xda Galaxy Core users
#
# Some variables
# SQLite path
zipalign_lib="/system/etc/init.d/libs/zipalign";
# Data folder path
data_folder="/data/boot_scripts_data/";
# Data database file name
apk_cache="zipalign_apk_cache";
# Counters
count_apps=0
count_zipaligned_apps=0
count_zipalign_failed=0
# Report ZipAlign start
echo "ZipAlign Optimization Start";
# For every apk in /data/app/
for apk in /data/app/*.apk ; do
# Check if this apk is zipaligned
$zipalign_lib -c 4 $apk;
# Get results
not_zipaligned=$?;
# Count app
count_apps=$((count_apps+1))
# If not, align it
if [ $not_zipaligned -eq 1 ]; then
# ZipAlign app
result=`$zipalign_lib -f 4 $apk $data_folder$apk_cache`
if [ -e $data_folder$apk_cache -a ${#result} -eq 0 ]; then
# Successful zipalign
/system/xbin/busybox cp -p $data_folder$apk_cache $apk;
chmod 644 $apk;
rm $data_folder$apk_cache;
count_zipaligned_apps=$((count_zipaligned_apps+1))
else
echo "[ERROR] $result"
# Failed zipalign
count_zipalign_failed=$((count_zipalign_failed+1))
#echo ZipAligning $(basename $apk) Failed | tee -a $LOG_FILE;
fi;
fi;
done;
# Report results
echo "Apks ZipAligned $count_zipaligned_apps/$count_apps ($count_zipalign_failed failed)";
# Exit
exit 0
I need help with the code:
Code:
/system/xbin/busybox cp -p $data_folder$apk_cache $apk;
chmod 644 $apk;
rm $data_folder$apk_cache;
I try to make all my script work with no busybox. "cp" command do not exist in android (without busybox).
Is "cat" a good alternative?
Also, should I use "chmod 644 $apk;"? "cp -p" do not work and I am pretty sure the script has root rights.
Thanks for your time.
Click to expand...
Click to collapse
I need betatester
Sent from my GT-I8262 using XDA Premium 4 mobile app
NieeLz said:
I need betatester
Click to expand...
Click to collapse
Download the "init.bsu.boot" script (from first post). Create the "/system/etc/init.d/" folder. And run the script (from your download folder) using Script Manager (do not forget to enable "su"). Then check "/data/tmp/init.bsu.log" (open as text) and see the log.
This is an easy safe test.
You can also make a test script, like:
Code:
#!/system/bin/sh
# Test Script
echo "This will be on log."
(You can read the script codes too, I have many comments.)

Maintaining build.prop changes in ROM Updates

Hey guys,
So, I am using CM currently, and use CyanDelta to update every couple of days (it works so well!). It works great because I can have it flash Franco Kernel and SuperSU after updating, so those are maintained at least. Annoying part is, every time I update, my build.prop is being overwritten. I scale my DPI down to 405 in order for everything to be ungigantic, and when it gets changed back, it essentially erases my home screens. So, every update, I have to re-apply my settings, and re-do my homescreens. I'm just wondering if you guys have come up with a way to maintain build.prop changes between ROM updates? I feel like there may be a script or something out there, but with some cursory searching around, I can't find jack.
Thanks!
Just copy your current build.prop to your sd when u flash a new build copy and paste over the new one change permissions reboot
Sent from my SM-N910C using XDA Free mobile app
duvalbmarley said:
Just copy your current build.prop to your sd when u flash a new build copy and paste over the new one change permissions reboot
Sent from my SM-N910C using XDA Free mobile app
Click to expand...
Click to collapse
What happens if there are important build.prop changes in an update though?
Transmitted via Bacon
timmaaa said:
What happens if there are important build.prop changes in an update though?
Transmitted via Bacon
Click to expand...
Click to collapse
Most changes are not build.prop related and if it is it would be easier to just copy and paste those changes to the build.prop u copied on your sd card.. and if it's the same rom then it should be no problem or even if it's 2 different roms with the same Base just make sure to copy your original before replacing incase anything goes wrong.... I'm just throwing out a solution what do you suggest the op do??? Don't bash the helper give a helping hand or don't comment
Sent from my SM-N910C using XDA Free mobile app
duvalbmarley said:
Most changes are not build.prop related and if it is it would be easier to just copy and paste those changes to the build.prop u copied on your sd card.. and if it's the same rom then it should be no problem or even if it's 2 different roms with the same Base just make sure to copy your original before replacing incase anything goes wrong.... I'm just throwing out a solution what do you suggest the op do??? Don't bash the helper give a helping hand or don't comment
Sent from my SM-N910C using XDA Free mobile app
Click to expand...
Click to collapse
Whoa, calm down. I'm not bashing you, just asking a question, in order to work with you to come up with the best solution. I agree, most changes aren't contained in the build.prop, but every now and again there could be one or two and it'd take more time checking the two build.props against other than it would just changing the DPI and setting up screens after a flash. I just don't think this solution, while it may work, is a very elegant or practical one, considering that you'd need to waste time to check the build.prop anyway.
@kmakiki, what launcher do you use? I use the app Texdroider to adjust my DPI to 370 after each nightly flash too, but my home screens are never affected. I use Nova Launcher.
Transmitted via Bacon
timmaaa said:
Whoa, calm down. I'm not bashing you, just asking a question, in order to work with you to come up with the best solution. I agree, most changes aren't contained in the build.prop, but every now and again there could be one or two and it'd take more time checking the two build.props against other than it would just changing the DPI and setting up screens after a flash. I just don't think this solution, while it may work, is a very elegant or practical one, considering that you'd need to waste time to check the build.prop anyway.
@kmakiki, what launcher do you use? I use the app Texdroider to adjust my DPI to 370 after each nightly flash too, but my home screens are never affected. I use Nova Launcher.
Transmitted via Bacon
Click to expand...
Click to collapse
Well in my situation I have speed tweaks Internet tweaks dpi changes and a bunch of other tweaks I add to build.prop and i would rather just copy one or two lines then to add every tweak and change after every update
Sent from my SM-N910C using XDA Free mobile app
duvalbmarley said:
Well in my situation I have speed tweaks Internet tweaks dpi changes and a bunch of other tweaks I add to build.prop and i would rather just copy one or two lines then to add every tweak and change after every update
Sent from my SM-N910C using XDA Free mobile app
Click to expand...
Click to collapse
Yeah, but what I'm saying is that it would be time consuming to actually go through each build.prop line by line to discover if there are any that are different or added/removed. It isn't the adding of lines that's the problem, it's having to find out if you need to.
Transmitted via Bacon
timmaaa said:
Yeah, but what I'm saying is that it would be time consuming to actually go through each build.prop line by line to discover if there are any that are different or added/removed. It isn't the adding of lines that's the problem, it's having to find out if you need to.
Transmitted via Bacon
Click to expand...
Click to collapse
Most developer's have change logs to show what was updated and if it's build.prop changes which most likely it won't be u could just ask or it should be posted in change log let's not argue about the changes let's find another solution besides copy and paste since no one has came up with another option
Sent from my SM-N910C using XDA Free mobile app
duvalbmarley said:
Most developer's have change logs to show what was updated and if it's build.prop changes which most likely it won't be u could just ask or it should be posted in change log let's not argue about the changes let's find another solution besides copy and paste since no one has came up with another option
Sent from my SM-N910C using XDA Free mobile app
Click to expand...
Click to collapse
I think the best solution for him is to just change the launcher he's using, that's where the problem lies.
Transmitted via Bacon
flash this zip (attachement)
it will add a file called 99-DPI.sh to
/system/addons.d/ and, by that, it will be executed after every rom flash that uses the backupscripts (cm,... )
the script will replace the default ro.sf.lcd_density to a value you specify (the new default value is 360, this is what i use)
you can add a file called .dpi to your sdcard (/sdcard/.dpi) which contains a number (e.g. 405), then this value will be used after each rom flash.
if you have some questions then feel free to ask :>
[edit]
i just read the whole thread (i was missing some posts)
the 99-DPI.sh can be used to edit any build.prop change, you just have to add some lines, it should be self explaining.
@aHcVolle can u explain more on how to dd new lines to be added into build. Prop
Thnx in advance
@kmakiki i just think of it what if u edit the build. Prop in the cyandelta zip file b4 flashing it?
Ma7mu7 said:
@aHcVolle can u explain more on how to dd new lines to be added into build. Prop
Thnx in advance
Click to expand...
Click to collapse
Can you give more info in what you are trying to do?
aHcVolle said:
Can you give more info in what you are trying to do?
Click to expand...
Click to collapse
Thanks for the fast reply i want to add some lines to build.prop other than changing the dpi i.e disabling bootanimation 3g tweaks etc..
Ma7mu7 said:
Thanks for the fast reply i want to add some lines to build.prop other than changing the dpi i.e disabling bootanimation 3g tweaks etc..
Click to expand...
Click to collapse
OK, edit the file script/99-DPI.sh
remove everything between restore) and ;;
and add your stuff between those 2.
example:
Code:
restore)
echo "dummy_var=1" >> /system/build.prop
ui_print "added line to build.prop"
;;
that should be everything you need.
aHcVolle said:
OK, edit the file script/99-DPI.sh
remove everything between restore) and ;;
and add your stuff between those 2.
example:
Code:
restore)
echo "dummy_var=1" >> /system/build.prop
ui_print "added line to build.prop"
;;
that should be everything you need.
Click to expand...
Click to collapse
Sooo it should be
Code:
restore)
echo "dummy_var=1" >> /system/build.prop
ui_print "added line to build.prop"
debug.sf.nobootanimation=1
ro.config.hw_quickpoweron=true
persist.sys.shutdown.mode=hibernate
dev.bootcomplete=0 ;;
Instead of
Code:
restore)
# We only have work when restoring....
if [ -f $FILE ]; then
# The DPI file is existing, lets check its content
FILEDPI=$(cat $FILE)
# Convert to int (maybe not needed)
(( FILEDPI=$FILEDPI+0 ))
Right?
No
Code:
restore)
echo "debug.sf.nobootanimation=1" >> /system/build.prop
echo "ro.config.hw_quickpoweron=true" >> /system/build.prop
echo "persist.sys.shutdown.mode=hibernate" >> /system/build.prop
echo "dev.bootcomplete=0" >> /system/build.prop
ui_print "added 4 lines to build.prop"
;;
aHcVolle said:
No
Code:
restore)
echo "debug.sf.nobootanimation=1" >> /system/build.prop
echo "ro.config.hw_quickpoweron=true" >> /system/build.prop
echo "persist.sys.shutdown.mode=hibernate" >> /system/build.prop
echo "dev.bootcomplete=0" >> /system/build.prop
ui_print "added 4 lines to build.prop"
;;
Click to expand...
Click to collapse
Thank you very very much just last question
What abt the rest
Code:
# We only have work when restoring....
if [ -f $FILE ]; then
# The DPI file is existing, lets check its content
FILEDPI=$(cat $FILE)
# Convert to int (maybe not needed)
(( FILEDPI=$FILEDPI+0 ))
Shall i just delete them or keep the,m?
Ma7mu7 said:
Thank you very very much just last question
What abt the rest
Code:
# We only have work when restoring....
if [ -f $FILE ]; then
# The DPI file is existing, lets check its content
FILEDPI=$(cat $FILE)
# Convert to int (maybe not needed)
(( FILEDPI=$FILEDPI+0 ))
Shall i just delete them or keep the,m?
Click to expand...
Click to collapse
you can delete them.
make the file look like this:
Code:
#!/sbin/sh
# persistant dpi by volle
# credits: nuclearmistake for ui_print cmd
# Print function
export OUTFD=$(ps | grep -v "grep" | grep -o -E "update_binary(.*)" | cut -d " " -f 3); #BIG props to Chainfire
[ ! $OUTFD ] && export OUTFD=$(ps | grep -v "grep" | grep -o -E "/tmp/updater(.*)" | cut -d " " -f 3); #BIG props nuclearmistake for TWRP-izing
ui_print() { if [ $OUTFD ]; then echo "ui_print $*" 1>&$OUTFD; fi; return 0; }
case "$1" in
pre-backup)
;;
backup)
;;
post-backup)
;;
pre-restore)
;;
restore)
echo "debug.sf.nobootanimation=1" >> /system/build.prop
echo "ro.config.hw_quickpoweron=true" >> /system/build.prop
echo "persist.sys.shutdown.mode=hibernate" >> /system/build.prop
echo "dev.bootcomplete=0" >> /system/build.prop
ui_print "added 4 lines to build.prop"
;;
post-restore)
;;
*)
ui_print " Unkown command $1"
;;
esac
@aHcVolle thanx for the script.
i was also searching how to add lines to build.prop in recovery and it works perfect :good:
aHcVolle said:
you can delete them.
make the file look like this:
[/code]
Click to expand...
Click to collapse
I have a question about combining scripts.
I managed to combine 2 scripts.
First one i created with Android Flashable Zip Creator to install to flash apps in recovery.
Second one is the Fermion Blackhole script to remove bloatware and unwanted apps, also in recovery.
I just copied part of the blackhole into the 1st scipt. I tested it and it works.
Code:
ui_print("@Starting the install process");
ui_print("Setting up required tools...");
ui_print("Mounting Partitions...");
ui_print(" ");
run_program("/sbin/busybox","mount", "/system");
run_program("/sbin/busybox","mount", "/data");
set_progress(0.1);
ui_print("@Installing System Apps");
package_extract_dir("customize/APKs-System/APKs-System_appz", "/system/app");
set_progress(0.2);
set_progress(0.25);
set_progress(0.3);
set_progress(0.4);
set_progress(0.5);
set_progress(0.6);
set_progress(0.7);
set_progress(0.8);
set_progress(0.9);
ui_print("-Sending bloatware to a blackhole.");
delete_recursive(
"/system/app/BasicDreams",
"/system/app/Browser",
"/system/app/Camera2",
"/system/app/CMFileManager",
"/system/app/CMWallpapers",
"/system/app/Eleven",
"/system/app/Email",
"/system/app/Exchange2",
"/system/app/Galaxy4",
"/system/app/Gallery2",
"/system/app/HoloSpiralWallpaper",
"/system/app/LatinIME",
"/system/app/LiveWallpapers",
"/system/app/LiveWallpapersPicker",
"/system/app/Microbes",
"/system/app/NoiseField",
"/system/app/PhaseBeam",
"/system/app/PhotoPhase",
"/system/app/PhotoTable",
"/system/app/PicoTts",
"/system/app/VisualizationWallpapers",
"/system/app/WhisperPush"
);
delete_recursive(
"/system/priv-app/AudioFX",
"/system/priv-app/CellBroadcastReceiver",
"/system/priv-app/Mms",
"/system/priv-app/MmsService",
"/system/priv-app/OmniSwitch",
"/system/priv-app/Trebuchet",
"/system/priv-app/Wallet"
);
set_progress(0.9);
set_metadata_recursive("/system/addon.d", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/permissions", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/preferred-apps", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/framework", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/priv-app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
ui_print("-Unmounting system partition.");
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "umount", "/data");
ui_print("");
ui_print("Done debloating your device!");
ui_print("@Finished Install");
set_progress(1);
Is it possible to add your script to the updater.script ? What part should i copy ? And also can i just add the /script folder into my zip flash file ?
These are the 2 files i use to edit build.prop :
Code:
ui_print("Persistant DPI mod by volle");
ui_print(" Mounting /system");
ifelse(is_mounted("/system"), unmount("/system"));
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system");
ui_print(" Extracting backupscript");
package_extract_file("script/99-DPI.sh", "/system/addon.d/99-DPI.sh");
set_perm(0, 0, 0777, "/system/addon.d/99-DPI.sh");
ui_print(" Running backupscript");
assert(run_program("/system/addon.d/99-DPI.sh","restore"));
ui_print(" Unmounting /system");
unmount("/system");
ui_print("Everything done");
Code:
#!/sbin/sh
# persistant dpi by volle
# credits: nuclearmistake for ui_print cmd
# Print function
export OUTFD=$(ps | grep -v "grep" | grep -o -E "update_binary(.*)" | cut -d " " -f 3); #BIG props to Chainfire
[ ! $OUTFD ] && export OUTFD=$(ps | grep -v "grep" | grep -o -E "/tmp/updater(.*)" | cut -d " " -f 3); #BIG props nuclearmistake for TWRP-izing
ui_print() { if [ $OUTFD ]; then echo "ui_print $*" 1>&$OUTFD; fi; return 0; }
case "$1" in
pre-backup)
;;
backup)
;;
post-backup)
;;
pre-restore)
;;
restore)
echo "qemu.hw.mainkeys=0" >> /system/build.prop
ui_print " HW Mainkeys set"
;;
post-restore)
;;
*)
ui_print " Unkown command $1"
;;
esac

[GUIDE] Create your own Flashable ZIP with custom updater-script and addon.d script

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
FOR WHO? AND WHY?
• Everyone who wants to learn something today
• Do something yourself instead of relying on a 3rd party app/system.
• Remove/Add system apps
• Modify DPI
• Backup/Restore apps to survive a dirty flash
• Apply a custom font
• Apply a custom bootanimation
• Install a new ringtone
• and so on.
Basically removing/adding system stuff can be easily done through a file manager but it takes time and we have to do it whenever we update a custom ROM.
A couple of examples:
1. Customizing GApps packages: if you don't use all apps that are provided then you can simply remove them
2. Viper4Android: V4A is an awesome audio app and it's highly recommended to remove other audio apps/tweaks like AudioFX.
Click to expand...
Click to collapse
We will see how to add and remove system components. Once again, it can be done manually but your phone has to be booted into Android then it needs a reboot to apply the changes.
The last part is for the addon.d script. Your custom system changes will survive a dirty flash. No need to flash a zip file for each update
WHAT DO YOU NEED?
1. A good file manager: MiXplorer, Solid Explorer, ES File Explorer (jk )...
2. ZipSigner to sign your zip (or MiX Signer if you use MiXplorer // add-on available in the XDA thread)
3. A nandroid backup is recommended before using those scripts
4. Prepare your custom files: apk, gps.conf, ringtone, bootanimation,... Everything you want to add after a clean flash.
5. Free time. No young children around you
TEMPLATE AND MY CUSTOM ZIP
I'm a nice guy so I prepared a template. You can either download my own zip and customize it to your needs or use this template as a base to create your own zip "from scratch".
→ TEMPLATE: DOWNLOAD LINK (basic commands / you have to add your custom values: apps, paths of ringtones, bootanimation...)
→ MY ZIP: DOWNLOAD LINK (examples are always welcome to better understand an explanation. It can help to understand how to structure your files).
The template should be enough to start using a custom script.
SOME INFORMATIONS TO REMEMBER
Here are the paths of the main things we want to change in the /system partition (should work for most recent Android versions but check your system to be sure):
• addon.d => backup script to survive a dirty flash (used by GApps package for instance)
• app and priv-app => system apps to add or remove
• etc => host file
• fonts => your font
• media => your bootanimation.zip
• media > audio > alarms => sounds for alarms
• media > audio > notifications => sounds for notifications
• media > audio > ringtones => sounds for ringtones
• media > audio > ui => sounds for various things such as low battery, unlock, camera,..
• root of /system for build.prop file
Click to expand...
Click to collapse
Files that have been removed will be installed again after a dirty flash.
Files that have been manually added will be removed after a dirty flash.
=> That's why we need a script to backup our modifications!
NO space at the end of the lines
UNDERSTAND HOW IT WORKS
PART 1: UPDATER-SCRIPT
Here is mine:
ui_print("+-------------------------------------+");
ui_print("| CLEAN FLASH SCRIPT |");
ui_print("| |");
ui_print("| by Primokorn |");
ui_print("+-------------------------------------+");
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "mount", "/system");
ui_print(" ");
ui_print("***Deleting bloatwares***");
delete_recursive(
"/system/app/adaway.apk",
"/system/app/AdAway",
"/system/app/BasicDreams",
"/system/app/BookmarkProvider",
"/system/app/Calendar",
"/system/app/CalendarWidget",
"/system/app/CMFileManager",
"/system/app/CMWallpapers",
"/system/app/DeskClock",
"/system/app/Eleven",
"/system/app/Email",
"/system/app/ExactCalculator",
"/system/app/Exchange2",
"/system/app/Gello",
"/system/app/HexoLibre",
"/system/app/Jelly",
"/system/app/LiveWallpapersPicker",
"/system/app/LockClock",
"/system/app/messaging",
"/system/app/MiXplorer",
"/system/app/NexusLauncher",
"/system/app/Phonograph",
"/system/app/PhotoTable",
"/system/app/PicoTts",
"/system/app/PicoTTS",
"/system/app/ResurrectionStats",
"/system/app/SoundRecorder",
"/system/app/Terminal",
"/system/app/TugaBrowser",
"/system/app/Wallpaper",
"/system/app/WallpaperPickerGoogle",
"/system/priv-app/AudioFX",
"/system/priv-app/Chrome",
"/system/priv-app/Gallery2",
"/system/priv-app/MusicFX",
"/system/priv-app/OnePlusCamera",
"/system/priv-app/OnePlusGallery",
"/system/priv-app/OnePlusMusic",
"/system/priv-app/Recorder",
"/system/priv-app/Screencast",
"/system/priv-app/Snap",
"/system/priv-app/SnapdragonCamera",
"/system/priv-app/SnapdragonGallery",
"/system/priv-app/WeatherManagerService",
"/system/priv-app/WeatherProvider",
"/system/priv-app/Tag"
);
ui_print("Installing apps and mods, etc");
show_progress(8.800000, 5);
package_extract_dir("system", "/system/");
ui_print("***Fixing permissions***");
set_perm(0, 0, 0755, "/system/addon.d/99-dirty.sh");
set_perm(0, 0, 0644, "/system/etc/gps.conf");
set_perm(0, 0, 0644, "/system/fonts/Roboto-Regular.ttf");
set_perm(0, 0, 0644, "/system/media/audio/ringtones/PlasticRing.ogg");
set_perm(0, 0, 0644, "/system/priv-app/Phonesky.apk");
set_perm(0, 0, 0644, "/system/priv-app/microG.apk");
set_perm(0, 0, 0644, "/system/priv-app/Gsam.apk");
set_perm(0, 0, 0644, "/system/priv-app/BBS.apk");
set_perm(0, 0, 0644, "/system/priv-app/V4A-Magisk.apk");
run_program("/sbin/busybox", "mount", "/data");
package_extract_dir("data", "/data/");
set_perm(0, 0, 0755, "/data/local/afscript.sh");
show_progress(8.800000, 5);
run_program("/sbin/busybox", "umount", "/data");
run_program("/sbin/busybox", "umount", "/system");
ui_print(" ");
ui_print("Done.");
ui_print("Ready to reboot.");
Note: ui_print(" "); is for text message. These lines don't do anything.
1/ It's a good practice to unmount then mount the partition before working on it.
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "mount", "/system");
Click to expand...
Click to collapse
2/ Remove system components. Put a comma at the end of each line EXCEPT the last one.
delete_recursive(
"/system/app/adaway.apk",
"/system/app/AdAway",
........................
"/system/priv-app/WeatherProvider",
"/system/priv-app/Tag"
);
Click to expand...
Click to collapse
3/ Extract the system files I want to install
package_extract_dir("system", "/system/");
Click to expand...
Click to collapse
4/ Set the permissions for the files that I add
set_perm(0, 0, 0755, "/system/addon.d/99-dirty.sh");
..............
set_perm(0, 0, 0644, "/system/priv-app/V4A-Magisk.apk");
Click to expand...
Click to collapse
5/ Same thing but for the /data folder (mount the partition > extract the data I want to add > set the permissions)
run_program("/sbin/busybox", "mount", "/data");
package_extract_dir("data", "/data/");
set_perm(0, 0, 0755, "/data/local/afscript.sh");
Click to expand...
Click to collapse
6/ Unmount the modified partitions
run_program("/sbin/busybox", "umount", "/data");
run_program("/sbin/busybox", "umount", "/system");
Click to expand...
Click to collapse
PART 2: ADDON.D
Here is mine:
#!/sbin/sh
#
# /system/addon.d/99-dirty.sh
# /system is formatted and reinstalled, then thes files are restored.
#
. /tmp/backuptool.functions
list_files() {
cat <<EOF
addon.d/99-dirty.sh
fonts/Roboto-Regular.ttf
media/audio/ringtones/PlasticRing.ogg
priv-app/BBS.apk
priv-app/Gsam.apk
priv-app/microG.apk
priv-app/PhoneSky.apk
priv-app/V4A-Magisk.apk
etc/gps.conf
etc/hosts
EOF
}
case "$1" in
backup)
list_files | while read FILE DUMMY; do
backup_file $S/"$FILE"
done
;;
restore)
list_files | while read FILE REPLACEMENT; do
R=""
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
[ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
done
rm -rf /system/app/adaway.apk
rm -rf /system/app/AdAway
rm -rf /system/app/BasicDreams
rm -rf /system/app/BookmarkProvider
rm -rf /system/app/Calendar
rm -rf /system/app/CalendarWidget
rm -rf /system/app/CMFileManager
rm -rf /system/app/CMWallpapers
rm -rf /system/app/DeskClock
rm -rf /system/app/Eleven
rm -rf /system/app/Email
rm -rf /system/app/ExactCalculator
rm -rf /system/app/Exchange2
rm -rf /system/app/Gello
rm -rf /system/app/HexoLibre
rm -rf /system/app/Jelly
rm -rf /system/app/LatinIME
rm -rf /system/app/LiveWallpapersPicker
rm -rf /system/app/LockClock
rm -rf /system/app/messaging
rm -rf /system/app/MiXplorer
rm -rf /system/app/NexusLauncher
rm -rf /system/app/Nova.apk
rm -rf /system/app/Phonograph
rm -rf /system/app/PhotoTable
rm -rf /system/app/PicoTts
rm -rf /system/app/PicoTTS
rm -rf /system/app/ResurrectionStats
rm -rf /system/app/SoundRecorder
rm -rf /system/app/Terminal
rm -rf /system/app/TugaBrowser
rm -rf /system/app/Wallpaper
rm -rf /system/app/WallpaperPickerGoogle
rm -rf /system/priv-app/AudioFX
rm -rf /system/priv-app/Chrome
rm -rf /system/priv-app/Gallery2
rm -rf /system/priv-app/LatinIME
rm -rf /system/priv-app/MusicFX
rm -rf /system/priv-app/OnePlusCamera
rm -rf /system/priv-app/OnePlusGallery
rm -rf /system/priv-app/OnePlusMusic
rm -rf /system/priv-app/Recorder
rm -rf /system/priv-app/Screencast
rm -rf /system/priv-app/SnapdragonCamera
rm -rf /system/priv-app/SnapdragonGallery
rm -rf /system/priv-app/Snap
rm -rf /system/priv-app/Trebuchet
rm -rf /system/priv-app/WeatherManagerService
rm -rf /system/priv-app/WeatherProvider
rm -rf /system/priv-app/Tag
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac
1/ Files that I want to keep after a dirty flash
list_files() {
cat <<EOF
addon.d/99-dirty.sh
fonts/Roboto-Regular.ttf
media/audio/ringtones/PlasticRing.ogg
priv-app/BBS.apk
priv-app/Gsam.apk
priv-app/microG.apk
priv-app/PhoneSky.apk
priv-app/V4A-Magisk.apk
etc/gps.conf
etc/hosts
EOF
}
Click to expand...
Click to collapse
2/ Files I don't want to be installed after a dirty flash
rm -rf /system/app/adaway.apk
rm -rf /system/app/AdAway
rm -rf /system/app/BasicDreams
rm -rf /system/app/BookmarkProvider
................................................
rm -rf /system/priv-app/WeatherProvider
rm -rf /system/priv-app/Tag
;;
Click to expand...
Click to collapse
CREATE YOUR FLASHABLE ZIP
The steps below are done with MiXplorer file manager.
1. Select all your folders and select Archive.
2. Confirm the creation of the archive file.
View attachment 4182479
3. Enter the name of your file and select Store.
4. Your flashable zip has been created.
5. Select your zip file then Sign.
6. Select TESTKEY.
7. Your final flashable zip is created (xxx-signed.zip). This is the file you will flash from your custom recovery. You can safely remove the first zip file.
NOTES:
• your flashable zip has to be installed after a clean flash (or after wiping /system partition and making a dirty flash of your ROM custom). The updater-script will immediately remove/add the desired apps/folders. Leave your addon.d script alone. It will do its job without any user intervention.
Check your /system partition after the first installations to be sure that everything is working as expected.
• if you have something better to share or tips then let us know.
• all credits go to the people who shared their findings with the community. I picked up various information so this is more a general guide to create a custom updater-script and addon.d script.
• I recommend to keep an eye on the template or my zip when reading this guide.
• Ref: [TUTORIAL] The updater-script completely explained
HOW TO EDIT YOUR BUILD.PROP
If you want to modify your build.prop or add new lines then follow those steps.
1. Create a new .sh file (e.g build_prop.sh)
2. To modify specific lines:
sed -i 's/original_value/new_value/g' /system/build.prop;
Example for LCD Density (from 480 to 420):
sed -i 's/ro.sf.lcd_density=480/ro.sf.lcd_density=420/g' /system/build.prop;
Click to expand...
Click to collapse
3. To add new lines:
echo "your_value" >> /system/build.prop;
Example for Viper4Android (if you don't have those lines):
echo "IPA.decode=false" >> /system/build.prop;
echo "tunnel.decode=false" >> /system/build.prop;
echo "lpa.use-stagefright=false" >> /system/build.prop;
Click to expand...
Click to collapse
4. In your build_prop.sh file copy this
Code:
#!/sbin/sh
Then add your sed and echo lines
Example:
#!/sbin/sh
sed -i 's/ro.sf.lcd_density=480/ro.sf.lcd_density=420/g' /system/build.prop;
echo "IPA.decode=false" >> /system/build.prop;
echo "tunnel.decode=false" >> /system/build.prop;
echo "lpa.use-stagefright=false" >> /system/build.prop;
Click to expand...
Click to collapse
Copy your script into your flashable zip (system folder). That's it for the .sh script.
5. Now you have to create your updater-script into your flashable zip (see OP if you don't know how to do that).
Here is what you need to put:
Code:
ui_print("+--------BUILD-PROP-EDITION----------+");
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "mount", "/system");
show_progress(8.800000, 5);
package_extract_dir("system", "/system/");
ui_print("***Fixing permissions***");
set_perm(0, 0, 0777, "/system/build_prop.sh");
run_program("/sbin/sh", "system/build_prop.sh");
show_progress(8.800000, 5);
delete_recursive(
"/system/build_prop.sh"
);
run_program("/sbin/busybox", "umount", "/system");
ui_print(" ");
ui_print("Completed.");
What does it do? This will extract your build_prop.sh file into /system partition, set the permissions and delete your script.
6. Create your flashable zip and sign it as explained in the previous post.
7. Reboot into TWRP and flash!
I have attached a compressed file as an example.
Thank you! Will try this later
---------- Post added at 04:34 PM ---------- Previous post was at 03:45 PM ----------
Im so newbie with this kind of stuff, that i have to ask for specific info.
As i told in another topic, i need to keep my /system/app/Calculator/Calculator.apk when im flashing my rom update.
If i understand correctly, it can be done with addon.d script automatically, without flashing any zips?
raimopeku said:
Thank you! Will try this later
---------- Post added at 04:34 PM ---------- Previous post was at 03:45 PM ----------
Im so newbie with this kind of stuff, that i have to ask for specific info.
As i told in another topic, i need to keep my /system/app/Calculator/Calculator.apk when im flashing my rom update.
If i understand correctly, it can be done with addon.d script automatically, without flashing any zips?
Click to expand...
Click to collapse
Exactly. You can only create a .sh file into addon.d folder.
Use the following at the beginning:
Code:
list_files() {
cat <<EOF
app/Calculator/Calculator.apk
EOF
}
i remove some of the addons on your updater script.
because i only want the bloatware removal scripts. Can you check if this is correct.
ui_print("+-------------------------------------+");
ui_print("| bloatware removal script |");
ui_print("| |");
ui_print("| !!!BYE BYE!!! |");
ui_print("+-------------------------------------+");
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "mount", "/system");
ui_print(" ");
ui_print("***Deleting bloatwares***");
delete_recursive(
"/system/priv-app/Launcher3",
"/system/priv-app/MusicFX"
);
run_program("/sbin/busybox", "unmount", "/system");
ui_print(" ");
ui_print("Completed.");
ui_print("Enjoy!");
mixtapes08 said:
i remove some of the addons on your updater script.
because i only want the bloatware removal scripts. Can you check if this is correct.
ui_print("+-------------------------------------+");
ui_print("| bloatware removal script |");
ui_print("| |");
ui_print("| !!!BYE BYE!!! |");
ui_print("+-------------------------------------+");
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "mount", "/system");
ui_print(" ");
ui_print("***Deleting bloatwares***");
delete_recursive(
"/system/priv-app/Launcher3",
"/system/priv-app/MusicFX"
);
run_program("/sbin/busybox", "unmount", "/system");
ui_print(" ");
ui_print("Completed.");
ui_print("Enjoy!");
Click to expand...
Click to collapse
It should work BUT Launcher3 is stored into /system/app/. Moreover you need a launcher to reach a homescreen. In other words, if you remove Launcher3 after a clean flash then you have to install another launcher.
I forgot to explain how to sign the final zip. I'll add this in the coming hours.
On pure nexus its located on system/priv-app and I have a novalauncher.zip that i will install after flashing. I have a installer.zip here. Can i copy my modified updater-script there?
Sent from my Nexus 5
mixtapes08 said:
On pure nexus its located on system/priv-app and I have a novalauncher.zip that i will install after flashing. I have a installer.zip here. Can i copy my modified updater-script there?
Sent from my Nexus 5
Click to expand...
Click to collapse
Of course. Do not forget to remove run_program lines if you already have them in the other file :good:
Thanks. Man.
Sent from my Nexus 5
PART 3 added to create and sign your flashable zip.
Primokorn said:
Exactly. You can only create a .sh file into addon.d folder.
Use the following at the beginning:
Code:
list_files() {
cat <<EOF
app/Calculator/Calculator.apk
EOF
}
Click to expand...
Click to collapse
So, i created that file in /system/addon.d/myfile.sh
And now when i updated my rom (euphoria), my old calculator was gone, and i had to manually it back?
raimopeku said:
So, i created that file in /system/addon.d/myfile.sh
And now when i updated my rom (euphoria), my old calculator was gone, and i had to manually it back?
Click to expand...
Click to collapse
Can you post your whole script? Are you using other scripts?
Primokorn said:
Can you post your whole script? Are you using other scripts?
Click to expand...
Click to collapse
hmm, there are 2 other scripts (made by rom i assume)
myfile.sh:
Code:
list_files() {
cat <<EOF
app/Calculator/Calculator.apk
EOF
}
50-eos.sh
Code:
#!/sbin/sh
#
# /system/addon.d/50-eos.sh
# During a upgrade, this script backs up /system/etc/hosts,
# /system is formatted and reinstalled, then the file is restored.
#
. /tmp/backuptool.functions
list_files() {
cat <<EOF
etc/hosts
EOF
}
case "$1" in
backup)
list_files | while read FILE DUMMY; do
backup_file $S/"$FILE"
done
;;
restore)
list_files | while read FILE REPLACEMENT; do
R=""
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
[ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
done
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac
70-gapps.sh
Code:
#!/sbin/sh
#
# /system/addon.d/70-gapps.sh
#
. /tmp/backuptool.functions
list_files() {
cat <<EOF
app/FaceLock/lib/arm/libfacelock_jni.so
app/FaceLock/lib/arm64/libfacelock_jni.so
app/FaceLock/FaceLock.apk
app/GoogleContactsSyncAdapter/GoogleContactsSyncAdapter.apk
etc/permissions/com.google.android.camera2.xml
etc/permissions/com.google.android.maps.xml
etc/permissions/com.google.android.media.effects.xml
etc/permissions/com.google.widevine.software.drm.xml
etc/preferred-apps/google.xml
framework/com.google.android.camera2.jar
framework/com.google.android.maps.jar
framework/com.google.android.media.effects.jar
framework/com.google.widevine.software.drm.jar
lib/libfilterpack_facedetect.so
lib64/libfilterpack_facedetect.so
lib/libjni_latinime.so
lib64/libjni_latinime.so
lib/libjni_latinimegoogle.so
lib64/libjni_latinimegoogle.so
priv-app/GoogleBackupTransport/GoogleBackupTransport.apk
priv-app/GoogleFeedback/GoogleFeedback.apk
priv-app/GoogleLoginService/GoogleLoginService.apk
priv-app/GoogleOneTimeInitializer/GoogleOneTimeInitializer.apk
priv-app/GooglePartnerSetup/GooglePartnerSetup.apk
priv-app/GoogleServicesFramework/GoogleServicesFramework.apk
priv-app/HotwordEnrollment/HotwordEnrollment.apk
priv-app/Phonesky/Phonesky.apk
priv-app/PrebuiltGmsCore/lib/arm/libAppDataSearch.so
priv-app/PrebuiltGmsCore/lib/arm/libconscrypt_gmscore_jni.so
priv-app/PrebuiltGmsCore/lib/arm/libdirect-audio.so
priv-app/PrebuiltGmsCore/lib/arm/libgcastv2_base.so
priv-app/PrebuiltGmsCore/lib/arm/libgcastv2_support.so
priv-app/PrebuiltGmsCore/lib/arm/libgmscore.so
priv-app/PrebuiltGmsCore/lib/arm/libgms-ocrclient.so
priv-app/PrebuiltGmsCore/lib/arm/libjgcastservice.so
priv-app/PrebuiltGmsCore/lib/arm/libNearbyApp.so
priv-app/PrebuiltGmsCore/lib/arm/libsslwrapper_jni.so
priv-app/PrebuiltGmsCore/lib/arm/libwearable-selector.so
priv-app/PrebuiltGmsCore/lib/arm/libWhisper.so
priv-app/PrebuiltGmsCore/lib/arm64/libAppDataSearch.so
priv-app/PrebuiltGmsCore/lib/arm64/libconscrypt_gmscore_jni.so
priv-app/PrebuiltGmsCore/lib/arm64/libdirect-audio.so
priv-app/PrebuiltGmsCore/lib/arm64/libgcastv2_base.so
priv-app/PrebuiltGmsCore/lib/arm64/libgcastv2_support.so
priv-app/PrebuiltGmsCore/lib/arm64/libgmscore.so
priv-app/PrebuiltGmsCore/lib/arm64/libgms-ocrclient.so
priv-app/PrebuiltGmsCore/lib/arm64/libjgcastservice.so
priv-app/PrebuiltGmsCore/lib/arm64/libNearbyApp.so
priv-app/PrebuiltGmsCore/lib/arm64/libsslwrapper_jni.so
priv-app/PrebuiltGmsCore/lib/arm64/libwearable-selector.so
priv-app/PrebuiltGmsCore/lib/arm64/libWhisper.so
priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk
priv-app/SetupWizard.apk
priv-app/Velvet/lib/arm/libcronet.so
priv-app/Velvet/lib/arm/libgoogle_speech_jni.so
priv-app/Velvet/lib/arm/libgoogle_speech_micro_jni.so
priv-app/Velvet/lib/arm64/libcronet.so
priv-app/Velvet/lib/arm64/libgoogle_speech_jni.so
priv-app/Velvet/lib/arm64/libgoogle_speech_micro_jni.so
priv-app/Velvet/Velvet.apk
usr/srec/en-US/c_fst
usr/srec/en-US/clg
usr/srec/en-US/commands.abnf
usr/srec/en-US/compile_grammar.config
usr/srec/en-US/contacts.abnf
usr/srec/en-US/dict
usr/srec/en-US/dictation.config
usr/srec/en-US/dnn
usr/srec/en-US/endpointer_dictation.config
usr/srec/en-US/endpointer_voicesearch.config
usr/srec/en-US/ep_acoustic_model
usr/srec/en-US/g2p_fst
usr/srec/en-US/grammar.config
usr/srec/en-US/hclg_shotword
usr/srec/en-US/hmm_symbols
usr/srec/en-US/hmmlist
usr/srec/en-US/hotword.config
usr/srec/en-US/hotword_classifier
usr/srec/en-US/hotword_normalizer
usr/srec/en-US/hotword_prompt.txt
usr/srec/en-US/hotword_word_symbols
usr/srec/en-US/metadata
usr/srec/en-US/norm_fst
usr/srec/en-US/normalizer
usr/srec/en-US/offensive_word_normalizer
usr/srec/en-US/phone_state_map
usr/srec/en-US/phonelist
usr/srec/en-US/rescoring_lm
usr/srec/en-US/wordlist
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8/landmark_group_meta_data.bin
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8/left_eye-y0-yi45-p0-pi45-r0-ri20.lg_32-tree7-wmd.bin
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8/nose_base-y0-yi45-p0-pi45-r0-ri20.lg_32-tree7-wmd.bin
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8/right_eye-y0-yi45-p0-pi45-r0-ri20.lg_32-3-tree7-wmd.bin
vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/head-y0-yi45-p0-pi45-r0-ri30.4a-v24-tree7-2-wmd.bin
vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/head-y0-yi45-p0-pi45-rn30-ri30.5-v24-tree7-2-wmd.bin
vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/head-y0-yi45-p0-pi45-rp30-ri30.5-v24-tree7-2-wmd.bin
vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/pose-r.8.1.bin
vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/pose-y-r.8.1.bin
vendor/pittpatt/models/recognition/face.face.y0-y0-71-N-tree_7-wmd.bin
EOF
}
case "$1" in
backup)
list_files | while read FILE DUMMY; do
backup_file $S/$FILE
done
;;
restore)
list_files | while read FILE REPLACEMENT; do
R=""
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
[ -f "$C/$S/$FILE" ] && restore_file $S/$FILE $R
done
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
rm -rf /system/app/BrowserProviderProxy
rm -f /system/app/BrowserProviderProxy.apk
rm -rf /system/app/PartnerBookmarksProvider
rm -f /system/app/PartnerBookmarksProvider.apk
rm -rf /system/app/Provision
rm -f /system/app/Provision.apk
rm -rf /system/app/QuickSearchBox
rm -f /system/app/QuickSearchBox.apk
rm -rf /system/app/Vending
rm -f /system/app/Vending.apk
rm -rf /system/priv-app/BrowserProviderProxy
rm -f /system/priv-app/BrowserProviderProxy.apk
rm -rf /system/priv-app/PartnerBookmarksProvider
rm -f /system/priv-app/PartnerBookmarksProvider.apk
rm -rf /system/priv-app/Provision
rm -f /system/priv-app/Provision.apk
rm -rf /system/priv-app/QuickSearchBox
rm -f /system/priv-app/QuickSearchBox.apk
rm -rf /system/priv-app/Vending
rm -f /system/priv-app/Vending.apk
;;
esac
Your myfile.sh file is not complete. You have to use the whole code (just remove my custom lines: apps that I remove and audio_policy at the end).
Try this:
Code:
#!/sbin/sh
#
#
. /tmp/backuptool.functions
list_files() {
cat <<EOF
app/Calculator/Calculator.apk
EOF
}
case "$1" in
backup)
list_files | while read FILE DUMMY; do
backup_file $S/"$FILE"
done
;;
restore)
list_files | while read FILE REPLACEMENT; do
R=""
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
[ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
done
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac
Primokorn said:
Your myfile.sh file is not complete. You have to use the whole code (just remove my custom lines: apps that I remove and audio_policy at the end).
Try this:
Code:
#!/sbin/sh
#
#
. /tmp/backuptool.functions
list_files() {
cat <<EOF
app/Calculator/Calculator.apk
EOF
}
case "$1" in
backup)
list_files | while read FILE DUMMY; do
backup_file $S/"$FILE"
done
;;
restore)
list_files | while read FILE REPLACEMENT; do
R=""
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
[ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
done
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac
Click to expand...
Click to collapse
Ok, thanks m8! I updated my script, after next rom update ill report if it works
*** NEW ***
How to edit your build.prop in post 2.
The "Template" (MEGA) download link in the OP is dead. Please re-upload, thanks.
blowtorch said:
The "Template" (MEGA) download link in the OP is dead. Please re-upload, thanks.
Click to expand...
Click to collapse
I've uploaded my latest custom scripts. I also updated OP.
Primokorn said:
I've uploaded my latest custom scripts. I also updated OP.
Click to expand...
Click to collapse
I was wondering if there is any way you can help me with a flashable zip i am working on cant seem to get it to flash correctly I get the following error each time;
Updater process ended with signal:11
maxmotos said:
I was wondering if there is any way you can help me with a flashable zip i am working on cant seem to get it to flash correctly I get the following error each time;
Updater process ended with signal:11
Click to expand...
Click to collapse
Share your files and I'll have a look as soon as I can.

Categories

Resources