[GUIDE][HOW-TO] customize your xperia phone - Sony Xperia Miro, Tipo (Dual), J, E

Let's customize our ROM.
This thread's goal is to make you understand better about your ROM, how to maintain it, and how to modify it to satisfy your desire. this thread is based of this thread http://forum.xda-developers.com/showthread.php?t=1590330 which I've write several months ago. however, our system is a lil bit different with the one in SGY. this thread will contain more specific information about ICS based rom especially the xperia phones.
I'll made this thread into several section. the first section will explain about the file structure in our system. the second one will tell you about app/system modification, and the thirdth one is about tweaking.
1. KNOW BETTER ABOUT YOUR SYSTEM
1.1 SYSTEM STRUCTURE
first of all, when I said "system" here, what I mean is all the stuff under your system partition. if you're browsing with your file explorer, it's all the files inside /system folder. please don't mix it with a complete android system. if you open your /system folder, you'll find these folders.
1. app : contain all the system's app and the odex file of system app
2. bin : contain the command and bin files for the rom
3. vendor: specified vendor system. you have your specific vendor's app, libs, and config files here.
4. etc : additional setting and files for the rom.
5. font : the fonts
6. framework : system's framework files and the odex file for framework
7. lib : drivers, modules, kernel related files for the rom
8. media : media files-ringtones, notification, bootanimation.
9. sd : folder created by a2sd darktremor. (only modified rom have it)
10. usr : files needed for keyboard, bluetooth, etc.
11. xbin : additional command and bin files (busybox is usually installed here)
12. build.prop file : contain your system default prop
13. ts.conf : a configuration file for your system. you'd better stay away from it.
1.2 DEODEX VS ODEX
Most of custom rom available is deodexed rom while our stock rom is half deodexed rom. I'll try to explain it in most simple way. First of all, we should understand that mostly every app in android consist of three part, *apk files, *dex/odex files, and lib files.
ODEXED rom means that *dex file needed to run the app is extracted from the apk file and placed in same folder with the apk files (/system/app). the positive side, it consume less internal memory and a execute faster. the negative side, it makes the app uncostumizable (cannot apply custom themes) and need more space in system partition.
DEODEXED rom means that *dex file needed to run the app is extracted from the apk file and placed in /data/dalvik-cache. the positive side, the app can be themed (full customizable) and consume less system partition. we could put more app in /system/app in deodexed rom. the negative side, it consume a lot of internal memory. please be cautious with the internal memory space if you use deodexed rom. (NOTE: if you start from stock rom, you may use dsixdia to convert odexed to deodexed rom).
2. APP/SYSTEM MODIFICATION
basicly, you modify your system in two ways. push a file to add/replace file into your system and modify your files with file explorer. it can be done in several ways. if you want to modify your system, you should remember these stuff:
1. file compatibilty : if you push a file, especially some apps, you should make sure that file is compatible with your system. some app require different framework, additional libs, and some other dependencies. make sure you already had all of them in your system.
2. correct file permission: some file don't need special permission. however, some other file require special permission like execution.
3. system free memory : you have limited system partition size. you can't put everything inside it. please be aware with the system partition size and the free memory.
4. always backup before doing everything.
2.1 ADD MORE APP INTO YOUR SYSTEM
it can be done in two ways. the first one, you can add that app into /system/app. the second one, you can add that app into /system/vendor/app. both of them works on xperia's phone. most of the files inside inside /system/vendor work just like in /system. so, if you have an apk in /system/vendor/app, it's not different with having that apk in /system/app. nevertheless, all file in /system/vendor is more prioritizied than the one in /system. it means, if you have two file with same name, the one in /system/vendor will be used instead of the one in /system.
please note that. this trick only work for anything under /system/vendor/app, /system/vendor/etc, and /system/vendor/lib. for an instance, if you create /system/vendor/framework, it won't recognized by system. this trick will usefull for you if you want to modifying your system without touching your original system files. you'll also easiliy distinguish your modification and easily remove it from your system without worying about bootloop.
Click to expand...
Click to collapse
2.2 CREATE THEME FOR YOR OWN ROM
simple theming stuff could be done by replacing the pic files inside the apk, especially framework-res.apk in /system/framework. a hardcore theming need apk modification. this thread doesn't recover about this stuff since it's too long. please search it by yourself if you interested about it. for a basic theme, you need to modify systemUI.apk and framework-res.apk. the systemUI.apk contain your statusbar. the framework-res.apk contain your system interface.
3. TWEAK UP YOUR ROM
there are a lot of tweak. I'll divide it into two categories. scripts and props. scripts, is a tweak run by specified script. this tweak only work if you have a rom with init.d support or you're using script manager app. most of these stuff can be found in /system/etc/init.d/.
props, is a file contain your system properties. the famous one your build.prop inside /system. aside of it you actually have default.prop but this file is stored in your ramdisk and can't be modified without kernel modification. you have a lot of method to modify your prop stuff.
1. modify your build.prop file. you can put your own prop or modify the prop value inside this file. seems easy, but this is the most risky one. you can brick your device easily if you're not carefull when modifying it. I don't recommend it for new android user.
2. create a file "local.prop" in /data. the less risky method. it works just like when you modify your build.prop directly. however, it's less risky since if you got bootloop, you only need to delete it and your device will revived. I always prefer this method for my rom modification
3. create script in init.d. the basic form will be
Code:
#!/system/bin/sh
# the custom prop
setprop <prop key><space><prop value>
for an instance, if you have a prop in your build.prop "dalvik.vm.heapsize=128m" you can type "setprop dalvik.vm.heapsize 128m" in your script. this trick is usefull if you're a rom modificator and want to install something which require specific prop. in this way, you don't need to know anything inside build.prop/local.prop. you can make an universal mod which can be installed on a lot of device. bravia engine mod works fine with this method.

BONUS FOR TWEAKERS
if you have time, you can rewrite all the stuff by yourself to avoid double typed script with different value. its easy but need a lil more patience. I'll try to give quick explanation. our tweaks mostly work via init.d script. the basic structure will be.
Code:
#!/system/bin/sh --> the header. tell the system to use "sh" command on the script below
echo bla bla bla. --> the script
I'll differentiate the scripts into two parts. the one run a bash script and the one used to change our device setting. the first one is quite complicated and usually written on separated file. the famous one might be zipalign script and sqlite script. basicly you only need to add the script and the required files (the libs and the binary file in /system/bin) into your system and need no modification. just add and leave it.
the second part is the one used to change our device setting. we can differentiate this stuff into two things. the setprop stuff and the "other stuff". the setprop stuff is quite easy to use. the setprop stuff basic form is "setprop <key> <value>" for an example:
Code:
setprop ro.ril.enable.dtm 1
setprop ro.ril.gprsclass 10
setprop ro.ril.hep 1
setprop ro.ril.enable.3g.prefix 1
setprop ro.ril.hsdpa.category 8
setprop ro.ril.hsupa.category 6
setprop ro.ril.hsxpa 2
setprop ro.ril.enable.a53 1
some of these script written in form of "setprop ro.ril.hep=1". that's the wrong way. the correct way is as I've described above.
the second part, the "other stuff" work in three different way. for an example, look at these files
Code:
/proc/sys/kernel/shmmni
/proc/sys/kernel/shmmax
/proc/sys/kernel/shmall
these files have certain value on it. if we want to change the value written on it, we can use three different way.
1. use "sysctl -w <key>=<value>" form. in your init.d script you'll type
Code:
sysctl -w kernel.shmmni=4096
sysctl -w kernel.shmmax=268435456
sysctl -w kernel.shmall=2097152
2. use sysctl.conf file. in your sysctl.conf file, you'll write
Code:
kernel.shmmni=4096
kernel.shmmax=268435456
kernel.shmall=2097152
while in your init.d script you'll write "sysctl -p".
personally I prefer the number 1 since I can made a simple test to check whether if the script is running or not and add it into my log files. anyway, these trick only work for the files under /proc/sys. if you want to change the value of different files, you'll need to use method number 3.
3. use echo command. the form is "echo "<value>" > /path/to/file". in your init.d you'll write
Code:
echo "0" > /sys/module/lowmemorykiller/parameters/debug_level
echo "64" > /sys/module/lowmemorykiller/parameters/cost
echo "0,1,3,5,7,15" > /sys/module/lowmemorykiller/parameters/adj
echo "4096,5182,6400,15360,17920,20480" > /sys/module/lowmemorykiller/parameters/minfree
to avoid double typed script, we can categorize our tweak into several group. I'll show you my tweak as an example. you can learn it or start with it. I don't take credits, so that you can modify it anytime without asking my permission.
Code:
#!/system/bin/sh
# kuro tweak1: the echo stuff
# [email protected] (2012) - lol...i'm just joking. no copyright or whatsoever
# contact : [email protected]
# v.1 - first release
# v.1.1 - new log system and new tweak added.
# v.1.2 - new tweak for xperia
# v.1.3(4-11-12) - new form
LOG_FILE=/data/kuro_tweak1.log
LOG_FILEZ=/data/kuro_sqlite.log
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
if [ -e $LOG_FILEZ ]; then
rm $LOG_FILEZ;
fi;
# the preface
echo "==========================
# TWEAK KURO1-LOG FILE #
==========================
in the name of Allah,
the most beneficent,
the most mercifull
==========================
system information:
vendor : $( getprop ro.product.brand )
model : $( getprop ro.product.model )
ROM : $( getprop ro.build.display.id )
running the script...
start at:
$( date +"%m-%d-%Y %H:%M:%S" )
==========================" | tee -a $LOG_FILE;
# perfect mount
mount -o remount,noatime,commit=500,noauto_da_alloc,barrier=0 /system /system;
mount -o remount,noatime,commit=500,noauto_da_alloc,barrier=0 /data /data;
mount -o remount,noatime,commit=500,noauto_da_alloc,barrier=0 /cache /cache;
echo "perfect mount---------[OK]" | tee -a $LOG_FILE;
# sdcard speed fix
# not working yet - need root permission to change these value
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]; then
busybox echo "2048" > /sys/devices/virtual/bdi/179:0/read_ahead_kb
busybox echo "2048" > /sys/devices/virtual/bdi/179:32/read_ahead_kb
echo "sdcard speed fix------[OK]
-value set to $( cat /sys/devices/virtual/bdi/179:0/read_ahead_kb )
-value set to $( cat /sys/devices/virtual/bdi/179:32/read_ahead_kb )" | tee -a $LOG_FILE; else
echo "sdcard speed fix----[FAIL]" | tee -a $LOG_FILE;
fi
# kernel kick
sysctl -w kernel.shmmni=4096
sysctl -w kernel.shmmax=268435456
sysctl -w kernel.shmall=2097152
sysctl -w kernel.msgmni=4096
sysctl -w kernel.msgmax=64000
# sysctl -w kernel.sched_latency_ns=20000000
# sysctl -w kernel.sched_wakeup_granularity_ns=2500000
# sysctl -w kernel.sched_min_granularity_ns=10000000
sysctl -w kernel.sem="500 512000 64 2048"
sysctl -w kernel.panic=30
sysctl -w kernel.panic_on_oops=0
sysctl -w kernel.threads-max=10000
sysctl -w kernel.panic=30
# sysctl -w kernel.sched_compat_yield=1
# sysctl -w kernel.sched_shares_ratelimit=256000
sysctl -w kernel.ctrl-alt-del=0
sysctl -w fs.lease-break-time=10
sysctl -w fs.file-max=65536
echo "kernel kick-----------[OK]" | tee -a $LOG_FILE;
# OOM
sysctl -w vm.laptop_mode=0
sysctl -w vm.swappiness=40
sysctl -w vm.dirty_writeback_centisecs=3000
sysctl -w vm.dirty_expire_centisecs=500
sysctl -w vm.dirty_ratio=15
sysctl -w vm.dirty_background_ratio=10
sysctl -w vm.lowmem_reserve_ratio="100 100"
sysctl -w vm.overcommit_ratio=70
sysctl -w vm.highmem_is_dirtyable=1
sysctl -w vm.min_free_order_shift=4
sysctl -w vm.oom_kill_allocating_task=0
sysctl -w vm.panic_on_oom=0
sysctl -w vm.page-cluster=3
sysctl -w vm.drop_caches=3
sysctl -w vm.min_free_kbytes=5120
sysctl -w vm.vfs_cache_pressure=50
sysctl -w vm.block_dump=0
echo "memory management-----[OK]" | tee -a $LOG_FILE;
# network boost
sysctl -w net.ipv4.tcp_congestion_control=cubic
sysctl -w net.ipv4.tcp_timestamps=0
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w net.ipv4.tcp_sack=1
sysctl -w net.ipv4.tcp_dsack=1
sysctl -w net.ipv4.tcp_tw_recycle=1
sysctl -w net.ipv4.tcp_window_scaling=1
sysctl -w net.ipv4.tcp_keepalive_probes=5
sysctl -w net.ipv4.tcp_keepalive_intvl=30
sysctl -w net.ipv4.tcp_fin_timeout=30
sysctl -w net.ipv4.tcp_moderate_rcvbuf=1
sysctl -w net.ipv4.tcp_max_tw_buckets=1440000
sysctl -w net.ipv4.tcp_mem="57344 57344 524288"
sysctl -w net.ipv4.tcp_synack_retries=2
sysctl -w net.ipv4.tcp_syn_retries=2
sysctl -w net.ipv4.tcp_max_syn_backlog=1024
sysctl -w net.ipv4.icmp_echo_ignore_all=1
sysctl -w net.ipv4.route/flush=1
sysctl -w net.ipv4.udp_rmem_min=6144
sysctl -w net.ipv4.udp_wmem_min=6144
sysctl -w net.ipv4.tcp_rfc1337=1
sysctl -w net.ipv4.ip_no_pmtu_disc=0
sysctl -w net.ipv4.tcp_ecn=0
sysctl -w net.ipv4.tcp_wmem="6144 87380 524288"
sysctl -w net.ipv4.tcp_rmem="6144 87380 524288"
sysctl -w net.ipv4.tcp_fack=1
sysctl -w net.ipv4.tcp_synack_retries=2
sysctl -w net.ipv4.tcp_syn_retries=2
sysctl -w net.ipv4.tcp_no_metrics_save=1
sysctl -w net.ipv4.tcp_keepalive_time=1800
sysctl -w net.ipv4.ip_forward=0
sysctl -w net.ipv4.ip_dynaddr=0
sysctl -w net.ipv4.conf.all.accept_source_route=0
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.all.rp_filter=1
sysctl -w net.ipv4.conf.all.secure_redirects=0
sysctl -w net.ipv4.conf.default.accept_redirects=0
sysctl -w net.ipv4.conf.default.secure_redirects=0
sysctl -w net.ipv4.conf.default.accept_source_route=0
sysctl -w net.core.rmem_max=524288
sysctl -w net.core.wmem_max=524288
sysctl -w net.core.rmem_default=262144
sysctl -w net.core.wmem_default=262144
sysctl -w net.core.optmem_max=20480
sysctl -w net.core.netdev_max_backlog=25000
sysctl -w net.unix.max_dgram_qlen=50
echo "network boost---------[OK]" | tee -a $LOG_FILE;
# cleaner
busybox rm -f /data/anr/*.*
busybox rm -f /data/cache/*.*
busybox rm -f /data/local/log/*.*
busybox rm -f /data/local/tmp/*.*
busybox rm -f /data/last_alog/*
busybox rm -f /data/last_kmsg/*
busybox rm -f /data/mlog/*
busybox rm -f /data/tombstones/*
busybox rm -f /data/system/dropbox/*
chmod 400 /data/system/dropbox
busybox rm /dev/log/main
busybox rm -f /data/system/usagestats/*
busybox chmod 400 /data/system/usagestats
export sampling_rate=10000
export up_threshold=80
echo "memory cleaner--------[OK]" | tee -a $LOG_FILE;
if [ -e /data/anr/*.* ]; then
echo "-anr not cleaned" | tee -a $LOG_FILE; else
echo "-anr cleaned" | tee -a $LOG_FILE
fi;
if [ -e /data/local/tmp/*.* ]; then
echo "-local/tmp not cleaned" | tee -a $LOG_FILE; else
echo "-local/tmp cleaned" | tee -a $LOG_FILE
fi;
if [ -e /data/cache/*.* ]; then
echo "-cache not cleaned" | tee -a $LOG_FILE; else
echo "-cache cleaned" | tee -a $LOG_FILE
fi;
if [ -e /data/last_log/*.* ]; then
echo "-log not cleaned" | tee -a $LOG_FILE; else
echo "-log cleaned" | tee -a $LOG_FILE
fi;
if [ -e /data/tombstones/*.* ]; then
echo "-tombstones not cleaned" | tee -a $LOG_FILE; else
echo "-tombstones cleaned" | tee -a $LOG_FILE
fi;
# minfree
echo "64" > /sys/module/lowmemorykiller/parameters/cost
echo "0,1,3,5,7,15" > /sys/module/lowmemorykiller/parameters/adj
echo "4096,5182,6400,15360,17920,20480" > /sys/module/lowmemorykiller/parameters/minfree
echo "minfree setting-------[OK]
-minfree value
$( cat /sys/module/lowmemorykiller/parameters/adj )
$( cat /sys/module/lowmemorykiller/parameters/minfree )" | tee -a $LOG_FILE;
# end
echo "==========================
done at:
$( date +"%m-%d-%Y %H:%M:%S" )
all praise is due to Allah
==========================
-- have a nice day --
[email protected]
==========================" | tee -a $LOG_FILE;
note that the line started with # are not executed.
Code:
#!/system/bin/sh
# kuro tweak2: the setprop stuffs and journalismoff
# [email protected] (2012) - lol...i'm just joking. no copyright or whatsoever
# contact : [email protected]
# v.1 - first release
# v.1.1 - new log system and new tweak added.
# v.1.2 - new tweak for xperia
LOG_FILE=/data/kuro_tweak2.log
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
# the preface
echo "==========================
# TWEAK KURO2-LOG FILE #
==========================
in the name of Allah,
the most beneficent,
the most mercifull
==========================
system information:
vendor : $( getprop ro.product.brand )
model : $( getprop ro.product.model )
ROM : $( getprop ro.build.display.id )
running the script...
start at:
$( date +"%m-%d-%Y %H:%M:%S" )
==========================" | tee -a $LOG_FILE;
# 3g mod
setprop ro.ril.enable.dtm 1
setprop ro.ril.gprsclass 10
setprop ro.ril.hep 1
setprop ro.ril.enable.3g.prefix 1
setprop ro.ril.hsdpa.category 8
setprop ro.ril.hsupa.category 6
setprop ro.ril.hsxpa 2
setprop ro.ril.enable.a53 1
setprop ro.ril.htcmaskw1.bitmask 4294967295
setprop ro.ril.htcmaskw1 14449
setprop ro.config.hw_fast_dormancy 1
echo "3g signal mod---------[OK]" | tee -a $LOG_FILE;
# battery mod n media
setprop debug.performance.tuning 1
setprop pm.sleep_mode 1
setprop windowsmgr.max_events_per_sec 90
setprop ro.ril.disable.power.collapse 0
setprop wifi.supplicant_scan_interval 180
setprop ro.media.enc.jpeg.quality 100
setprop debug.sf.hw 1
setprop ro.vold.umsdirtyratio 20
echo "battery n media-------[OK]" | tee -a $LOG_FILE;
# performance
# setprop persist.sys.purgeable_assets 1
setprop dalvik.vm.execution-mode int:jit
setprop dalvik.vm.dexopt-flags l=x,n=z,m=y
setprop dalvik.vm.verify-bytecode false
setprop dalvik.vm.heapsize 64m
setprop dalvik.vm.heapgrowthlimit 48m
setprop dalvik.vm.dexopt-data-only 1
setprop dalvik.vm.jmiopts forcecopy
setprop dalvik.vm.lockprof.treshold 250
setprop ro.kernel.android.checkjni 0
setprop ro.telephony.call_ring.delay 0
setprop debug.kill_allocating_task 1
# defaul is zero
# mem adj
setprop ro.FOREGROUND_APP_ADJ 0
setprop ro.VISIBLE_APP_ADJ 4
setprop ro.SECONDARY_SERVER_ADJ 6
setprop ro.HIDDEN_APP_MIN_ADJ 8
setprop ro.CONTENT_PROVIDER_ADJ 12
setprop ro.EMPTY_APP_ADJ 15
# mem minfree
setprop ro.FOREGROUND_APP_MEM 1536
setprop ro.VISIBLE_APP_MEM 2048
setprop ro.SECONDARY_SERVER_MEM 4096
setprop ro.HIDDEN_APP_MEM 5120
setprop ro.CONTENT_PROVIDER_MEM 5632
setprop ro.EMPTY_APP_MEM 6144
echo "performance-----------[OK]" | tee -a $LOG_FILE;
# Disable debugging notify icon on statusbar
setprop persist.adb.notify 0
# Disable blackscreen issue after a call
setprop ro.lge.proximity.delay 0
setprop mot.proximity.delay 0
# Phone will not wake up from hitting the volume rocker
# setprop ro.config.hwfeature_wakeupkey 0
# Enable display Dithering
# setprop persist.sys.use_dithering 1
# xperia mental
setprop persist.android.strictmode 0
setprop persist.sys.ui.hw 1
setprop ro.max.fling_velocity 12000
setprop ro.min.fling_velocity 2000
setprop ro.mot.eri.losalert.delay 1000
setprop ro.kernel.checkjni 0
setprop ro.config.nocheckin 1
setprop debug.qctwa.statusbar 1
setprop debug.qctwa.preservebuf 1
setprop debug.qc.hardware true
setprop com.qc.hardware true
setprop profiler.force_disable_err_rpt 1
setprop profiler.force_disable_ulog 1
setprop logcat.live disable
setprop net.ppp0.dns1 8.8.8.8
setprop net.ppp0.dns2 8.8.4.4
setprop net.dns1 8.8.8.8
setprop net.rmnet0.dns1 8.8.8.8
setprop net.rmnet0.dns2 8.8.4.4
setprop net.dns2 8.8.4.4
setprop debug.egl.profiler 1
setprop debug.egl.hw 1
setprop debug.composition.type gpu
echo "Xperia tweak----------[OK]" | tee -a $LOG_FILE;
# no journal
tune2fs -o journal_data_writeback /dev/block/mmcblk0p10
tune2fs -o journal_data_writeback /dev/block/mmcblk0p11
tune2fs -o journal_data_writeback /dev/block/mmcblk0p15
echo "no journal------------[OK]" | tee -a $LOG_FILE;
# end
echo "==========================
done at:
$( date +"%m-%d-%Y %H:%M:%S" )
all praise is due to Allah
==========================
-- have a nice day --
[email protected]
==========================" | tee -a $LOG_FILE;
the journalism stuff require tune2fs binary file installed into your system.
Code:
#!/system/bin/sh
#keep beats
PPID=$(pidof org.equalizerapp);
echo "17" > /proc/$PPID/oom_adj;
renice -18 $PPID;
#set
setprop.keep_app_1 org.equalizerapp
#audio resample
setprop af.resample 48000;
setprop af.resampler.quality 255;
setprop ro.audio.samplerate 48000;
setprop ro.audio.pcm.samplerate 48000;
setprop persyst.af.resample 48000;
setprop persyst.af.resampler.quality 255;
setprop persyst.ro.audio.samplerate 48000;
setprop persyst.ro.audio.pcm.samplerate 48000;
setprop persyst.dev.pm.dyn_samplingrate 1;
this one is modifying our sound quality. some of the part are still under my investigation but the audio resample part is really working.
Code:
#!/system/bin/sh
# DarkyROM 2011
# Much faster zipalign.
# Changelog:
# 1.3 (5/8/12) new log system. system remount deleted (by: kurotsugi)
# 1.2 (17/1/11) Added /data/zipalign.db file for faster apk check (ninpo,Bo$s)
# 1.1 (12/1/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
# 1.0 (11/30/09) Original
LOG_FILE=/data/kuro_zalign.log
ZIPALIGNDB=/data/kuro_zalign.db
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
if [ ! -f $ZIPALIGNDB ]; then
touch $ZIPALIGNDB;
fi;
# the preface
echo "==========================
# TWEAK KURO-ZALIGN FILE #
==========================
in the name of Allah,
the most beneficent,
the most mercifull
==========================
system information:
vendor : $( getprop ro.product.brand )
model : $( getprop ro.product.model )
ROM : $( getprop ro.build.display.id )
running the script...
start at:
$( date +"%m-%d-%Y %H:%M:%S" )
==========================" | tee -a $LOG_FILE;
# zipalign script (not modified)
for DIR in /system/app /data/app ; do
cd $DIR
for APK in *.apk ; do
if [ $APK -ot $ZIPALIGNDB ] && [ $(grep "$DIR/$APK" $ZIPALIGNDB|wc -l) -gt 0 ] ; then
echo "zipaligned: $DIR/$APK" | tee -a $LOG_FILE
else
zipalign -c 4 $APK
if [ $? -eq 0 ] ; then
echo "now zipaligned: $DIR/$APK" | tee -a $LOG_FILE
grep "$DIR/$APK" $ZIPALIGNDB > /dev/null || echo $DIR/$APK >> $ZIPALIGNDB
else
echo "Now aligning: $DIR/$APK" | tee -a $LOG_FILE
zipalign -f 4 $APK /cache/$APK
busybox mount -o rw,remount /system
cp -f -p /cache/$APK $APK
busybox rm -f /cache/$APK
grep "$DIR/$APK" $ZIPALIGNDB > /dev/null || echo $DIR/$APK >> $ZIPALIGNDB
fi
fi
done
done
touch $ZIPALIGNDB
# end
echo "==========================
done at:
$( date +"%m-%d-%Y %H:%M:%S" )
all praise is due to Allah
==========================
-- have a nice day --
[email protected]
==========================" | tee -a $LOG_FILE;
the famous zipalign script. i modify the log system. you need the zipalign binary to use it
Code:
#!/system/bin/sh
# kuro akuro: new data2sd method
# [email protected] (2012) - lol...i'm just joking. no copyright or whatsoever
# contact : [email protected]
# v.1 - first release
# v.1.1 - automated system, new build,
LOG_FILE=/data/kuro_akuro.log
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
# the preface
echo "==========================
# TWEAK AKURO-LOG FILE #
==========================
in the name of Allah,
the most beneficent,
the most mercifull
==========================
system information:
vendor : $( getprop ro.product.brand )
model : $( getprop ro.product.model )
ROM : $( getprop ro.build.display.id )
running the script...
start at:
$( date +"%m-%d-%Y %H:%M:%S" )
==========================" | tee -a $LOG_FILE;
# fix sdcard speed
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]; then
echo "2048" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
echo "fix sdcard speed tweak [OK]" | tee -a $LOG_FILE;
fi;
# create sdext dir in /system
if [ ! -e /system/sd ]; then
echo "WARNING!: no sdext dir
please create dir /system/sd" | tee -a $LOG_FILE;
fi;
echo "SDEXT directory check [OK]" | tee -a $LOG_FILE;
# mount sdcard all type
busybox mount -o noatime,nodiratime,nosuid,nodev /dev/block/mmcblk0p2 /system/sd;
mountext=`busybox mount | egrep 'ext2|ext3|ext4'`;
if [ -n "$mountext" ]; then
chown 1000:1000 /system/sd;
chmod 771 /system/sd;
fi;
echo "akuro: sd-ext mount [OK]" | tee -a $LOG_FILE;
# create the directories
if [ ! -e /system/sd/app ]; then
mkdir /system/sd/app;
busybox mv /data/app/* /system/sd/app;
fi;
if [ ! -e /system/sd/dalvik-cache ]; then
mkdir /system/sd/dalvik-cache;
busybox mv /data/dalvik-cache/* /system/sd/dalvik-cache;
fi;
echo "akuro: preparation step [OK]" | tee -a $LOG_FILE;
# mount sd to data directories
mount -o bind /system/sd/app /data/app;
chown 1000:1000 /system/sd/app;
chmod 771 /system/sd/app;
if [ -e /system/sd/app ]; then
echo "akuro: app mount step [OK]" | tee -a $LOG_FILE; else
echo "akuro: app mount step [FAIL]" | tee -a $LOG_FILE;
fi;
mount -o bind /system/sd/dalvik-cache /data/dalvik-cache;
chown 1000:1000 /system/sd/dalvik-cache;
chmod 771 /system/sd/dalvik-cache;
if [ -e /system/sd/dalvik-cache ]; then
echo "akuro: dalvik mount step [OK]" | tee -a $LOG_FILE; else
echo "akuro: dalvik mount step [FAIL]" | tee -a $LOG_FILE;
fi;
if [ -e /system/sd/data ]; then
mount -o bind /system/sd/data /data/data;
chown 1000:1000 /system/sd/data;
chmod 771 /system/sd/data;
fi;
if [ -e /system/sd/data ]; then
echo "akuro: data mount step [OK]" | tee -a $LOG_FILE; else
echo "akuro: data mount step [FAIL]" | tee -a $LOG_FILE;
fi;
# end
echo "==========================
done at:
$( date +"%m-%d-%Y %H:%M:%S" )
all praise is due to Allah
==========================
-- have a nice day --
[email protected]
==========================" | tee -a $LOG_FILE;
my own made akuro script. it works to move dalvik-cache,app, and /data/folder from our internal memory to ext2/3/4 partition on our sdcard. it will save our internal mem space. sadly this one is for samsung device. you need to modify some part of it.
have a nice tweaking
EDIT: btw, for my first and second tweak, you should use your own value. my value is taken from sgy and still under investigation to get better result.

as I've promised I'll tell you how to build your own rom. however, I made this thread for someone who started to build his own rom. I want to made this post understandable even for a newb in android world. this guide doesn't recover stuffs like how to customize the theme or add more feature into your your rom. that one require a lot of resources and you need to learn it by yourself.
the first thing you need is the system files. you can get it by dumping your system partition, modify an existed rom of even build it from scratch by yourself. assume if you already have one, the next thing you should learn is the updater script.
basic rom installer structure will be something like this.
1. meta-inf folder : contain updater script and updater binary to install your rom
2. system folder : contain your system files
3. additional files and script.
for a start, you can get meta-inf folder from here http://www.mediafire.com/?nxgiz0993brp9re
it contain a basic updater script to install a rom. it designed to install a rom for another device. you need to modify it if you want to use it.
if you open the updater script, you'll see this
Code:
ui_print("Installing ...");
ui_print(" ");
unmount("/system");
mount("ext3", "EMMC", "/dev/block/mmcblk0p2", "/system");
show_progress(0.100000, 0);
delete_recursive("/system");
show_progress(0.100000, 0);
show_progress(0.500000, 40);
ui_print("Installing System...");
package_extract_dir("system", "/system");
symlink("toolbox", "/system/bin/schedtop");
symlink("toolbox", "/system/bin/df");
symlink("toolbox", "/system/bin/insmod");
symlink("toolbox", "/system/bin/top");
symlink("toolbox", "/system/bin/iftop");
symlink("toolbox", "/system/bin/getevent");
symlink("toolbox", "/system/bin/rm");
symlink("toolbox", "/system/bin/rmmod");
symlink("toolbox", "/system/bin/printenv");
symlink("toolbox", "/system/bin/start");
symlink("toolbox", "/system/bin/kill");
symlink("toolbox", "/system/bin/vmstat");
symlink("toolbox", "/system/bin/stop");
symlink("toolbox", "/system/bin/ioctl");
symlink("toolbox", "/system/bin/cmp");
symlink("toolbox", "/system/bin/ps");
symlink("toolbox", "/system/bin/chmod");
symlink("toolbox", "/system/bin/sendevent");
symlink("toolbox", "/system/bin/netstat");
symlink("toolbox", "/system/bin/setconsole");
symlink("toolbox", "/system/bin/cat");
symlink("toolbox", "/system/bin/mount");
symlink("toolbox", "/system/bin/ln");
symlink("toolbox", "/system/bin/log");
symlink("toolbox", "/system/bin/reboot");
symlink("toolbox", "/system/bin/dd");
symlink("toolbox", "/system/bin/id");
symlink("toolbox", "/system/bin/getprop");
symlink("toolbox", "/system/bin/lsmod");
symlink("toolbox", "/system/bin/ionice");
symlink("toolbox", "/system/bin/newfs_msdos");
symlink("toolbox", "/system/bin/setprop");
symlink("toolbox", "/system/bin/sync");
symlink("toolbox", "/system/bin/umount");
symlink("toolbox", "/system/bin/watchprops");
symlink("toolbox", "/system/bin/route");
symlink("toolbox", "/system/bin/notify");
symlink("toolbox", "/system/bin/uptime");
symlink("toolbox", "/system/bin/wipe");
symlink("toolbox", "/system/bin/nandread");
symlink("toolbox", "/system/bin/lsof");
symlink("toolbox", "/system/bin/mkdir");
symlink("toolbox", "/system/bin/rmdir");
symlink("toolbox", "/system/bin/hd");
symlink("toolbox", "/system/bin/ls");
symlink("toolbox", "/system/bin/chown");
symlink("toolbox", "/system/bin/dmesg");
symlink("toolbox", "/system/bin/sleep");
symlink("toolbox", "/system/bin/renice");
symlink("toolbox", "/system/bin/ifconfig");
symlink("toolbox", "/system/bin/mv");
symlink("toolbox", "/system/bin/date");
symlink("toolbox", "/system/bin/smd");
symlink("dumpstate", "/system/bin/dumpmesg");
set_perm_recursive(0, 0, 0755, 0644, "/system");
set_perm_recursive(0, 0, 0777, 0777, "/system/etc/init.d");
set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");
set_perm(0, 3003, 06755, "/system/bin/ip");
set_perm(0, 3003, 02750, "/system/bin/netcfg");
set_perm(0, 3004, 02755, "/system/bin/ping");
set_perm(0, 2000, 06750, "/system/bin/run-as");
set_perm_recursive(1002, 1002, 0755, 0440, "/system/etc/bluetooth");
set_perm(0, 0, 0755, "/system/etc/bluetooth");
set_perm(1000, 1000, 0640, "/system/etc/bluetooth/auto_pairing.conf");
set_perm(3002, 3002, 0444, "/system/etc/bluetooth/blacklist.conf");
set_perm(1002, 1002, 0755, "/system/etc/dbus.conf");
set_perm(1014, 2000, 0755, "/system/etc/dhcpcd/dhcpcd-run-hooks");
set_perm(0, 2000, 0550, "/system/etc/init.goldfish.sh");
set_perm(0, 0, 04755, "/system/bin/bash");
symlink("/system/bin/bash", "/system/bin/sh");
set_perm(0, 0, 0777, "/system/bin/a2sd");
set_perm(0, 0, 0777, "/system/rtc/init.d/S95allinone");
set_perm(0, 0, 0777, "/system/etc/init.d/00banner");
set_perm(0, 0, 0777, "/system/etc/init.d/01sysctl");
set_perm(0, 0, 0777, "/system/etc/init.d/02firstboot");
set_perm(0, 0, 0777, "/system/etc/init.d/03mountsd");
set_perm(0, 0, 0777, "/system/etc/init.d/04apps2sd");
set_perm(0, 0, 0777, "/system/etc/init.d/99complete");
set_perm(0, 0, 0777, "/system/bin/launcha2sd");
set_perm(0, 0, 0777, "/system/bin/starta2sd");
set_perm(0, 0, 0777, "/system/bin/jita2sd");
set_perm(0, 0, 0777, "/system/bin/chka2sd");
set_perm(0, 0, 0777, "/system/bin/zipalign");
set_perm(0, 0, 0777, "/system/bin/sysinit");
set_perm(0, 0, 0777, "/system/bin/busybox.a2sd");
set_perm(0, 0, 0644, "/system/bin/apps2sd.hlp");
set_perm(0, 0, 0777, "/system/xbin/a2sd");
set_perm(0, 0, 0777, "/system/bin/dtinstall");
set_perm(0, 0, 06755, "/system/bin/su");
symlink("/system/bin/su", "/system/xbin/su");
set_perm_recursive(0, 0, 0755, 0555, "/system/etc/ppp");
set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");
show_progress(0.1, 10);
show_progress(0.2, 0);
set_perm(0, 1000, 0755, "/system/xbin/busybox");
package_extract_file("installbusybox", "/tmp/installbusybox");
set_perm(0, 0, 0777, "/tmp/installbusybox");
run_program("/tmp/installbusybox");
ui_print("Installing Boot...");
show_progress(0.2, 10);
show_progress(0.100000, 0);
ui_print(" ");
ui_print("Installation Completed!!!!");
ui_print(" ");
ui_print("Enjoy...");
ui_print(" ");
unmount("/system");
ui_print("Welcome to MySs Rom ");
lets breakdown the updater script. basic updater script contain several parts. from above script, we can divide it into these parts:
1. UI SCRIPT
it will give you information about your rom installation.
it consist of two part. the first one is the ui_print, it used to show some text when you install the rom. for an example, ui_print("Welcome to MySs Rom "); it will print Welcome to MySs Rom on your screen. the form is
Code:
ui_print("<your text>")
the second one is the show progress stuff. for an example show_progress(0.5, 20);.the form is
Code:
show_progress(<the progress part 0 to 1>, <time needed to reach progress part>);
if you look into the example, it means that the installation progress bar will reach 50% in 20 second.
2. INSTALLER SCRIPT
the most crucial part. it install the files into your system partition.
it consist of three part. the first one is the mounter script. it used to mount a certain partition when you install the rom. this is one of the example mount("ext3", "EMMC", "/dev/block/mmcblk0p2", "/system");. the basic form is
Code:
mount("<partition file>", "<partition type>", "<partition location>", "<place where it mounted>");
the second part is formater script. you can do it by format the entire partition or simply delete all the files in the partition. I always choose the second one to avoid getting a corrupted partition. the basic form is
Code:
delete_recursive("<folder address>")
# or in an example
delete_recursive("/system");
the last part is the one used to copy the files into your system. you can do it in two ways. the first one you copy the files one by one. you'll use something like this.package_extract_file("installbusybox", "/tmp/installbusybox");. the form is package_extract_file("<file name and address>", "<where you want to copy it>");. the second one is you copy the entire folder. you'll use package_extract_dir("system", "/system");. the form is package_extract_dir("<folder name inside your zip file>", "<where to copy it>");
3. MODIFIER SCRIPT
to change the permission you'll use
Code:
set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");
# if you want to change it based on the folder
# basic form
set_perm_recursive(<1st owner>, <2nd owner>, <folder permission>, <file permission>, "/system/bin")
set_perm(0, 3003, 06755, "/system/bin/ip");
# if you want to change it file by file
# basic form
set_perm(<1st owner>, <2nd owner>, <permission>, "/system/bin/ip")
to create symlink
Code:
symlink("toolbox", "/system/bin/ls");
# basic form
symlink("<the file name>", "<the link name>");
4. ADDITIONAL SCRIPT
it mainly use to run certain script. for an example
Code:
package_extract_file("installbusybox", "/tmp/installbusybox");
set_perm(0, 0, 0777, "/tmp/installbusybox");
run_program("/tmp/installbusybox"); [code] first thing you should remember is that you need to extract the script first. in this case, is the installbusybox file to /tmp. to run the script you'll need to change the permission and run it with run_program. the basic form is [b]run_program("<the file>")[/b]
[/hide]
now, after you know about the updater script, you need to create the proper updater script for your rom. the basic script will be.
1. mount all needed partition. some rom installation need to mount /data, /cache, etc. make sure you already mount all of them
2. delete all the old system files.
3. copy all new system files into your system.
4. change the owner and the permission of certain files and folders. make sure you have the exact owner and permission setting of all the files copied into /system. the default is owner: root. permission: rw-r-r.
5. create symlinks.
6. run the additional script.
the last step, pack all the files into a single zip file and install your rom. enjoy your rom.
ADDITIONAL RESOURCE
1. introduction for edify updater script [url]http://forum.xda-developers.com/showthread.php?t=1669489[/url]
2. dsixda's kitchen [url]http://forum.xda-developers.com/showthread.php?t=633246[/url]
3. kernel kitchen [url]http://forum.xda-developers.com/showthread.php?t=1659584[/url]

Thanks king! Always wanted to learn that!
Sent from my ST23i using xda app-developers app

nice one..thanks for your work.:good:

thanks, nice info

Good post will wait for some more cool stuffs

thread updated...I don't know. I hope you can understand this simple guide. I made this thread so that we will have more rom devs in near future. please don't use it to steal another's works.

help
kurotsugi said:
thread updated...I don't know. I hope you can understand this simple guide. I made this thread so that we will have more rom devs in near future. please don't use it to steal another's works.
Click to expand...
Click to collapse
hai gan.. terimakasih untuk tut.nya kembangkan terus skill yang anda punya.
saya jadi ikut bangga .. heee.
gan saya boleh minta tolong. kenapa kalau saya buat jaringan ad hoc dikomputer lalu saya coba check di hp saya (sony tipo) itu nggak mau kedeteksi dan konek? denger-denger katanya suruh modif wpa_nya tapi tetep nggak bisa.
tolong bantu saya gan,
terimakasih. :angel:

Pls keep the language to english
Inviato dal mio ST26i con Tapatalk 2

thanks for this tut, I'll bookrmark this topic since I'm still new to this android thingy

Beautiful tutorial Thanks:highfive:

Java_Indo said:
hai gan.. terimakasih untuk tut.nya kembangkan terus skill yang anda punya.
saya jadi ikut bangga .. heee.
gan saya boleh minta tolong. kenapa kalau saya buat jaringan ad hoc dikomputer lalu saya coba check di hp saya (sony tipo) itu nggak mau kedeteksi dan konek? denger-denger katanya suruh modif wpa_nya tapi tetep nggak bisa.
tolong bantu saya gan,
terimakasih. :angel:
Click to expand...
Click to collapse
Pakai bahasa inggris..
This is international forum, all around the world is here..
Anyway, thanka for this guide.. bookmarked this

Thanks a lot!

Related

[Q] How do i Odex a build from my computer

all of the tutorials i have seen on how to odex is pushing a script to the phone after its installed i am looking to do this before first boot. any help its appreciated
here is the script from an and build, try in linux and see what happens (of course edit for your folder structure)
#!/system/bin/sh
#
# system/app odex-er by Paul O'Brien @ www.MoDaCo.com
#
# experimental - nandroid backup before you run this script!
#
# version 0.1, 29th January 2010
# updated by Martin Johnson, M.J.Johnson @ massey.ac.nz June 2010 for Vogue
#
rm /tmp.odex
cd /data/app
# Check for and delete leftover .odex files after uninstalled apps
for filename in *.odex
do
name=`basename $filename .odex`
if [ ! -f $name.apk -a -f $filename ]
then
rm $filename
echo "Removed $filename"
fi
done;
# Loop through all installed apps
for filename in *.apk
do
name=`basename $filename .apk`
if [ ! -f $name.odex -o $filename -nt $name.odex ]
then
# step 1 - odex the apk
rm -f /tmp.odex
/system/bin/dexopt-wrapper $filename /tmp.odex
# step 2 - did we succesfully odex?
if [ $? -eq 0 ]
then
# step 3 - remove the classes.dex from the apk
/system/bin/zip -d $filename classes.dex
# continue only if classes.dex was present
if [ $? -eq 0 ]
then
# step 4 - zipalign, just in case
/system/bin/zipalign -f -v 4 $filename /$filename.new
mv -f /$filename.new $filename
mv -f /tmp.odex $name.odex
touch $name.odex
echo "Odexed $filename"
else
echo "Error $filename did not contain classes.dex"
fi
else
echo "Error creating odex from $filename"
fi
else
echo "Nothing to do: $filename"
fi
done;
Any more thoughts??

[SCRIPT] Run init.d scripts once every N days [ZipAlign/SQLite3/others]

There are many ROMs that include the ZipAlign or SQLite3 vacuum on boot, but these command are not really needed to run on EVERY boot, once every few days can be enough, so I came out with this script.
To run it, you need to have busybox with the stat applet (should be there always), which gives information about a file, including last modification date.
This is done is by checking the last modification date on a file, which is touched or changed only when the main script is executed.
Currently I modified the ZipAlign and SQLite vacuum in my own rom to use this technique, and they seem to work fine. The monitored file is the log of the operation done, which is stored in the /data/ directory
ZipAlign on Boot:
Code:
#!/system/bin/sh
# Automatic ZipAlign by Wes Garner
# ZipAlign files in /data that have not been previously ZipAligned (using md5sum)
# Thanks to oknowton for the changes
# Changelog:
# 1.0 (11/30/09) Original
# 1.1 (12/01/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
# 1.2 (06/01/13) Run the main script only once every N days (default 7 days, 1 week) (mcbyte_it)
[COLOR="DarkRed"]LOG_FILE=/data/zipalign.log
#Interval between ZipAlign runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"] if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "Starting Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for apk in /data/app/*.apk ; do
zipalign -c 4 $apk;
ZIPCHECK=$?;
if [ $ZIPCHECK -eq 1 ]; then
echo ZipAligning $(basename $apk) | tee -a $LOG_FILE;
zipalign -f 4 $apk /cache/$(basename $apk);
if [ -e /cache/$(basename $apk) ]; then
cp -f -p /cache/$(basename $apk) $apk | tee -a $LOG_FILE;
rm /cache/$(basename $apk);
else
echo ZipAligning $(basename $apk) Failed | tee -a $LOG_FILE;
fi;
else
echo ZipAlign already completed on $apk | tee -a $LOG_FILE;
fi;
done;
echo "Automatic ZipAlign finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/color]
[COLOR="DarkRed"]fi[/COLOR]
SQLite3 vacuum:
Code:
#!/system/bin/sh
# ========================================
# init.d script for McByte jkSGS3
# ========================================
# SQLite database vaccum
# Frequent inserts, updates, and deletes can cause the database file to become fragmented - where data for a single table or index is scattered around the database file.
# Running VACUUM ensures that each table and index is largely stored contiguously within the database file.
# In some cases, VACUUM may also reduce the number of partially filled pages in the database, reducing the size of the database file further.
# sqlite3 binary in /system/xbin is required!
# Changelog
# v1.0 - (??/??/????) - original version
# v1.1 - (06/01/2013) - run only every X seconds, default = 1 week (mcbyte_it)
#
[COLOR="DarkRed"]# Log file location
LOG_FILE=/data/sqlite.log
#Interval between SQLite3 runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"]if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "SQLite database VACUUM and REINDEX started at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for i in `busybox find /d* -iname "*.db"`; do
/system/xbin/sqlite3 $i 'VACUUM;';
resVac=$?
if [ $resVac == 0 ]; then
resVac="SUCCESS";
else
resVac="ERRCODE-$resVac";
fi;
/system/xbin/sqlite3 $i 'REINDEX;';
resIndex=$?
if [ $resIndex == 0 ]; then
resIndex="SUCCESS";
else
resIndex="ERRCODE-$resIndex";
fi;
echo "Database $i: VACUUM=$resVac REINDEX=$resIndex" | tee -a $LOG_FILE;
done
echo "SQLite database VACUUM and REINDEX finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/COLOR]
[COLOR="DarkRed"]fi;[/COLOR]
This looks like a great idea :good: is it possible to easily change the intended interval at which yo want the scripts to run though?
HTCDreamOn said:
This looks like a great idea :good: is it possible to easily change the intended interval at which yo want the scripts to run though?
Click to expand...
Click to collapse
Sure, check the examples I posted, they are well commented. Just change the value of the "RUN_EVERY".
I'll take a look
mcbyte_it said:
Sure, check the examples I posted, they are well commented. Just change the value of the "RUN_EVERY".
Click to expand...
Click to collapse
Awesome, I'll give them a go!
how can i modify this script to zimpalign /system/app too?
UnitedOceanic said:
how can i modify this script to zimpalign /system/app too?
Click to expand...
Click to collapse
There is no much sense of zipaligning system apps every x days, once they are zipaligned (when making the ROM zip), they remain zipaligned. some apks might need zip aligning if they get moved/installed as system apps after rom install.
Not to mention the stability, I don't know the exact boot mechanism of android, if you start zip aligning system apps during the init.d, it might cause instability to some system apps.
But if you mount the /system partition as read/write, do the zipaligning loop, then remount it as read-only, it should be possible.
still, I don't recommend doing so....
i pushed many apps from /data/app to /system/app.
I deleted the libs from the apks and copied them to /system/libs to saved space. however I forgot to zipalign the apks after removing the libs. I used the zipalign script from the rom toolbox app unfortunately it didn't work as expected. it just deleted the apps that should have been zipaligned.
I don't really want to zipalign /system at every boot. just once for the modified apks.
mcbyte_it said:
There are many ROMs that include the ZipAlign or SQLite3 vacuum on boot, but these command are not really needed to run on EVERY boot, once every few days can be enough, so I came out with this script.
To run it, you need to have busybox with the stat applet (should be there always), which gives information about a file, including last modification date.
This is done is by checking the last modification date on a file, which is touched or changed only when the main script is executed.
Currently I modified the ZipAlign and SQLite vacuum in my own rom to use this technique, and they seem to work fine. The monitored file is the log of the operation done, which is stored in the /data/ directory
ZipAlign on Boot:
Code:
#!/system/bin/sh
# Automatic ZipAlign by Wes Garner
# ZipAlign files in /data that have not been previously ZipAligned (using md5sum)
# Thanks to oknowton for the changes
# Changelog:
# 1.0 (11/30/09) Original
# 1.1 (12/01/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
# 1.2 (06/01/13) Run the main script only once every N days (default 7 days, 1 week) (mcbyte_it)
[COLOR="DarkRed"]LOG_FILE=/data/zipalign.log
#Interval between ZipAlign runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"] if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "Starting Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for apk in /data/app/*.apk ; do
zipalign -c 4 $apk;
ZIPCHECK=$?;
if [ $ZIPCHECK -eq 1 ]; then
echo ZipAligning $(basename $apk) | tee -a $LOG_FILE;
zipalign -f 4 $apk /cache/$(basename $apk);
if [ -e /cache/$(basename $apk) ]; then
cp -f -p /cache/$(basename $apk) $apk | tee -a $LOG_FILE;
rm /cache/$(basename $apk);
else
echo ZipAligning $(basename $apk) Failed | tee -a $LOG_FILE;
fi;
else
echo ZipAlign already completed on $apk | tee -a $LOG_FILE;
fi;
done;
echo "Automatic ZipAlign finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/color]
[COLOR="DarkRed"]fi[/COLOR]
SQLite3 vacuum:
Code:
#!/system/bin/sh
# ========================================
# init.d script for McByte jkSGS3
# ========================================
# SQLite database vaccum
# Frequent inserts, updates, and deletes can cause the database file to become fragmented - where data for a single table or index is scattered around the database file.
# Running VACUUM ensures that each table and index is largely stored contiguously within the database file.
# In some cases, VACUUM may also reduce the number of partially filled pages in the database, reducing the size of the database file further.
# sqlite3 binary in /system/xbin is required!
# Changelog
# v1.0 - (??/??/????) - original version
# v1.1 - (06/01/2013) - run only every X seconds, default = 1 week (mcbyte_it)
#
[COLOR="DarkRed"]# Log file location
LOG_FILE=/data/sqlite.log
#Interval between SQLite3 runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"]if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "SQLite database VACUUM and REINDEX started at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for i in `busybox find /d* -iname "*.db"`; do
/system/xbin/sqlite3 $i 'VACUUM;';
resVac=$?
if [ $resVac == 0 ]; then
resVac="SUCCESS";
else
resVac="ERRCODE-$resVac";
fi;
/system/xbin/sqlite3 $i 'REINDEX;';
resIndex=$?
if [ $resIndex == 0 ]; then
resIndex="SUCCESS";
else
resIndex="ERRCODE-$resIndex";
fi;
echo "Database $i: VACUUM=$resVac REINDEX=$resIndex" | tee -a $LOG_FILE;
done
echo "SQLite database VACUUM and REINDEX finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/COLOR]
[COLOR="DarkRed"]fi;[/COLOR]
Click to expand...
Click to collapse
Thanks for this awesome script i was able to get an idea for this. I tried this two scripts but only zipalign works even though i have sqlite3 in stored in xbin.
mcbyte_it said:
There are many ROMs that include the ZipAlign or SQLite3 vacuum on boot, but these command are not really needed to run on EVERY boot, once every few days can be enough, so I came out with this script.
To run it, you need to have busybox with the stat applet (should be there always), which gives information about a file, including last modification date.
This is done is by checking the last modification date on a file, which is touched or changed only when the main script is executed.
Currently I modified the ZipAlign and SQLite vacuum in my own rom to use this technique, and they seem to work fine. The monitored file is the log of the operation done, which is stored in the /data/ directory
ZipAlign on Boot:
Code:
#!/system/bin/sh
# Automatic ZipAlign by Wes Garner
# ZipAlign files in /data that have not been previously ZipAligned (using md5sum)
# Thanks to oknowton for the changes
# Changelog:
# 1.0 (11/30/09) Original
# 1.1 (12/01/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
# 1.2 (06/01/13) Run the main script only once every N days (default 7 days, 1 week) (mcbyte_it)
[COLOR="DarkRed"]LOG_FILE=/data/zipalign.log
#Interval between ZipAlign runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"]if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "Starting Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for apk in /data/app/*.apk ; do
zipalign -c 4 $apk;
ZIPCHECK=$?;
if [ $ZIPCHECK -eq 1 ]; then
echo ZipAligning $(basename $apk) | tee -a $LOG_FILE;
zipalign -f 4 $apk /cache/$(basename $apk);
if [ -e /cache/$(basename $apk) ]; then
cp -f -p /cache/$(basename $apk) $apk | tee -a $LOG_FILE;
rm /cache/$(basename $apk);
else
echo ZipAligning $(basename $apk) Failed | tee -a $LOG_FILE;
fi;
else
echo ZipAlign already completed on $apk | tee -a $LOG_FILE;
fi;
done;
echo "Automatic ZipAlign finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/color]
[COLOR="DarkRed"]fi[/COLOR]
SQLite3 vacuum:
Code:
#!/system/bin/sh
# ========================================
# init.d script for McByte jkSGS3
# ========================================
# SQLite database vaccum
# Frequent inserts, updates, and deletes can cause the database file to become fragmented - where data for a single table or index is scattered around the database file.
# Running VACUUM ensures that each table and index is largely stored contiguously within the database file.
# In some cases, VACUUM may also reduce the number of partially filled pages in the database, reducing the size of the database file further.
# sqlite3 binary in /system/xbin is required!
# Changelog
# v1.0 - (??/??/????) - original version
# v1.1 - (06/01/2013) - run only every X seconds, default = 1 week (mcbyte_it)
#
[COLOR="DarkRed"]# Log file location
LOG_FILE=/data/sqlite.log
#Interval between SQLite3 runs, in seconds, 604800=1 week
RUN_EVERY=604800
# Get the last modify date of the Log file, if the file does not exist, set value to 0
if [ -e $LOG_FILE ]; then
LASTRUN=`stat -t $LOG_FILE | awk '{print $14}'`
else
LASTRUN=0
fi;
# Get current date in epoch format
CURRDATE=`date +%s`
# Check the interval
INTERVAL=$(expr $CURRDATE - $LASTRUN)
# If interval is more than the set one, then run the main script
if [ $INTERVAL -gt $RUN_EVERY ];
then[/COLOR]
[COLOR="Green"]if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
echo "SQLite database VACUUM and REINDEX started at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for i in `busybox find /d* -iname "*.db"`; do
/system/xbin/sqlite3 $i 'VACUUM;';
resVac=$?
if [ $resVac == 0 ]; then
resVac="SUCCESS";
else
resVac="ERRCODE-$resVac";
fi;
/system/xbin/sqlite3 $i 'REINDEX;';
resIndex=$?
if [ $resIndex == 0 ]; then
resIndex="SUCCESS";
else
resIndex="ERRCODE-$resIndex";
fi;
echo "Database $i: VACUUM=$resVac REINDEX=$resIndex" | tee -a $LOG_FILE;
done
echo "SQLite database VACUUM and REINDEX finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;[/COLOR]
[COLOR="DarkRed"]fi;[/COLOR]
Click to expand...
Click to collapse
Hi guys! I recently installed lollipop touch wiz and installed the two scripts on the Op, managed to get the sql script to work fine but when the zip align tries to run it errors out in the log, any advice to what I've done wrong or if you guys know of a change in lollipop that doesn't play nice with zip aligning?
Starting Automatic ZipAlign 06-04-2014 15:23:01
ZipAligning *.apk
ZipAligning *.apk Failed
Automatic ZipAlign finished at 06-04-2014 15:23:01
Click to expand...
Click to collapse
All I've done as far as modify the script is I got rid of the color tags.
Also the sql log shows the correct date as well, where this script does not.
Thank you in advance guys!
Any chance to make this flasheable thx!
how to make an specific init.d script runs every x minutes?
and when unlock the screen

[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.

[SCRIPT/ZIP][v1.3] Init.d enabler @ stock kernel / ALL DEVICES / NO BUSYBOX needed

I present you universal script to enable Init.d in ALL ANDROID DEVICES (I hope...) while running the stock kernel. NO BUSYBOX needed! It is packed in easy to use ZIP flashable
EDIT: This script will NOT work with Magisk! However, notice that using Magisk you do not need init.d support at all (you can put your scripts in /magisk/.core/post-fs-data.d OR /magisk/.core/service.d, depending on your needs).
Requirements:
- a rooted Android device (SuperSU)
- ANY tool to flash a ZIP (custom recovery or FlashFire app)
Installation:
1. Custom recovery - open file using "Install Zip" option and confirm "Yes - install..."
2. FlashFire - open file using "Flash ZIP or OTA" option (default mount options). Tap "FLASH"
How to check:
Just check if /data/initd_test.log file exists (optionally you can check its content)
Changelog:
v1.3:
★ This version automatically detects privileges of launched sh script used to trigger init.d and if these are not sufficient to remount /system rw - all commands are automatically expanded to "/su/bin/su -c [command]" or "/system/xbin/su -c [command]" (depending on SuperSU install mode)
★ Fixed problem with "exit 0" at the end of used sh script resulting that simply added new lines never worked. This version automatically detects such case and moves "exit 0" at the end of modified file
★ SELinux context autodetection - starting from v1.3 modified file has always exact same context as original file
★ BusyBox will not be used anymore, even if exists (checking the presence removed)
v1.2:
★ Starting from this version installer performs more secure and only 100% reversible actions. Original *.sh file is never touched (just renamed to *.bak to keep its original attributes, including context). Installer will try to set to modified file as many attributes taken from original file as possible (instead of forcing "known values").
★ Added initd_remover.zip. Use it if you want to remove Init.d support (enabled by script from this thread!) and restore 100% original system files
v1.1:
★ Avoids potential WiFi problems in case of Samsung S6 (and probably other Samsung's Exynos based devices running Android 6.0.1) - see post #3
v1.0:
★ Initial version
Enabler [sh script]:
Code:
#!/sbin/sh
# Init.d enabler by ALEXNDR (_alexndr @ XDA)
OUTFD=/proc/self/fd/$2
ui_print() {
echo -n -e "ui_print $1\n" >> $OUTFD
echo -n -e "ui_print\n" >> $OUTFD
}
set_perm() {
chown $1.$2 $4
chown $1:$2 $4
chmod $3 $4
if [ -z "$5" ] ; then
chcon u:object_r:system_file:s0 $4
else
chcon u:object_r:$5:s0 $4
fi
}
resolve_link() {
if [ -z "$1" ] || [ ! -e $1 ] ; then return 1 ; fi
local VAR=$1
while [ -h "$VAR" ] ; do
VAR=$(readlink $VAR)
done
echo $VAR
}
is_mounted() {
if [ -z "$2" ] ; then
cat /proc/mounts | grep $1 >/dev/null
else
cat /proc/mounts | grep $1 | grep "$2," >/dev/null
fi
return $?
}
ui_print " "
ui_print "=========================================="
ui_print "Init.d enabler by ALEXNDR (_alexndr @ XDA)"
ui_print "=========================================="
ui_print " "
SYSTEM=$(resolve_link $(find /dev/block/platform -type l | grep -i -m 1 "/app$")) ||
SYSTEM=$(resolve_link $(find /dev/block/platform -type l | grep -i -m 1 "/system$"))
if (! is_mounted /system) ; then mount -o rw /system ; fi
if (! is_mounted /system rw) ; then mount -o rw,remount /system ; fi
if (! is_mounted /system rw) ; then mount -t ext4 -o rw $SYSTEM /system ; fi
if (! is_mounted /system rw) ; then mount -t f2fs -o rw $SYSTEM /system ; fi
if (! is_mounted /system rw) ; then
ui_print "Failed! Can't mount /system rw, aborting!"
ui_print " "
exit 1
fi
SYSLIB=/system/lib
cat /system/build.prop | grep "ro.product.cpu.abilist=" | grep "64" >/dev/null && SYSLIB=/system/lib64
cat /system/build.prop | grep "ro.product.cpu.abi=" | grep "64" >/dev/null && SYSLIB=/system/lib64
# These files are prefered to trigger init.d scripts (in following order, if exists):
# /system/etc/init.*.post_boot.sh
# /system/etc/*.post_boot.sh
# /system/etc/init.*.boot.sh
# /system/etc/*.boot.sh
#
# /system/bin/debuggerd is used if there is no suitable *.sh file in /system/etc
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "/init\..*\.post_boot\.sh$") ||
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "\.post_boot\.sh$") ||
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "/init\..*\.boot\.sh$") ||
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "\.boot\.sh$") ||
BOOTFILE=/system/bin/debuggerd
BOOTCON=$(ls -Z $BOOTFILE 2>/dev/null | grep "u:object_r" | cut -d: -f3)
if [ -z "$BOOTCON" ] ; then
BOOTCON=$(LD_LIBRARY_PATH=$SYSLIB /system/bin/toolbox ls -Z $BOOTFILE 2>/dev/null | grep "u:object_r" | cut -d: -f3)
fi
if [ -z "$BOOTCON" ] ; then
BOOTCON=$(LD_LIBRARY_PATH=$SYSLIB /system/bin/toybox ls -Z $BOOTFILE 2>/dev/null | grep "u:object_r" | cut -d: -f3)
fi
if [ -z "$BOOTCON" ] ; then
BOOTCON=system_file
fi
cat $BOOTFILE | grep "^exit 0" >/dev/null && EXIT=true || EXIT=false
if [ -z "$(cat $BOOTFILE | grep "Init\.d")" ] ; then
if [ "$BOOTFILE" = "/system/bin/debuggerd" ] ; then
if [ ! -f /system/bin/debuggerd_real ] ; then
mv -f $BOOTFILE /system/bin/debuggerd_real
echo "#!/system/bin/sh" > $BOOTFILE
else
sed -i '/debuggerd_real/d' $BOOTFILE
fi
else
mv -f $BOOTFILE "$BOOTFILE.bak"
cp -pf "$BOOTFILE.bak" $BOOTFILE
if ($EXIT) ; then sed -i '/^exit 0/d' $BOOTFILE ; fi
echo "" >> $BOOTFILE
fi
echo "# Init.d support" >> $BOOTFILE
echo 'SU="$(ls /su/bin/su 2>/dev/null || ls /system/xbin/su) -c"' >> $BOOTFILE
echo 'mount -o rw,remount /system && SU="" || eval "$SU mount -o rw,remount /system"' >> $BOOTFILE
echo 'eval "$SU chmod 777 /system/etc/init.d"' >> $BOOTFILE
echo 'eval "$SU chmod 777 /system/etc/init.d/*"' >> $BOOTFILE
echo 'eval "$SU mount -o ro,remount /system"' >> $BOOTFILE
echo 'ls /system/etc/init.d/* 2>/dev/null | while read xfile ; do eval "$SU /system/bin/sh $xfile" ; done' >> $BOOTFILE
if [ "$BOOTFILE" = "/system/bin/debuggerd" ] ; then
echo '/system/bin/debuggerd_real [email protected]' >> $BOOTFILE
set_perm 0 2000 755 $BOOTFILE $BOOTCON
else
if ($EXIT) ; then echo "exit 0" >> $BOOTFILE ; fi
chcon u:object_r:$BOOTCON:s0 $BOOTFILE
fi
mkdir -p /system/etc/init.d
echo "#!/system/bin/sh" > /system/etc/init.d/00test
echo "# Init.d test" >> /system/etc/init.d/00test
echo 'echo "Init.d is working !!!" > /data/initd_test.log' >> /system/etc/init.d/00test
echo 'echo "excecuted on $(date +"%d-%m-%Y %r")" >> /data/initd_test.log' >> /system/etc/init.d/00test
echo "#!/system/bin/sh" > /system/etc/init.d/99SuperSUDaemon
echo "/system/xbin/daemonsu --auto-daemon &" >> /system/etc/init.d/99SuperSUDaemon
set_perm 0 0 777 /system/etc/init.d
set_perm 0 0 777 "/system/etc/init.d/*"
ui_print "Init.d has been successfully enabled"
ui_print "using following file run at boot:"
ui_print " "
ui_print "$BOOTFILE"
ui_print " "
ui_print "Check result in /data/initd_test.log file"
ui_print " "
else
ui_print "Init.d is enabled already, aborting!"
ui_print " " # exit is not necessary
fi
umount /system
exit 0
Remover [sh script]:
Code:
#!/sbin/sh
# Init.d remover by ALEXNDR (_alexndr @ XDA)
OUTFD=/proc/self/fd/$2
ui_print() {
echo -n -e "ui_print $1\n" >> $OUTFD
echo -n -e "ui_print\n" >> $OUTFD
}
resolve_link() {
if [ -z "$1" ] || [ ! -e $1 ] ; then return 1 ; fi
local VAR=$1
while [ -h "$VAR" ] ; do
VAR=$(readlink $VAR)
done
echo $VAR
}
is_mounted() {
if [ -z "$2" ] ; then
cat /proc/mounts | grep $1 >/dev/null
else
cat /proc/mounts | grep $1 | grep "$2," >/dev/null
fi
return $?
}
ui_print " "
ui_print "=========================================="
ui_print "Init.d remover by ALEXNDR (_alexndr @ XDA)"
ui_print "=========================================="
ui_print " "
SYSTEM=$(resolve_link $(find /dev/block/platform -type l | grep -i -m 1 "/app$")) ||
SYSTEM=$(resolve_link $(find /dev/block/platform -type l | grep -i -m 1 "/system$"))
if (! is_mounted /system) ; then mount -o rw /system ; fi
if (! is_mounted /system rw) ; then mount -o rw,remount /system ; fi
if (! is_mounted /system rw) ; then mount -t ext4 -o rw $SYSTEM /system ; fi
if (! is_mounted /system rw) ; then mount -t f2fs -o rw $SYSTEM /system ; fi
if (! is_mounted /system rw) ; then
ui_print "Failed! Can't mount /system rw, aborting!"
ui_print " "
exit 1
fi
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "/init\..*\.post_boot\.sh$") ||
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "\.post_boot\.sh$") ||
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "/init\..*\.boot\.sh$") ||
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "\.boot\.sh$") ||
BOOTFILE=/system/bin/debuggerd
if [ ! -z "$(cat $BOOTFILE | grep "Init\.d")" ] ; then
if [ "$BOOTFILE" = "/system/bin/debuggerd" ] ; then
if [ -f /system/bin/debuggerd_real ] ; then
rm -f $BOOTFILE
mv -f /system/bin/debuggerd_real $BOOTFILE
else
ui_print "Failed! Missing debuggerd_real file!"
exit 1
fi
elif [ -f "$BOOTFILE.bak" ] ; then
rm -f $BOOTFILE
mv -f "$BOOTFILE.bak" $BOOTFILE
else
ui_print "Failed! Missing *.sh.bak file!"
exit 1
fi
rm -Rf /system/etc/init.d
ui_print "Init.d has been successfully removed :)"
else
ui_print "Init.d by ALEXNDR has not been detected!"
fi
ui_print " "
umount /system
exit 0
NOTE:
If it does not work for your device - please post here a feedback! I will try to find a reason and tune my script
Credits: @Chainfire, @JustArchi
Hit Thanks button if you like my work. If you really appreciate my work - feel free to buy me a beer
Great Work..
Thanks
@_alexndr mate today i tried ur init.d enabled but on my s6 mm 6.0.1 its bricked my wifi as after flashing ur script i can't get wifi connected any fix for MM ?? Thanks
thereassaad said:
@_alexndr mate today i tried ur init.d enabled but on my s6 mm 6.0.1 its bricked my wifi as after flashing ur script i can't get wifi connected any fix for MM ?? Thanks
Click to expand...
Click to collapse
In my case work good no problem with WiFi connection on S5 MM 6.0.1
Regards
thereassaad said:
@_alexndr mate today i tried ur init.d enabled but on my s6 mm 6.0.1 its bricked my wifi as after flashing ur script i can't get wifi connected any fix for MM ?? Thanks
Click to expand...
Click to collapse
Strange as my installer in case of G920F should only add to /system/etc/init.sec.boot.sh following lines:
Code:
# Init.d support
mount -o rw,remount /system
chmod 777 /system/etc/init.d
chmod 777 /system/etc/init.d/*
mount -o ro,remount /system
busybox run-parts /system/etc/init.d
or following if busybox has not been installed:
Code:
# Init.d support
mount -o rw,remount /system
chmod 777 /system/etc/init.d
chmod 777 /system/etc/init.d/*
mount -o ro,remount /system
ls /system/etc/init.d/* 2>/dev/null | while read xfile ; do $xfile ; done
Original file should be renamed to /system/etc/init.sec.boot.sh.bak, so you can just delete modified init.sec.boot.sh and then rename init.sec.boot.sh.bak -> init.sec.boot.sh to revert changes (+ delete /system/etc/init.d folder but it's just a cosmetic)
...but before you do it - it would be great if you help in further development and try if following command put in terminal emulator or adb shell will help:
Code:
su
mount -o rw,remount /system
chmod 550 /system/etc/init.sec.boot.sh
chown 0:2000 /system/etc/init.sec.boot.sh
chcon u:object_r:sec-sh_exec:s0 /system/etc/init.sec.boot.sh
mount -o ro,remount /system
...then reboot device
EDIT:
Anyway - #1 has been updated as I found potential permissions / SELinux context mismatch in case of Samsung's Exynos based devices running Android 6.0.1. NOTE: It will not fix broken installation already done - you need to revert changes first (as I mentioned above - by deleting init.sec.boot.sh and renaming init.sec.boot.sh.bak -> init.sec.boot.sh) and then re-flash v1.1
Another update
Changelog:
v1.2:
★ Starting from this version installer performs more secure and only 100% reversible actions. Original *.sh file is never touched (just renamed to *.bak to keep its original attributes, including context). Installer will try to set to modified file as many attributes taken from original file as possible (instead of forcing "known values").
★ Added initd_remover.zip. Use it if you want to remove Init.d support (enabled by script from this thread!) and restore 100% original system files
@_alexndr , definitely mate will give a shot , later , thanks for ur work xD ,
good work bro will test more with new update
Good work ?
Sent from my A66A using XDA-Developers mobile app
Another update
Changelog:
v1.3:
★ This version automatically detects privileges of launched sh script used to trigger init.d and if these are not sufficient to remount /system rw - all commands are automatically expanded to "/su/bin/su -c [command]" or "/system/xbin/su -c [command]" (depending on SuperSU install mode)
★ Fixed problem with "exit 0" at the end of used sh script resulting that simply added new lines never worked. This version automatically detects such case and moves "exit 0" at the end of modified file
★ SELinux context autodetection - starting from v1.3 modified file has always exact same context as original file
★ BusyBox will not be used anymore, even if exists (checking the presence removed)
First of all really thank you for this script which works very well...except if included in the installation script.
The initd.sh is this
I use this command in the updater-script:
ui_print("@ Add init.d support");
package_extract_file("tools/initd.sh", "/tmp/initd.sh");
set_perm(0, 0, 0777, "/tmp/initd.sh");
run_program("/tmp/initd.sh");
delete("/tmp/initd.sh");
ui_print("--> Init.d Installed");
But not working. Got this error in recovery log
run_program: execv failed: No such file or directory
run_program: child exited with status 1
Any advice or a proper .sh script please ?
Thanks very much.
WILMANS2M said:
First of all really thank you for this script which works very well...except if included in the installation script.
The initd.sh is this
I use this command in the updater-script:
ui_print("@ Add init.d support");
package_extract_file("tools/initd.sh", "/tmp/initd.sh");
set_perm(0, 0, 0777, "/tmp/initd.sh");
run_program("/tmp/initd.sh");
delete("/tmp/initd.sh");
ui_print("--> Init.d Installed");
But not working. Got this error in recovery log
run_program: execv failed: No such file or directory
run_program: child exited with status 1
Any advice or a proper .sh script please ?
Thanks very much.
Click to expand...
Click to collapse
My script (as it is in post #1) is designed to be standalone installer. If you want to enable init.d by a sh script called from the updater-script - please try as follow:
Code:
#!/sbin/sh
# Init.d enabler by ALEXNDR (_alexndr @ XDA)
set_perm() {
chown $1.$2 $4
chown $1:$2 $4
chmod $3 $4
if [ -z "$5" ] ; then
chcon u:object_r:system_file:s0 $4
else
chcon u:object_r:$5:s0 $4
fi
}
# These files are prefered to trigger init.d scripts (in following order, if exists):
# /system/etc/init.*.post_boot.sh
# /system/etc/*.post_boot.sh
# /system/etc/init.*.boot.sh
# /system/etc/*.boot.sh
#
# /system/bin/debuggerd is used if there is no suitable *.sh file in /system/etc
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "/init\..*\.post_boot\.sh$") ||
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "\.post_boot\.sh$") ||
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "/init\..*\.boot\.sh$") ||
BOOTFILE=$(ls /system/etc/*.sh 2>/dev/null | grep -m 1 "\.boot\.sh$") ||
BOOTFILE=/system/bin/debuggerd
BOOTCON=$(ls -Z $BOOTFILE 2>/dev/null | grep "u:object_r" | cut -d: -f3)
if [ -z "$BOOTCON" ] ; then
BOOTCON=system_file
fi
cat $BOOTFILE | grep "^exit 0" >/dev/null && EXIT=true || EXIT=false
if [ -z "$(cat $BOOTFILE | grep "[Ii]nit\.d")" ] ; then
if [ "$BOOTFILE" = "/system/bin/debuggerd" ] ; then
if [ ! -f /system/bin/debuggerd_real ] ; then
mv -f $BOOTFILE /system/bin/debuggerd_real
echo "#!/system/bin/sh" > $BOOTFILE
else
sed -i '/debuggerd_real/d' $BOOTFILE
fi
else
mv -f $BOOTFILE "$BOOTFILE.bak"
cp -pf "$BOOTFILE.bak" $BOOTFILE
if ($EXIT) ; then sed -i '/^exit 0/d' $BOOTFILE ; fi
echo "" >> $BOOTFILE
fi
echo "# Init.d support" >> $BOOTFILE
echo 'SU="$(ls /su/bin/su 2>/dev/null || ls /system/xbin/su) -c"' >> $BOOTFILE
echo 'mount -o rw,remount /system && SU="" || eval "$SU mount -o rw,remount /system"' >> $BOOTFILE
echo 'eval "$SU chmod 777 /system/etc/init.d"' >> $BOOTFILE
echo 'eval "$SU chmod 777 /system/etc/init.d/*"' >> $BOOTFILE
echo 'eval "$SU mount -o ro,remount /system"' >> $BOOTFILE
echo 'ls /system/etc/init.d/* 2>/dev/null | while read xfile ; do eval "$SU /system/bin/sh $xfile" ; done' >> $BOOTFILE
if [ "$BOOTFILE" = "/system/bin/debuggerd" ] ; then
echo '/system/bin/debuggerd_real [email protected]' >> $BOOTFILE
set_perm 0 2000 755 $BOOTFILE $BOOTCON
else
if ($EXIT) ; then echo "exit 0" >> $BOOTFILE ; fi
chcon u:object_r:$BOOTCON:s0 $BOOTFILE
fi
mkdir -p /system/etc/init.d
echo "#!/system/bin/sh" > /system/etc/init.d/00test
echo "# Init.d test" >> /system/etc/init.d/00test
echo 'echo "Init.d is working !!!" > /data/initd_test.log' >> /system/etc/init.d/00test
echo 'echo "excecuted on $(date +"%d-%m-%Y %r")" >> /data/initd_test.log' >> /system/etc/init.d/00test
echo "#!/system/bin/sh" > /system/etc/init.d/99SuperSUDaemon
echo "/system/xbin/daemonsu --auto-daemon &" >> /system/etc/init.d/99SuperSUDaemon
set_perm 0 0 777 /system/etc/init.d
set_perm 0 0 777 "/system/etc/init.d/*"
fi
exit 0
Thanks for the answer. Will try it asap and give you feedback.
Envoyé de mon GT-I9505 en utilisant Tapatalk
hello @_alexndr
So tried again with the sh modified script, but same thing. Same error and no initd installed unfortunately
If you have any other advice, i really thank you in advance.
i tried something different. I keep your original zip file, and put it in tools/initd folder in my custom rom
Then i added this in the updater script:
ui_print("@ Add init.d support");
package_extract_dir("tools/initd", "/tmp/initd");
run_program("/sbin/busybox", "unzip", "/tmp/initd/initd.any.stock.1.3.zip", "META-INF/com/google/android/*", "-d", "/tmp/initd");
run_program("/sbin/busybox", "sh", "/tmp/initd/META-INF/com/google/android/update-binary", "dummy", "1", "/tmp/initd/initd.any.stock.1.3.zip");
ui_print("--> Init.d Installed");
IT WORKS with this
Thanks
great job
You sir are an animal. This script is intelligently designed
Deleted
Hey, Firstly thanks for all your work!
I've not tried this yet but I'm working on stock based ROM nd I want to enable to init.d support in it.
I've used the SuperR's Kitchen to enable the init.d support in the kernel nd I could find the script in the kernel too. Not sure if it'll work or not as I haven't tested in yet. So I hope you can tell me if I need to enable this way too or not,
Thanks.
@_alexndr
Thanks a lot
Confirmed Working on Samsung Galaxy S5 G900H
OS: Stock Deodexed Marshmallow 6.0.1 with GreenApple Kernal

Using command echo .sh file doesn't work in recovery

I'm trying to understand why using echo command in sh file doesn't work in recovery.
I've made a flashable zip with 7-zip, it contains a shell script.
The updater-script is
Code:
ui_print("");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");
package_extract_dir("test", "/tmp");
set_perm(0, 0, 0777, "/tmp/test.sh");
run_program("/tmp/test.sh");
delete_recursive("/tmp");
unmount("/system");
unmount("/data");
and my test.sh is like this :
Code:
#!/sbin/sh
rm -rf /system/app/YouTube
echo "Delete Youtube"
test.sh deletes Youtube folder but echo command doesn't work.
I use TWRP 3.2.3.0 recovery
Echo is a command for windows command line. In recovery you use: ui_print("<message goes here");
In recovery the language used is called Edify.
Read a bit about it here:
https://forum.xda-developers.com/wiki/Edify_script_language
joluke said:
Echo is a command for windows command line. In recovery you use: ui_print("<message goes here");
In recovery the language used is called Edify.
Read a bit about it here:
https://forum.xda-developers.com/wiki/Edify_script_language
Click to expand...
Click to collapse
you use ui_print in updater-script ?
but in sh file how to print on screen if echo doesn't work in recovery ?
kramer04 said:
you use ui_print in updater-script ?
but in sh file how to print on screen if echo doesn't work in recovery ?
Click to expand...
Click to collapse
Sh use the commands you use in linux
And yes ui_print is for updater-script
joluke said:
Sh use the commands you use in linux
And yes ui_print is for updater-script
Click to expand...
Click to collapse
Ok trying to use echo in sh file doesn't work for me.
So I don't understand how to do .
Any suggestions?
kramer04 said:
Ok trying to use echo in sh file doesn't work for me.
So I don't understand how to do .
Any suggestions?
Click to expand...
Click to collapse
Use Linux commands only. Echo is for Windows command line.
I don't have the skills to help you but googling "Linux commands for console" should help
joluke said:
Use Linux commands only. Echo is for Windows command line.
I don't have the skills to help you but googling "Linux commands for console" should help
Click to expand...
Click to collapse
So googling linus commands but I don't find how to use echo in a sh file in recovery.
If you have time try yourself echo command .
I've no idea why it doesn't work.
ECHO is a command for windows command line dude! Why do you insist on using echo? Echo is for windows command line? Got it now?
You need to use other commands according to the system you are using. and in android you use bash language on .sh files!
joluke said:
ECHO is a command for windows command line dude! Why do you insist on using echo? Echo is for windows command line? Got it now?
You need to use other commands according to the system you are using. and in android you use bash language on .sh files!
Click to expand...
Click to collapse
but i don't understand why it doesn't work
else i don't know how to replace echo by an other command
Thanks for help
kramer04 said:
but i don't understand why it doesn't work
else i don't know how to replace echo by an other command
Thanks for help
Click to expand...
Click to collapse
Every programming language uses its own commands...
Maybe because of that?
After some research
i change a little my script to see if command echo works
code in updater-script
Code:
ui_print("*************************");
ui_print("sh10");
ui_print("*************************");
unmount("/system");
unmount("/data");
#ui_print("-- Montage partitions...");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");
package_extract_dir("test", "/tmp");
set_perm(0, 0, 0777, "/tmp/test.sh");
run_program("/tmp/test.sh");
#ui_print("Extracting files ...");
#package_extract_dir("system", "/tmp/update");
#set_perm(0, 0, 0755, "/tmp/update/myscript.sh");
#run_program("/tmp/update/myscript.sh");
#delete_recursive("/tmp*");
ui_print("END OF PROCESS");
ui_print("*************************");
unmount("/data");
unmount("/system");
code in test.sh file
Code:
#!/sbin/sh
#echo on
#function to display commands
exe() { echo "\$ [email protected]" ; "[email protected]" ; }
OUTFD=$2
ui_print() {
if [ $OUTFD != "" ]; then
echo "ui_print ${1} " 1>&$OUTFD;
echo "ui_print " 1>&$OUTFD;
else
echo "${1}";
fi;
}
#rm -rf /system/app/YouTube
echo "hello world !, using echo" >tong.txt
exe echo "Delete YouTube, using exe echo"
echo "Delete YouTube, using echo" >>tong.txt
printf "hello world, using printf" >>tong.txt
cat tong.txt
ui_print "hello world! using ui_print"
echo command doesn't print on screen but it creates tong.txt and pass in results.
We can see it works in recovery.log
I:Set page: 'install'
I:Set page: 'flash_confirm'
I:Set page: 'flash_zip'
Iperation_start: 'Flashing'
Installing zip file '/external_sd/Custom Rom/test.zip'
Checking for Digest file...
Skipping Digest check: no Digest file found
I:Update binary zip
Verifying package compatibility...
Package doesn't contain compatibility.zip entry
I:Zip does not contain SELinux file_contexts file in its root.
I:has_legacy_properties: Found legacy property match!
I:Legacy property environment initialized.
*************************
sh10
*************************
unmount of /system failed; no such volume
about to run program [/sbin/busybox] with 3 args
about to run program [/sbin/busybox] with 3 args
minzip: Extracted file "/tmp/test.sh"
about to run program [/tmp/test.sh] with 1 args
$ echo Delete YouTube, using exe echo
Delete YouTube, using exe echo
hello world !, using echo
Delete YouTube, using echo
hello world, using printfsh: : unknown operand
hello world! using ui_print
END OF PROCESS
*************************
script result was [/system]
I:Updater process ended with RC=0
I:Legacy property environment disabled.
I:Install took 0 second(s).
Updating partition details...
I:mount -o bind '/data/media/0' '/sdcard' process ended with RC=0
Someone has an idea why echo doesn't print on screen in TWRP recovery; else it works...
weird for me
kramer04 said:
After some research
i change a little my script to see if command echo works
code in updater-script
Code:
ui_print("*************************");
ui_print("sh10");
ui_print("*************************");
unmount("/system");
unmount("/data");
#ui_print("-- Montage partitions...");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");
package_extract_dir("test", "/tmp");
set_perm(0, 0, 0777, "/tmp/test.sh");
run_program("/tmp/test.sh");
#ui_print("Extracting files ...");
#package_extract_dir("system", "/tmp/update");
#set_perm(0, 0, 0755, "/tmp/update/myscript.sh");
#run_program("/tmp/update/myscript.sh");
#delete_recursive("/tmp*");
ui_print("END OF PROCESS");
ui_print("*************************");
unmount("/data");
unmount("/system");
code in test.sh file
Code:
#!/sbin/sh
#echo on
#function to display commands
exe() { echo "\$ [email protected]" ; "[email protected]" ; }
OUTFD=$2
ui_print() {
if [ $OUTFD != "" ]; then
echo "ui_print ${1} " 1>&$OUTFD;
echo "ui_print " 1>&$OUTFD;
else
echo "${1}";
fi;
}
#rm -rf /system/app/YouTube
echo "hello world !, using echo" >tong.txt
exe echo "Delete YouTube, using exe echo"
echo "Delete YouTube, using echo" >>tong.txt
printf "hello world, using printf" >>tong.txt
cat tong.txt
ui_print "hello world! using ui_print"
echo command doesn't print on screen but it creates tong.txt and pass in results.
We can see it works in recovery.log
I:Set page: 'install'
I:Set page: 'flash_confirm'
I:Set page: 'flash_zip'
Iperation_start: 'Flashing'
Installing zip file '/external_sd/Custom Rom/test.zip'
Checking for Digest file...
Skipping Digest check: no Digest file found
I:Update binary zip
Verifying package compatibility...
Package doesn't contain compatibility.zip entry
I:Zip does not contain SELinux file_contexts file in its root.
I:has_legacy_properties: Found legacy property match!
I:Legacy property environment initialized.
*************************
sh10
*************************
unmount of /system failed; no such volume
about to run program [/sbin/busybox] with 3 args
about to run program [/sbin/busybox] with 3 args
minzip: Extracted file "/tmp/test.sh"
about to run program [/tmp/test.sh] with 1 args
$ echo Delete YouTube, using exe echo
Delete YouTube, using exe echo
hello world !, using echo
Delete YouTube, using echo
hello world, using printfsh: : unknown operand
hello world! using ui_print
END OF PROCESS
*************************
script result was [/system]
I:Updater process ended with RC=0
I:Legacy property environment disabled.
I:Install took 0 second(s).
Updating partition details...
I:mount -o bind '/data/media/0' '/sdcard' process ended with RC=0
Someone has an idea why echo doesn't print on screen in TWRP recovery; else it works...
weird for me
Click to expand...
Click to collapse
You are probably going to have to go in a little different direction. See this thread where update-binary is used in place of update-script.
Tulsadiver said:
You are probably going to have to go in a little different direction. See this thread where update-binary is used in place of update-script.
Click to expand...
Click to collapse
Thanks for your answer but could you add the link
kramer04 said:
Thanks for your answer but could you add the link
Click to expand...
Click to collapse
Sorry, lol!
https://forum.xda-developers.com/an...-complete-shell-script-flashable-zip-t2934449
Tulsadiver said:
Sorry, lol!
https://forum.xda-developers.com/an...-complete-shell-script-flashable-zip-t2934449
Click to expand...
Click to collapse
Thanks, but this isn't exactly what i'm looking for even if it's very interesting.
I would like to know how to display on recovery screen
I tryed with echo command but it doesn't work
For example running this script in sh file on recovery TWRP
Code:
#!/sbin/sh
csc_id=`cat /efs/imei/mps_code.dat`
echo "==== Your active csc is $csc_id ====="
echo do displays this
==== Your active csc is BTU ====
on recovery screen
but not displays anything.
Is there a way to activate it ?
kramer04 said:
Thanks, but this isn't exactly what i'm looking for even if it's very interesting.
I would like to know how to display on recovery screen
I tryed with echo command but it doesn't work
For example running this script in sh file on recovery TWRP
Code:
#!/sbin/sh
csc_id=`cat /efs/imei/mps_code.dat`
echo "==== Your active csc is $csc_id ====="
echo do displays this
==== Your active csc is BTU ====
on recovery screen
but not displays anything.
Is there a way to activate it ?
Click to expand...
Click to collapse
Echo has never worked on my phones. ui_print works on my pixel and pixel 2. It stopped working on my pixel 3 XL but that is because I haven't found a way to mount system using toybox. Pixel 3 XL won't mount using BusyBox.
Tulsadiver said:
Echo has never worked on my phones. ui_print works on my pixel and pixel 2. It stopped working on my pixel 3 XL but that is because I haven't found a way to mount system using toybox. Pixel 3 XL won't mount using BusyBox.
Click to expand...
Click to collapse
I know echo works because i see it in recovery log but it doesn't display anything on recovery screen
And i don't understand why;
Maybe it's because of recovery ?
I use TWRP
kramer04 said:
I know echo works because i see it in recovery log but it doesn't display anything on recovery screen
And i don't understand why;
Maybe it's because of recovery ?
I use TWRP
Click to expand...
Click to collapse
Most everyone uses TWRP. I believe for recovery screen, echo must be passed on to ui_print. Try this for an explanation:
https://forum.xda-developers.com/showthread.php?t=1023150&page=1
Tulsadiver said:
Most everyone uses TWRP. I believe for recovery screen, echo must be passed on to ui_print. Try this for an explanation:
https://forum.xda-developers.com/showthread.php?t=1023150&page=1
Click to expand...
Click to collapse
yes. totaly true
finaly i resolved my problem using code from Chainfire
Code:
#!/sbin/sh
OUTFD=1
readlink /proc/$$/fd/$OUTFD 2>/dev/null | grep /tmp >/dev/null
if [ "$?" -eq "0" ]; then
# rerouted to log file, we don't want our ui_print commands going there
OUTFD=0
# we are probably running in embedded mode, see if we can find the right fd
# we know the fd is a pipe and that the parent updater may have been started as
# 'update-binary 3 fd zipfile'
for FD in `ls /proc/$$/fd`; do
readlink /proc/$$/fd/$FD 2>/dev/null | grep pipe >/dev/null
if [ "$?" -eq "0" ]; then
ps | grep " 3 $FD " | grep -v grep >/dev/null
if [ "$?" -eq "0" ]; then
OUTFD=$FD
break
fi
fi
done
fi
ui_print() {
echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
}
Thanks to all
https://forum.xda-developers.com/android/software-hacking/dev-complete-shell-script-flashable-zip-t2934449/page37
kramer04 said:
yes. totaly true
finaly i resolved my problem using code from Chainfire
Code:
#!/sbin/sh
OUTFD=1
readlink /proc/$$/fd/$OUTFD 2>/dev/null | grep /tmp >/dev/null
if [ "$?" -eq "0" ]; then
# rerouted to log file, we don't want our ui_print commands going there
OUTFD=0
# we are probably running in embedded mode, see if we can find the right fd
# we know the fd is a pipe and that the parent updater may have been started as
# 'update-binary 3 fd zipfile'
for FD in `ls /proc/$$/fd`; do
readlink /proc/$$/fd/$FD 2>/dev/null | grep pipe >/dev/null
if [ "$?" -eq "0" ]; then
ps | grep " 3 $FD " | grep -v grep >/dev/null
if [ "$?" -eq "0" ]; then
OUTFD=$FD
break
fi
fi
done
fi
ui_print() {
echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
}
Thanks to all
https://forum.xda-developers.com/android/software-hacking/dev-complete-shell-script-flashable-zip-t2934449/page37
Click to expand...
Click to collapse
That works on my pixel and pixel 2 but not my pixel 3 XL. But on my pixel 3 XL I also have to use toybox to mount instead of BusyBox
run_program("/sbin/toybox", "mount", "/system");

Categories

Resources