Commit 1283590e authored by Chris Renshaw's avatar Chris Renshaw Committed by John Wu

scripts: prepare addon.d for recovery addon.d-v2 support

- naturally there's no `su` in recovery
- major refactor for common actions and simplicity
parent dca3fe39
...@@ -33,6 +33,14 @@ initialize() { ...@@ -33,6 +33,14 @@ initialize() {
# Load utility functions # Load utility functions
. $MAGISKBIN/util_functions.sh . $MAGISKBIN/util_functions.sh
if $BOOTMODE; then
# Override ui_print when booted
ui_print() { log -t Magisk -- "$1"; }
else
OUTFD=
setup_flashable
fi
} }
show_logo() { show_logo() {
...@@ -85,23 +93,20 @@ finalize() { ...@@ -85,23 +93,20 @@ finalize() {
exit 0 exit 0
} }
main_v1() { main() {
# Wait for post addon.d processes to finish if ! $backuptool_ab; then
# Wait for post addon.d-v1 processes to finish
sleep 5 sleep 5
recovery_actions fi
show_logo $BOOTMODE || recovery_actions
mount_partitions
installation
recovery_cleanup
finalize
}
main_v2() {
show_logo show_logo
mount_partitions mount_partitions
# Swap the slot if $backuptool_ab; then
# Swap the slot for addon.d-v2
if [ ! -z $SLOT ]; then [ $SLOT = _a ] && SLOT=_b || SLOT=_a; fi if [ ! -z $SLOT ]; then [ $SLOT = _a ] && SLOT=_b || SLOT=_a; fi
fi
installation installation
$BOOTMODE || recovery_cleanup
finalize finalize
} }
...@@ -122,21 +127,17 @@ case "$1" in ...@@ -122,21 +127,17 @@ case "$1" in
# Stub # Stub
;; ;;
post-restore) post-restore)
initialize
if $backuptool_ab; then if $backuptool_ab; then
exec su -c "sh $0 addond-v2" $BOOTMODE && su=su || su=sh
exec $su -c "sh $0 addond-v2"
else else
initialize
OUTFD=
setup_flashable
# Run in background, hack for addon.d-v1 # Run in background, hack for addon.d-v1
(main_v1) & (main) &
fi fi
;; ;;
addond-v2) addond-v2)
initialize initialize
# Override ui_print main
ui_print() { log -t Magisk -- "$1"; }
# addon.d-v2
main_v2
;; ;;
esac esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment