Quote:
Originally Posted by rovo89 View Post
Code:
Select Code
#!/sbin/sh
#
# /system/addon.d/90-xposed.sh
# During an upgrade, this script backs up /system/bin/app_process,
# /system is formatted and reinstalled, then the file is restored.
#

. /tmp/backuptool.functions

list_files() {
cat <<EOF
bin/app_process
bin/app_process.orig
EOF
}

case "$1" in
  backup)
    list_files | while read FILE DUMMY; do
      backup_file $S/"$FILE"
    done
  ;;
  restore)
    list_files | while read FILE REPLACEMENT; do
      R=""
      [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
      [ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
    done
  ;;
  pre-backup)
    # Stub
  ;;
  post-backup)
    # Stub
  ;;
  pre-restore)
    # Stub
  ;;
  post-restore)
    # Stub
  ;;
esac
Be aware that your script doesn't honor the purpose of the /system/bin/app_process.orig file which is expected to match the current ROM, here is an updated script:

Code:
Select Code
#!/sbin/sh
#
# /system/addon.d/90-xposed.sh
# During an upgrade, if /system/bin/app_process.orig exists, this
# script backs up /system/bin/app_process, /system is formatted
# and reinstalled, the ROM bundled /system/bin/app_process is copied as
# /system/bin/app_process.orig, then /system/bin/app_process is restored
# (as would the Xposed Installer do)

. /tmp/backuptool.functions

APP_PROCESS=bin/app_process

case "$1" in
  backup)
    [ -e "$S/${APP_PROCESS}.orig" ] && backup_file "$S/${APP_PROCESS}"
  ;;
  restore)
    if [ -e "$C/$S/${APP_PROCESS}" ]; then
      echo "Backuping new $S/${APP_PROCESS} as $S/${APP_PROCESS}.orig"
      cp -p "$S/${APP_PROCESS}" "$S/${APP_PROCESS}.orig"
      echo "Restoring Xposed $S/${APP_PROCESS}"
      restore_file "$S/${APP_PROCESS}"
      echo "If your system bootloops, you can either:"
      echo " - Replace $S/${APP_PROCESS} with $S/${APP_PROCESS}.orig"
      echo " - Remove $S/${APP_PROCESS} and reinstall your ROM"
    fi
  ;;
  pre-backup)
    # Stub
  ;;
  post-backup)
    # Stub
  ;;
  pre-restore)
    # Stub
  ;;
  post-restore)
    # Stub
  ;;
esac
Remark: For some unknown reason (at least in TWRP 2.5), the "echo" lines don't show up during the installation