diff --git a/README b/README index c1c3fec..57f6290 100644 --- a/README +++ b/README @@ -32,6 +32,7 @@ do.cleanup=0 will keep the zip from removing it's working directory in /tmp/anyk dump_boot backup_file replace_string +replace_section insert_line replace_line remove_line @@ -39,12 +40,12 @@ prepend_file insert_file append_file replace_file -patch_fstab +patch_fstab write_boot "if search string" is the string it looks for to decide whether it needs to add the tweak or not, so generally something to indicate the tweak already exists. -Similarly, "line match string" and "line replace string" are the search strings that locate where the modification needs to be made for those commands, and "mount match name" and "fs match type" are both required to narrow the patch_fstab command down to the correct entry. +Similarly, "line match string" and "line replace string" are the search strings that locate where the modification needs to be made for those commands, "begin search string" and "end search string" are both required to select the first and last lines of the script block to be replaced for replace_section, and "mount match name" and "fs match type" are both required to narrow the patch_fstab command down to the correct entry. "before|after" requires you simply specify "before" or "after" for the placement of the inserted line, in relation to "line match string". diff --git a/anykernel.sh b/anykernel.sh index c389958..2f794c5 100755 --- a/anykernel.sh +++ b/anykernel.sh @@ -108,6 +108,13 @@ replace_string() { fi; } +# replace_section +replace_section() { + line=`grep -n "$2" $1 | cut -d: -f1`; + sed -i "/${2}/,/${3}/d" $1; + sed -i "${line}s;^;${4}\n;" $1; +} + # insert_line insert_line() { if [ -z "$(grep "$2" $1)" ]; then @@ -171,10 +178,10 @@ replace_file() { chmod $2 $1; } -# patch_fstab +# patch_fstab patch_fstab() { entry=$(grep "$2" $1 | grep "$3"); - if [ -z "$(echo "$entry" | grep "$5")" ]; then + if [ -z "$(echo "$entry" | grep "$6")" ]; then case $4 in block) part=$(echo "$entry" | awk '{ print $1 }');; mount) part=$(echo "$entry" | awk '{ print $2 }');; @@ -225,7 +232,7 @@ fi; backup_file fstab.tuna; patch_fstab fstab.tuna /system ext4 options "nodiratime,barrier=0" "nodev,noatime,nodiratime,barrier=0,data=writeback,noauto_da_alloc,discard"; patch_fstab fstab.tuna /cache ext4 options "barrier=0,nomblk_io_submit" "nosuid,nodev,noatime,nodiratime,errors=panic,barrier=0,nomblk_io_submit,data=writeback,noauto_da_alloc"; -patch_fstab fstab.tuna /userdata ext4 options "nomblk_io_submit,data=writeback" "nosuid,nodev,noatime,errors=panic,nomblk_io_submit,data=writeback,noauto_da_alloc"; +patch_fstab fstab.tuna /data ext4 options "nomblk_io_submit,data=writeback" "nosuid,nodev,noatime,errors=panic,nomblk_io_submit,data=writeback,noauto_da_alloc"; append_file fstab.tuna "usbdisk" fstab; # end ramdisk changes