[DEV DISCUSSION] Install method for users on BML OR MTD! - Epic 4G Android Development

So... I know Random started something like this... and to be quite honest... This idea stemmed from the post.
What i have in mind, is an installer that can differentiate between BML and MTD... Making it TONS easier on the end user.
The idea is that it checks for config values in the build.prop (that are present for devs that have their ROMs on Rom Manager), and then if the installer already has the last previous version of a specific dev's ROM on the phone, it goes on to update... If the value is NOT present in the build.prop, it goes on to backup the phone, and then find which partition type the current system is on, to install a fresh system on that partition.
here's the code... make what you want, and all comments are welcomed... i just can't get this routine to work... and now i'm reaching out to the community for help... as i feel this would be beneficial to all, since we're making the jump from one partition map to another... which is a HUGE deal for people who are skeptical of doing so... let me know what you think.
This is as basic of code as i could break it down to... Let me know if it's not simplified enough.
Code:
ifelse(
getprop("ro.modversion") == "Legendary_rc_2.2",
(
ui_print("Currently running Legendary 2.2 | No changes until 2.3!");
),
(
ui_print("Backing up data...");
ifelse(
mount("yaffs2", "MTD", "system", "/system") == "system",
(
ui_print("Formatting Filesystem... (YAFFS2)");
),
(
ui_print("Formatting Filesystem... (EXT4)");
)
);
ui_print("Mounting file system...");
ui_print("Extracting ROM...");
ui_print("Restoring data");
ifelse(
mount("yaffs2", "MTD", "system", "/system") == "system",
(
ui_print("More YAFFS2 Stuff");
),
(
ui_print("--");
)
);
)
);
ui_print("Extracting Kernel...");
ifelse(
mount("yaffs2", "MTD", "system", "/system") == "system",
(
ui_print("Install MTD Kernel");
),
(
ui_print("Install BML Kernel");
)
);
ifelse(
mount("EXT4", "BML", "system", "/system") == "system",
(
ui_print("You're still using an EXT4 (BML) partition...");
),
(
ui_print("If not, Notify users that they're YAFFS2 (which at this point ODIN would be the only other option.) ");
)
);

Well lets do this. What is the order of each line, that your seeing in your head.
Example: 1. Check in build.prop for ("ro.modversion") == "Legendary_rc_2.2
2. If on earlier version update to 2.2
3.etc etc
Know I know you laid it out but just write what needs to be done exactly in order. Then we can figure out how to do it in updater-script and simplify it if needed. I can help figure out atleast bits and pieces and I am sure others will be in for figuring out parts. Also I don't see anything about installing MTD or BML recovery. Well we should also give an option to upgrade to MTD if your on BML.
Edit: I ran the script and it didn't check build.prop for the ro.modversion??

It would be <=Legendary 2.2
Sent from my SPH-D700 using XDA App

marcusant said:
It would be <=Legendary 2.2
Sent from my SPH-D700 using XDA App
Click to expand...
Click to collapse
I checked my build.prop and it was Legendary_rc_2.2 ??

The_Legendary said:
I checked my build.prop and it was Legendary_rc_2.2 ??
Click to expand...
Click to collapse
No... the code for less than
Sent from my SPH-D700 using XDA App

marcusant said:
No... the code for less than
Sent from my SPH-D700 using XDA App
Click to expand...
Click to collapse
Ohhh duhhh I need sleep :\

hoffman1984 said:
[...]here's the code... make what you want, and all comments are welcomed... i just can't get this routine to work... and now i'm reaching out to the community for help... as i feel this would be beneficial to all, since we're making the jump from one partition map to another... which is a HUGE deal for people who are skeptical of doing so... let me know what you think. [...]
Click to expand...
Click to collapse
I've gotten the code to run. The updater binary I'm using is looking for 3 arguments in the mount command instead of 4. Apparently, at least for my binary, it should look like:
mount("MTD", "system", "/system")
This lets the script run, so I wrote the following as a test:
Code:
ifelse(
# read the mount
mount("MTD", "system", "/system") == "system",
(
# Success
ui_print("Successfully Mounted!");
),
(
# Fail
ui_print("Mount Failed!");
)
);
A simple script to test the function... but unfortunately it reports "Mount Failed!" whether I ask for MTD or BML. That's as far as my brain is going right now.
UPDATE: So, apparently Samurai Kernel has already done this. I haven't checked if it works but it's here on pastebin.

hey hoffman i know you sent me a PM, was actually working on this alongside you except my approach is different in that i only check against mount-ability once and store a propfile with the relevant details. It's safer because you don't have to keep track of the mounts. here's the relevant code, it's two parts.
The beauty about this way of doing it is that we can handle EXT4, RFS, and MTD/YAFFS2 automatically.
pmfs.sh
establishes a property listing of partition map / file system details in a file /tmp/pmfs.
Code:
#!/sbin/sh
# 2012-01-01 SENSEISIMPLE
BB="/sbin/busybox"
MOUNT="$BB mount"
UMOUNT="$BB umount"
pmfs="/tmp/pmfs"
$BB rm -f $pmfs
$BB rm -f /sdcard/.PARTMAPFS.prop
$UMOUNT /system
if $MOUNT -t ext4 /dev/block/stl9 /system &> /dev/null; then echo -e "syspm=bml\nsysfs=ext4\nsyspmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /system
if $MOUNT -t rfs /dev/block/stl9 /system &> /dev/null; then echo -e "syspm=bml\nsysfs=rfs\nsyspmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /system
if $MOUNT -t yaffs2 /dev/block/mtdblock2 /system &> /dev/null; then echo -e "syspm=mtd\nsysfs=yaffs2\nsyspmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /system
$UMOUNT /data
if $MOUNT -t ext4 /dev/block/stl10 /data &> /dev/null; then echo -e "datpm=bml\ndatfs=ext4\ndatpmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /data
if $MOUNT -t rfs /dev/block/stl10 /data &> /dev/null; then echo -e "datpm=bml\ndatfs=rfs\ndatpmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /data
if $MOUNT -t yaffs2 /dev/block/mtdblock3 /data &> /dev/null; then echo -e "datpm=mtd\ndatfs=yaffs2\ndatpmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /data
$UMOUNT /cache
if $MOUNT -t ext4 /dev/block/stl11 /cache &> /dev/null; then echo -e "cacpm=bml\ncacfs=ext4\ncacpmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /cache
if $MOUNT -t rfs /dev/block/stl11 /cache &> /dev/null; then echo -e "cacpm=bml\ncacfs=rfs\ncacpmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /cache
if $MOUNT -t yaffs2 /dev/block/mtdblock4 /cache &> /dev/null; then echo -e "cacpm=mtd\ncacfs=yaffs2\ncacpmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /cache
the generated file looks like this:
/tmp/pmfs (example of a consistent BML/EXT4 setup, but it could be a mix of bml: ext4/rfs. Alternately mtd: yaffs2)
Code:
syspm=bml
sysfs=ext4
syspmfs=bmlext4
datpm=bml
datfs=ext4
datpmfs=bmlext4
cacpm=bml
cacfs=ext4
cacpmfs=bmlext4
the xxxpmfs= entry is a shortcut for when you need to test the combination i.e. bmlrfs or bmlext4 instead of having to invoke 4 separate file_getprops
the updaterscript looks something like this
updater-script
Code:
package_extract_dir("tools/univ", "/tmp/tools");
set_perm_recursive(0, 0, 0777, 0777, "/tmp/tools");
run_program("/tmp/tools/pmfs.sh");
#ENSURE FILESYSTEM CONSISTENCY (i.e. make sure we don't have a mix of RFS and EXT4 partitions - have all of the same FS on partitions
ifelse(
file_getprop("/tmp/pmfs", "sysfs") == "ext4" && file_getprop("/tmp/pmfs", "datfs") == "ext4" && file_getprop("/tmp/pmfs", "cacfs") == "ext4" ||
file_getprop("/tmp/pmfs", "sysfs") == "yaffs2" && file_getprop("/tmp/pmfs", "datfs") == "yaffs2" && file_getprop("/tmp/pmfs", "cacfs") == "yaffs2" ||
file_getprop("/tmp/pmfs", "sysfs") == "rfs" && file_getprop("/tmp/pmfs", "datfs") == "rfs" && file_getprop("/tmp/pmfs", "cacfs") == "rfs",
(
ui_print("PASSED CONSISTENCY CHECK");sleep(1);
),
(
ui_print("ERROR: INCONSISTENT FILESYSTEMS");
#NEED TO REFORMAT ALL (CLEAN WIPE)
abort();
)
);
#FORMAT SYSTEM (based on what is already there) - CHECK FILE SYSTEM ext4 || rfs || yaffs2
ifelse( file_getprop("/tmp/pmfs","sysfs") == "yaffs2",
(
#format MTD/YAFFS2
format("yaffs2", "MTD", "system");
format("yaffs2", "MTD", "cache");
)
);
ifelse( file_getprop("/tmp/pmfs","sysfs") == "ext4",
(
#format ext4
run_program("/tmp/tools/fsck.ext4", "-fy", "/dev/block/stl9");
run_program("/tmp/tools/mkfs.ext4", "-O", "^ext_attr,^has_journal,^huge_file", "-L", "SYSTEM", "-b", "4096", "-m", "0", "-F", "/dev/block/stl9");
run_program("/tmp/tools/fsck.ext4", "-fy", "/dev/block/stl11");
run_program("/tmp/tools/mkfs.ext4", "-O", "^ext_attr,^has_journal,^huge_file", "-L", "SYSTEM", "-b", "4096", "-m", "0", "-F", "/dev/block/stl11");
run_program("/tmp/tools/ext4convert");
)
);
ifelse( file_getprop("/tmp/pmfs","sysfs") == "rfs",
(
#format RFS
run_program("/sbin/dd", "if=/dev/zero", "of=/dev/block/stl9", "bs=4096");
run_program("/tmp/tools/fat.format", "-F", "32", "-S", "4096", "-s", "1", "/dev/block/stl9");
run_program("/sbin/dd", "if=/dev/zero", "of=/dev/block/stl11", "bs=4096");
run_program("/tmp/tools/fat.format", "-F", "32", "-S", "4096", "-s", "1", "/dev/block/stl11");
)
);
#INSTALL KERNEL (CHECK PARTITION MAP - BML || MTD
ifelse( file_getprop("/tmp/pmfs", "syspm") == "mtd",
(
#INSTALL MTD KERNEL IMGS
assert(run_program("/tmp/tools/erase_image", "boot")); set_progress(0.270000);
assert(
package_extract_file("kernel/boot.img", "/tmp/boot.img"),
write_raw_image("/tmp/boot.img", "boot"),
run_program("/tmp/tools/bml_over_mtd.sh", "boot", "72", "reservoir", "4012", "/tmp/boot.img"),
delete("/tmp/boot.img")
);
assert(run_program("/tmp/tools/erase_image", "recovery"));
assert(
package_extract_file("kernel/recovery.bin", "/tmp/recovery.img"),
run_program("/tmp/tools/bml_over_mtd.sh", "recovery", "102", "reservoir", "4012", "/tmp/recovery.img"),
delete("/tmp/recovery.img")
);
),
(
#INSTALL BML KERNEL
package_extract_file("kernel/zImage", "/tmp/zImage");
run_program("/tmp/tools/bmlwrite", "/tmp/zImage", "/dev/block/bml7");
delete("/tmp/zImage");
)
);
That is a functional example of usage right out of SleeperROM, my tools get unpacked and called from /tmp/tools , and my kernel images are kept together in the rom package

Hey Simple first I gotta say good idea with generating the pmfs instead of invoking four different getprops
but one question how do I use this to generate the pmfs file
#!/sbin/sh
# 2012-01-01 SENSEISIMPLE
BB="/sbin/busybox"
MOUNT="$BB mount"
UMOUNT="$BB umount"
pmfs="/tmp/pmfs"
$BB rm -f $pmfs
$BB rm -f /sdcard/.PARTMAPFS.prop
$UMOUNT /system
if $MOUNT -t ext4 /dev/block/stl9 /system &> /dev/null; then echo -e "syspm=bml\nsysfs=ext4\nsyspmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /system
if $MOUNT -t rfs /dev/block/stl9 /system &> /dev/null; then echo -e "syspm=bml\nsysfs=rfs\nsyspmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /system
if $MOUNT -t yaffs2 /dev/block/mtdblock2 /system &> /dev/null; then echo -e "syspm=mtd\nsysfs=yaffs2\nsyspmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /system
$UMOUNT /data
if $MOUNT -t ext4 /dev/block/stl10 /data &> /dev/null; then echo -e "datpm=bml\ndatfs=ext4\ndatpmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /data
if $MOUNT -t rfs /dev/block/stl10 /data &> /dev/null; then echo -e "datpm=bml\ndatfs=rfs\ndatpmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /data
if $MOUNT -t yaffs2 /dev/block/mtdblock3 /data &> /dev/null; then echo -e "datpm=mtd\ndatfs=yaffs2\ndatpmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /data
$UMOUNT /cache
if $MOUNT -t ext4 /dev/block/stl11 /cache &> /dev/null; then echo -e "cacpm=bml\ncacfs=ext4\ncacpmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /cache
if $MOUNT -t rfs /dev/block/stl11 /cache &> /dev/null; then echo -e "cacpm=bml\ncacfs=rfs\ncacpmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /cache
if $MOUNT -t yaffs2 /dev/block/mtdblock4 /cache &> /dev/null; then echo -e "cacpm=mtd\ncacfs=yaffs2\ncacpmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /cache
Click to expand...
Click to collapse
I just read what earthbound wrote up and I wrote up something similar, well without all the samurai stuff lol, but how do we make it so it checks for ro.modversion, if it finds a previous version, it goes to install an update that is included in the installer?? What would be the lines for this??

The_Legendary said:
Hey Simple first I gotta say good idea with generating the pmfs instead of invoking four different getprops
but one question how do I use this to generate the pmfs file
Click to expand...
Click to collapse
the script generates it, it writes the details to temporary file /tmp/pmfs as soon as it runs, so you're ready to access it

SenseiSimple said:
the script generates it, it writes the details to temporary file /tmp/pmfs as soon as it runs, so you're ready to access it
Click to expand...
Click to collapse
OK so it's already in the updater-script, sweet man if all of us help each other we should have this working just fine in no time.
EDIT: Hey man I tried running the script and I keep getting Status 6 installion aborted??
EDIT2: Well there is a extra line on line 48 that was causing the status 6. But now when I run I get status 7 and file_getprop: failed to stat "/tmp/pmfs" : No such file or directory
So this isn't making the pmfs file.

marcusant said:
It would be <=Legendary 2.2
Sent from my SPH-D700 using XDA App
Click to expand...
Click to collapse
It's actually looking for the exact value, so == is what i need. Not <=
IF the value IS EQUAL to Legendary_rc_2.2, then go onto update, ELSE backup and install.

SenseiSimple said:
hey hoffman i know you sent me a PM, was actually working on this alongside you except my approach is different in that i only check against mount-ability once and store a propfile with the relevant details. It's safer because you don't have to keep track of the mounts. here's the relevant code, it's two parts.
The beauty about this way of doing it is that we can handle EXT4, RFS, and MTD/YAFFS2 automatically.
pmfs.sh
establishes a property listing of partition map / file system details in a file /tmp/pmfs.
Code:
#!/sbin/sh
# 2012-01-01 SENSEISIMPLE
BB="/sbin/busybox"
MOUNT="$BB mount"
UMOUNT="$BB umount"
pmfs="/tmp/pmfs"
$BB rm -f $pmfs
$BB rm -f /sdcard/.PARTMAPFS.prop
$UMOUNT /system
if $MOUNT -t ext4 /dev/block/stl9 /system &> /dev/null; then echo -e "syspm=bml\nsysfs=ext4\nsyspmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /system
if $MOUNT -t rfs /dev/block/stl9 /system &> /dev/null; then echo -e "syspm=bml\nsysfs=rfs\nsyspmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /system
if $MOUNT -t yaffs2 /dev/block/mtdblock2 /system &> /dev/null; then echo -e "syspm=mtd\nsysfs=yaffs2\nsyspmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /system
$UMOUNT /data
if $MOUNT -t ext4 /dev/block/stl10 /data &> /dev/null; then echo -e "datpm=bml\ndatfs=ext4\ndatpmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /data
if $MOUNT -t rfs /dev/block/stl10 /data &> /dev/null; then echo -e "datpm=bml\ndatfs=rfs\ndatpmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /data
if $MOUNT -t yaffs2 /dev/block/mtdblock3 /data &> /dev/null; then echo -e "datpm=mtd\ndatfs=yaffs2\ndatpmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /data
$UMOUNT /cache
if $MOUNT -t ext4 /dev/block/stl11 /cache &> /dev/null; then echo -e "cacpm=bml\ncacfs=ext4\ncacpmfs=bmlext4" >> "$pmfs"; fi
$UMOUNT /cache
if $MOUNT -t rfs /dev/block/stl11 /cache &> /dev/null; then echo -e "cacpm=bml\ncacfs=rfs\ncacpmfs=bmlrfs" >> "$pmfs"; fi
$UMOUNT /cache
if $MOUNT -t yaffs2 /dev/block/mtdblock4 /cache &> /dev/null; then echo -e "cacpm=mtd\ncacfs=yaffs2\ncacpmfs=mtdyaffs2" >> "$pmfs"; fi
$UMOUNT /cache
the generated file looks like this:
/tmp/pmfs (example of a consistent BML/EXT4 setup, but it could be a mix of bml: ext4/rfs. Alternately mtd: yaffs2)
Code:
syspm=bml
sysfs=ext4
syspmfs=bmlext4
datpm=bml
datfs=ext4
datpmfs=bmlext4
cacpm=bml
cacfs=ext4
cacpmfs=bmlext4
the xxxpmfs= entry is a shortcut for when you need to test the combination i.e. bmlrfs or bmlext4 instead of having to invoke 4 separate file_getprops
the updaterscript looks something like this
updater-script
Code:
package_extract_dir("tools/univ", "/tmp/tools");
set_perm_recursive(0, 0, 0777, 0777, "/tmp/tools");
run_program("/tmp/tools/pmfs.sh");
#ENSURE FILESYSTEM CONSISTENCY (i.e. make sure we don't have a mix of RFS and EXT4 partitions - have all of the same FS on partitions
ifelse(
file_getprop("/tmp/pmfs", "sysfs") == "ext4" && file_getprop("/tmp/pmfs", "datfs") == "ext4" && file_getprop("/tmp/pmfs", "cacfs") == "ext4" ||
file_getprop("/tmp/pmfs", "sysfs") == "yaffs2" && file_getprop("/tmp/pmfs", "datfs") == "yaffs2" && file_getprop("/tmp/pmfs", "cacfs") == "yaffs2" ||
file_getprop("/tmp/pmfs", "sysfs") == "rfs" && file_getprop("/tmp/pmfs", "datfs") == "rfs" && file_getprop("/tmp/pmfs", "cacfs") == "rfs",
(
ui_print("PASSED CONSISTENCY CHECK");sleep(1);
),
(
ui_print("ERROR: INCONSISTENT FILESYSTEMS");
#NEED TO REFORMAT ALL (CLEAN WIPE)
abort();
)
);
#FORMAT SYSTEM (based on what is already there) - CHECK FILE SYSTEM ext4 || rfs || yaffs2
ifelse( file_getprop("/tmp/pmfs","sysfs") == "yaffs2",
(
#format MTD/YAFFS2
format("yaffs2", "MTD", "system");
format("yaffs2", "MTD", "cache");
)
);
ifelse( file_getprop("/tmp/pmfs","sysfs") == "ext4",
(
#format ext4
run_program("/tmp/tools/fsck.ext4", "-fy", "/dev/block/stl9");
run_program("/tmp/tools/mkfs.ext4", "-O", "^ext_attr,^has_journal,^huge_file", "-L", "SYSTEM", "-b", "4096", "-m", "0", "-F", "/dev/block/stl9");
run_program("/tmp/tools/fsck.ext4", "-fy", "/dev/block/stl11");
run_program("/tmp/tools/mkfs.ext4", "-O", "^ext_attr,^has_journal,^huge_file", "-L", "SYSTEM", "-b", "4096", "-m", "0", "-F", "/dev/block/stl11");
run_program("/tmp/tools/ext4convert");
)
);
ifelse( file_getprop("/tmp/pmfs","sysfs") == "rfs",
(
#format RFS
run_program("/sbin/dd", "if=/dev/zero", "of=/dev/block/stl9", "bs=4096");
run_program("/tmp/tools/fat.format", "-F", "32", "-S", "4096", "-s", "1", "/dev/block/stl9");
run_program("/sbin/dd", "if=/dev/zero", "of=/dev/block/stl11", "bs=4096");
run_program("/tmp/tools/fat.format", "-F", "32", "-S", "4096", "-s", "1", "/dev/block/stl11");
)
);
#INSTALL KERNEL (CHECK PARTITION MAP - BML || MTD
ifelse( file_getprop("/tmp/pmfs", "syspm") == "mtd",
(
#INSTALL MTD KERNEL IMGS
assert(run_program("/tmp/tools/erase_image", "boot")); set_progress(0.270000);
assert(
package_extract_file("kernel/boot.img", "/tmp/boot.img"),
write_raw_image("/tmp/boot.img", "boot"),
run_program("/tmp/tools/bml_over_mtd.sh", "boot", "72", "reservoir", "4012", "/tmp/boot.img"),
delete("/tmp/boot.img")
);
assert(run_program("/tmp/tools/erase_image", "recovery"));
assert(
package_extract_file("kernel/recovery.bin", "/tmp/recovery.img"),
run_program("/tmp/tools/bml_over_mtd.sh", "recovery", "102", "reservoir", "4012", "/tmp/recovery.img"),
delete("/tmp/recovery.img")
);
),
(
#INSTALL BML KERNEL
package_extract_file("kernel/zImage", "/tmp/zImage");
run_program("/tmp/tools/bmlwrite", "/tmp/zImage", "/dev/block/bml7");
delete("/tmp/zImage");
)
);
That is a functional example of usage right out of SleeperROM, my tools get unpacked and called from /tmp/tools , and my kernel images are kept together in the rom package
Click to expand...
Click to collapse
See the thing here is that i didn't really care to check for RFS, as both EXT4 and RFS are both on BML partition maps.
Just figured it'd be a simpler process to check for YAFFS (MTD) and if true, do YAFFS installation... If false, then it must be a BML mapping. So install EXT4 (which would convert RFS to EXT4 anyway).
I haven't gotten as far as to start playing with shell, though... But this does look promising.

RandomKing said:
I've gotten the code to run. The updater binary I'm using is looking for 3 arguments in the mount command instead of 4. Apparently, at least for my binary, it should look like:
mount("MTD", "system", "/system")
This lets the script run, so I wrote the following as a test:
Code:
ifelse(
# read the mount
mount("MTD", "system", "/system") == "system",
(
# Success
ui_print("Successfully Mounted!");
),
(
# Fail
ui_print("Mount Failed!");
)
);
A simple script to test the function... but unfortunately it reports "Mount Failed!" whether I ask for MTD or BML. That's as far as my brain is going right now.
UPDATE: So, apparently Samurai Kernel has already done this. I haven't checked if it works but it's here on pastebin.
Click to expand...
Click to collapse
I wrote earthbounds script for him... He made some minor changes, as i forgot to unixify the script before sending. So he had some left over carriage returns.
I can get the ui_prints to work... ALL FINE.
The problem i've been having is that once i start plugging in all my install scripting, it looks like it's going through the motions... then i get stuck on the Samsung screen after the install completes.
BOOOOOOOH!

The_Legendary said:
OK so it's already in the updater-script, sweet man if all of us help each other we should have this working just fine in no time.
EDIT: Hey man I tried running the script and I keep getting Status 6 installion aborted??
EDIT2: Well there is a extra line on line 48 that was causing the status 6. But now when I run I get status 7 and file_getprop: failed to stat "/tmp/pmfs" : No such file or directory
So this isn't making the pmfs file.
Click to expand...
Click to collapse
status 6 might be some carriage returns in the scripting. If you're using notepad++ go to view -> show symbol -> show end of line
Ditch the CR's and keep your LF's.

hoffman1984 said:
status 6 might be some carriage returns in the scripting. If you're using notepad++ go to view -> show symbol -> show end of line
Ditch the CR's and keep your LF's.
Click to expand...
Click to collapse
I def already did that, it was that extra line. But the partition check is working but the install fails.. is that what you are saying??

Wow, that was the first time I have actually looked at script code for android.
Even though I started as a programmer, I was very surprised at how well I could follow the flow of the commands
Good luck with the project!
This Epic post as brought to you via Tapatalk

The_Legendary said:
I def already did that, it was that extra line. But the partition check is working but the install fails.. is that what you are saying??
Click to expand...
Click to collapse
My installation never failed... The script went through the motions... It took the time it would take to format, extract, etc... Told me the installation was complete. Then when i went to turn the phone on... SAMMY SCREEN!
Not sure why or how this happened... But i'm leaning toward either edify not liking nested ifelse statments, or the kernel i was using (tried a few different ones) didn't like installation on the nested ifelse...
Either way, i think it has something to do with the nested ifelse statments, so might have to resort to doing an installation on the shell side? just a thought... and has to be possible. Let's keep this thread rolling though, so as not to die. There's alot of good that could come out of all this if we work together.
happy evenings! =)

hoffman1984 said:
My installation never failed... The script went through the motions... It took the time it would take to format, extract, etc... Told me the installation was complete. Then when i went to turn the phone on... SAMMY SCREEN!
Not sure why or how this happened... But i'm leaning toward either edify not liking nested ifelse statments, or the kernel i was using (tried a few different ones) didn't like installation on the nested ifelse...
Either way, i think it has something to do with the nested ifelse statments, so might have to resort to doing an installation on the shell side? just a thought... and has to be possible. Let's keep this thread rolling though, so as not to die. There's alot of good that could come out of all this if we work together.
happy evenings! =)
Click to expand...
Click to collapse
Yeah I know I get the Sammy screen everytime, I have been developing a rom and I really wanna incorporate this. SO COME ON PEOPLE DON'T LET THIS DIE!!!

Related

Why is my ext2 conversion of /cache not working?

#!/sbin/ash
DEVICE="/dev/stl14"
DIR="/cache"
umount $DEVICE
true
if [ $? = 0 ];
then
mkfs.ext2 -q -b 4096 $DEVICE
mount -t ext2 -o rw,noatime,nodiratime,nodev,nosuid $DEVICE $DIR
echo "/cache converted successfuly!" > /sdcard/ext2_cache.log
else
echo "/cache conversion error: unable to umount /cache" > /sdcard/ext2_cache.log
fi;
Click to expand...
Click to collapse
This scripts is executed in adb shell while in CWM...
On a reboot, my /cache is not mounted :/ and when I force to mount it
with
mount -t ext2 /dev/stl14 /cache
Click to expand...
Click to collapse
I get strange artifacts on my screen...
But for app2sd the phone uses ext2 as well... So why is ext2 not working for /cache then?
The link to app2sd is here: http://forum.xda-developers.com/showpost.php?p=16979976&postcount=552
Am I missing something?

Backtrack issue HTC jetstream

Greetings.
Ive used following script , HTC jetsteam rooted unlocked bootloader.
Code:
if [ "$perm" != "0" ];then echo "This Script Needs Root! Type : su";exit;fi
mount -o remount,rw /dev/block/mmcblk0p5 /system
export kit=/sdcard/bt
export bin=/system/bin
export mnt=/data/local/mnt
mkdir -p $mnt
export PATH=$bin:/usr/bin:/usr/local/bin:/usr/sbin:/bin:/usr/local/sbin:/usr/games:$PATH
export TERM=linux
export HOME=/root
if [ -b /dev/loop2 ]; then
echo "Loop device exists"
else
busybox mknod /dev/loop2 b 7 0
fi
mount -o loop,noatime -t ext2 $kit/bt5.img $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
busybox sysctl -w net.ipv4.ip_forward=1
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "127.0.0.1 localhost bt5" > $mnt/etc/hosts
busybox chroot $mnt /bin/bash
echo "Shutting down BackTrack ARM For Xoom"
umount $mnt/dev/pts
umount $mnt/proc
umount $mnt/sys
umount $mnt
but keep getting error message .
can't execute /bin/bash no such file or directory.
Hope to hear from you guys.
Regards
Net_Spy
May be u might not have busybox installed after rooting ur phone
Hit thanks rather than typing it
Well I do have busybox installed in my device.
Regards
Net_Spy

Increase TF300T /system partition size

I know this has been asked many times before, but I cannot find a good answer/tutorial on how to do this... I would like to increase the system (maybe also need to do data?) partitions on my TF300T in order to properly install gapps for 5.x
Could somebody please help?
Edit: found this script, would it be possible to modify or something else similar to be used with TF300T?
#!/sbin/sh
OUTFD=$2
ui_print() {
echo -n -e "ui_print $1\n" > /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" > /proc/self/fd/$OUTFD
}
ui_print ""
ui_print "###########################"
ui_print "# audahadi #"
ui_print "# modded from forumber2's #"
ui_print "# Repartition script #"
ui_print "# Mi 3W /system 1.2G #"
ui_print "# only! #"
ui_print "###########################"
ui_print ""
ui_print "Unmounting systems partiton..."
umount -l /system
umount -l /system1
umount -l /dev/block/mmcblk0p25
umount -l /dev/block/mmcblk0p26
ui_print ""
ui_print "WARNING! System is ready, repartitioning will start in 2 seconds"
sleep 2
ui_print ""
ui_print "Removing partitions..."
parted /dev/block/mmcblk0 rm 25
parted /dev/block/mmcblk0 rm 26
ui_print "Removing partitions...COMPLETED"
ui_print ""
ui_print "Creating new partitions..."
parted /dev/block/mmcblk0 mkpart primary 403MB 1740MB
parted /dev/block/mmcblk0 mkpart primary 1740MB 1745MB
parted /dev/block/mmcblk0 name 25 system
parted /dev/block/mmcblk0 name 26 system1
ui_print "Creating new partitions...COMPLETED"
ui_print ""
ui_print "Unmounting systems partitions again..."
umount -l /system
umount -l /system1
umount -l /dev/block/mmcblk0p25
umount -l /dev/block/mmcblk0p26
ui_print "Unmounting systems partitions again...COMPLETED"
ui_print ""
ui_print "Formatting new partitions..."
mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p25
mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p26
ui_print "Formatting new partitions...COMPLETED."
ui_print ""
ui_print "ALL DONE!..."
ui_print ""
ui_print "Rebooting to recovery in 5 seconds..."
ui_print "Thanks to forumber2 for his original GT-i9300 repartition script"
sleep 5
reboot recovery
fi
Click to expand...
Click to collapse

[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