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
This commit is contained in:
1 parent
bd4ba60cc5
commit
8c64041208
2 files changed
+13
-5
No files matched your search
+10
-3
@@ -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
|
||||
|
||||
Reference in new issue
Block a user