Updating patchreserve
authormauronofrio <poronofrio@gmail.com>
Fri, 6 Sep 2019 17:41:15 +0000 (19:41 +0200)
committermauronofrio <poronofrio@gmail.com>
Fri, 6 Sep 2019 17:41:15 +0000 (19:41 +0200)
recovery/root/init.recovery.qcom.rc
recovery/root/sbin/patchreserve-service.sh [new file with mode: 0644]
recovery/root/sbin/patchreserve.sh [deleted file]

index 89d15cc302bc1df9b38ab90426f65cdc3ce4588d..68ae0f02ab86dd69f2923b3446915014913cbfde 100644 (file)
@@ -36,7 +36,6 @@ on fs
     # this is for OnePlus 7 Pro 5g stock rom flashing
     symlink /dev/block/bootdevice/by-name/mdm_oem_stanvbk /dev/block/bootdevice/by-name/mdm_oem_stanvbk_a
     symlink /dev/block/bootdevice/by-name/mdm_oem_stanvbk /dev/block/bootdevice/by-name/mdm_oem_stanvbk_b
-
     chmod 0660 /dev/qseecom
     chown system drmrpc /dev/qseecom
     chmod 0664 /dev/ion
@@ -124,6 +123,13 @@ service patchreserve /sbin/patchreserve.sh
     oneshot
     seclabel u:r:recovery:s0
 
+service patchreserve-service /sbin/patchreserve-service.sh
+    user root
+    group root
+    disabled
+    oneshot
+    seclabel u:r:recovery:s0
+
 # This helps fix ld.config.txt errors from the linker on Android 8.1+
 service ldconfigtxt /sbin/touch /sbin/ld.config.txt
     oneshot
@@ -134,6 +140,9 @@ on boot
     setprop sys.usb.config adb
     write /proc/touchpanel/gesture_enable 1
     write /sys/devices/platform/soc/c440000.qcom,spmi/spmi-0/spmi0-02/c440000.qcom,spmi:qcom,pmi8998@2:qcom,qpnp-smb2/power_supply/usb/otg_switch 1
+    chmod 0777 /sbin/patchreserve.sh
+    chmod 0777 /sbin/patchreserve-service.sh
+    start patchreserve-service
 
 on init
     start logd
@@ -157,10 +166,6 @@ on property:vendor.sys.listeners.registered=true
     start gatekeeper-1-0
     start servicemanager
     restart time_daemon
-    start patchreserve
 
 on property:sys.usb.config=mtp,adb
     restart time_daemon
-
-on property:twrp.mount_to_decrypt=1
-    start patchreserve
diff --git a/recovery/root/sbin/patchreserve-service.sh b/recovery/root/sbin/patchreserve-service.sh
new file mode 100644 (file)
index 0000000..0ad2e28
--- /dev/null
@@ -0,0 +1,64 @@
+#!/sbin/sh
+# This script is needed to permananetly keep reserve_a and reserve_b fake partitions and /data/reserve/reserve.img.
+
+n=1
+
+while [ $n -le 2 ]
+do
+# Check if already exist the /data/reserve directory symlink and create it
+if [ -d /data/reserve ];
+then
+    echo "/data/reserve already exist"
+else
+    mkdir /data/reserve
+    echo "/data/reserve created"
+fi
+
+# Check if already exist the /data/reserve/reserve.img symlink and create it
+if [ -f /data/reserve/reserve.img ];
+then
+    echo "/data/reserve/reserve.img already exist"
+else
+    touch /data/reserve/reserve.img
+    echo "/data/reserve/reserve.img created"
+fi
+
+# Check if already exist the /dev/block/bootdevice/by-name/reserve_a symlink and create it
+if [ -L /dev/block/bootdevice/by-name/reserve_a ];
+then
+    echo "/dev/block/bootdevice/by-name/reserve_a already exist"
+else
+    ln -s /data/reserve/reserve.img /dev/block/bootdevice/by-name/reserve_a
+    echo "/dev/block/bootdevice/by-name/reserve_a created"
+fi
+
+# Check if already exist the /dev/block/bootdevice/by-name/reserve_b symlink and create it
+if [ -L /dev/block/bootdevice/by-name/reserve_b ];
+then
+    echo "/dev/block/bootdevice/by-name/reserve_b already exist"
+else
+    ln -s /data/reserve/reserve.img /dev/block/bootdevice/by-name/reserve_b
+    echo "/dev/block/bootdevice/by-name/reserve_b created"
+fi
+
+# Check if already exist the /dev/block/by-name/reserve_a symlink and create it
+if [ -L /dev/block/by-name/reserve_a ];
+then
+    echo "/dev/block/by-name/reserve_a already exist"
+else
+    ln -s /data/reserve/reserve.img /dev/block/by-name/reserve_a
+    echo "/dev/block/by-name/reserve_a created"
+fi
+
+# Check if already exist the /dev/block/by-name/reserve_b symlink and create it
+if [ -L /dev/block/by-name/reserve_b ];
+then
+    echo "/dev/block/by-name/reserve_b already exist"
+else
+    ln -s /data/reserve/reserve.img /dev/block/by-name/reserve_b
+    echo "/dev/block/by-name/reserve_b created"
+fi
+
+done
+
+exit 0
diff --git a/recovery/root/sbin/patchreserve.sh b/recovery/root/sbin/patchreserve.sh
deleted file mode 100755 (executable)
index 79f77bb..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/sbin/sh
-# This script is needed for Hydrogen OS to place reserve.img in the right place.
-
-
-# Check if already exist the /data/reserve directory symlink and create it
-if [ -d /data/reserve ];
-then
-    echo "/data/reserve already exist"
-else
-    mkdir /data/reserve
-    echo "/data/reserve created"
-fi
-
-# Check if already exist the /data/reserve/reserve.img symlink and create it
-if [ -f /data/reserve/reserve.img ];
-then
-    echo "/data/reserve/reserve.img already exist"
-else
-    touch /data/reserve/reserve.img
-    echo "/data/reserve/reserve.img created"
-fi
-
-# Check if already exist the /dev/block/bootdevice/by-name/reserve_a symlink and delete it
-if [ -L /dev/block/bootdevice/by-name/reserve_a ];
-then
-    rm -f /dev/block/bootdevice/by-name/reserve_a
-    echo "symlink_a exist and removed"
-else
-    echo "symlink_a doesn't exist"
-fi
-
-# Check if already exist the /dev/block/bootdevice/by-name/reserve_b symlink and delete it
-if [ -L /dev/block/bootdevice/by-name/reserve_b ];
-then
-    rm -f /dev/block/bootdevice/by-name/reserve_b
-    echo "symlink_b exist and removed"
-else
-    echo "symlink_b doesn't exist"
-fi
-
-# Creating symlinks /dev/block/bootdevice/by-name/reserve_a and /dev/block/bootdevice/by-name/reserve_b
-ln -s /data/reserve/reserve.img /dev/block/bootdevice/by-name/reserve_a
-ln -s /data/reserve/reserve.img /dev/block/bootdevice/by-name/reserve_b
-
-echo "Patch Reserve script complete."
-exit 0