From 8c640412087a602e4bdc789a241922fcedc4a363 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Sun, 10 Jan 2016 03:40:46 -0400 Subject: AnyKernel2: fix patch_fstab, add replace_section - correct typo that was breaking patch_fstab - add function to replace entire sections of files by selecting the first and last lines of the section using search strings and replacing it entirely with a new string --- anykernel.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'anykernel.sh') 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 -- cgit v1.2.3