Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

Functions

Zackptg5 edited this page Jan 4, 2020 · 12 revisions

Usable Functions

  • ui_print - Prints out message.
    Ex: ui_print "Unity is awesome"
  • grep_prop - gets a variable's value from specified file.
    Ex: grep_prop id /system/build.prop
  • is_mounted - Checks if partition is mounted. Returns a value if it is, returns nothing otherwise.
    Ex: is_mounted /magisk
  • mount_part - Mounts partition as rw.
    Ex: mount_part /odm (You'll probably want to unmount it after you're done - Ex: umount -l /odm)
  • abort - Prints message, unmounts partitions, and exits installer with error code of 1.
    Ex: abort "!Error! Exiting installer!"
  • set_perm - Only applicable to customize.sh - see file for examples. Sets the permissions of the file
  • set_perm_recursive - Only applicable to customize.sh - see file for examples. Sets the permissions of the folder and all files in it recurssively
  • mktouch - Creates an empty file, the directories for that file, and optionally, writes to the file.
    Ex: mktouch /system/etc/exlib.so
    Ex2: mktouch /system/etc/excfg.conf "example text"
  • device_check - Checks if android device is what's specified.
    Ex - returns true if device is a nexus 5x (bullhead): device_check "Bullhead"
  • install_script - Installs boot script to proper location (this is NOT for common/service.sh and common/post-fs-data.sh scripts, this is for any extra boot scripts you have). Installs to same locations as other scripts for non-magisk installs, installs as .core script for magisk installs
    To add as post-fs-data script: Ex: install_script -p $TMPDIR/common/script.sh
    To add as late_start service script: install_script -l $TMPDIR/common/script.sh
  • cp_ch - Copies/installs file/directory to 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 $TMPDIR/file $UNITY$SYS/file
    Has 3 different flags:
    • -r: copy recursively. Use this to copy a folder.
      Ex: cp_ch -r $TMPDIR/custom/audio $UNITY/audio
      Ex2: cp_ch -r $TMPDIR/custom/audio $UNITY
      (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 $TMPDIR/file $UNITY/system/file
    • -i: same as -n and but also exclude from mod INFO file. This means that the file won't be backed up with addon.d supported roms and that it also won't be uninstalled when mod is uninstalled. Use this for existing files that will be patched (like mixer_paths.xml).
      Ex: cp_ch -i $TMPDIR/file $UNITY/system/file
    • To use custom permissions, just put them at the end of the statement.
      Ex: cp_ch -n $TMPDIR/file $UNITY$SYS/file 0755
  • prop_process - Adds props in file to main system.prop file. Useful if you want different props set depending on device/rom/whatever.
    Ex: prop_process $TMPDIR/common/customprops.prop
Clone this wiki locally