Functions - Zackptg5/MMT-Extended GitHub Wiki

Usable Functions (Other than ones in customize.sh)

  • ui_print <msg> - print <msg> to console
    Use this instead of 'echo' as it will not display in custom recovery's console
    Ex: ui_print "MMT Extended is awesome"
  • abort <msg> - print error message <msg> to console and terminate installation
    Avoid using 'exit' as it will skip the termination cleanup steps
    ex: abort "Error!"
  • set_perm <target> <owner> <group> <permission> [context] - sets the permissions of the <target> (file) - best to keep this in set_permissions of customize.sh - it'll get overridden otherwise by installer
    If [context] is not set, the default is "u:object_r:system_file:s0"
    See customize.sh for examples
  • set_perm_recursive <directory> <owner> <group> <dirpermission> <filepermission> [context] - sets the permissions of the <directory> (folder) - best to keep this in set_permissions of customize.sh - it'll get overridden otherwise by installer
    If [context] is not set, the default is "u:object_r:system_file:s0"
    See customize.sh for examples
  • grep_prop <value> [file] - gets a variable's <value> from specified <file>.
    If no [file] is given, /system/build.prop is used
    Ex: grep_prop id
  • is_mounted <partition> - Checks if <partition> is mounted. Returns a value if it is, returns nothing otherwise.
    Ex: is_mounted /vendor
  • mktouch <file> [input] - Creates an empty <file>, the directories for that file, and optionally, writes [input] to the file.
    Ex: mktouch /system/etc/exlib.so
    Ex2: mktouch /system/etc/excfg.conf "example text"
  • device_check <device> - Checks if android device or manufacturer is what's specified. Use -m flag to check manufacturer and either -d or no flash to check device.
    Ex - returns true if device is a nexus 5x (bullhead): device_check "Bullhead"
    Ex2: - returns true if device is a google one: device_check -m "Google"
  • install_script [type] <file> - Installs <file> (boot script) to proper location where [type] is equal to -p for post-fs-data, -l for service, or '-b' for boot-completed - $NVBASE/service.d, post-fs-data.d, or boot-completed.d (this is NOT for common/service.sh and common/post-fs-data.sh scripts, this is for any extra boot scripts you have). Boot-completed is KSU only - if magisk detected, will be installed as service script and logic will be added to script so it'll run after boot.
    To add as post-fs-data script: install_script -p $MODPATH/common/script.sh
    To add as late_start service script: install_script -l $MODPATH/common/script.sh
    To add as boot-completed script: install_script -b $MODPATH/common/script.sh
  • prop_process <prop_file> - Adds props in file to main system.prop file. Useful if you want different props set depending on device/rom/whatever.
    Ex: prop_process $MODPATH/common/customprops.prop
  • cp_ch [arg] <source> <destination> - Copies/installs <source> file/directory to <destination>/target, backs up existing target file(s) if applicable, makes any needed folders if they don't already exist, and can set permissions if you specify them (Pretty nice huh?).
    Ex: cp_ch $MODPATH/file /data/local/file
    Has 2 different flags:
    • -r: copy recursively. Use this to copy a folder.
      Ex: cp_ch -r $MODPATH/common/audio $MODPATH/audio
      Ex2: cp_ch -r $MODPATH/common/audio $MODPATH
      (Note that either work - just like if you were using cp -R: The source directory will be placed INSIDE the target directory UNLESS the target directory doesn't exist - in the above example, we're assuming that audio directory doesn't exist)
    • -n: do not backup existing file. Use this for placing files that shouldn't already exist.
      Ex: cp_ch -n $MODPATH/file $MODPATH/system/file
    • To use custom permissions, just put them at the end of the statement.
      Ex: cp_ch -n $MODPATH/file $MODPATH/system/file 0755
⚠️ **GitHub.com Fallback** ⚠️