summaryrefslogtreecommitdiff
path: root/anykernel.sh
diff options
context:
space:
mode:
authorosm0sis <osm0sis@outlook.com>2016-01-10 03:40:46 -0400
committerosm0sis <osm0sis@outlook.com>2016-01-10 04:15:24 -0400
commit8c640412087a602e4bdc789a241922fcedc4a363 (patch)
treee446188f52a45972c9f275f211e034be862d5edb /anykernel.sh
parentbd4ba60cc55183ffcca6f035ab0e1c959f615e49 (diff)
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
Diffstat (limited to 'anykernel.sh')
-rwxr-xr-xanykernel.sh13
1 files changed, 10 insertions, 3 deletions
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 <file> <begin search string> <end search string> <replacement string>
+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 <file> <if search string> <before|after> <line match string> <inserted line>
insert_line() {
if [ -z "$(grep "$2" $1)" ]; then
@@ -171,10 +178,10 @@ replace_file() {
chmod $2 $1;
}
-# patch_fstab <fstab file> <mount match name> <fs match type> <block|mount|fstype|options|flags> <if search string> <replacement string>
+# patch_fstab <fstab file> <mount match name> <fs match type> <block|mount|fstype|options|flags> <original string> <replacement string>
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