├── .gitattributes ├── META-INF ├── CERT.RSA ├── CERT.SF ├── MANIFEST.MF └── com │ └── google │ └── android │ ├── update-binary │ └── updater-script ├── README.md ├── common ├── aapt ├── file_contexts_image └── mod-util.sh ├── install.sh ├── module.prop └── system └── xbin └── systemize /.gitattributes: -------------------------------------------------------------------------------- 1 | # Declare files that will always have LF line endings on checkout. 2 | META-INF/** text eol=lf 3 | *.prop text eol=lf 4 | *.sh text eol=lf 5 | *.md text eol=lf 6 | system/bin/systemize text eol=lf 7 | -------------------------------------------------------------------------------- /META-INF/CERT.RSA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Magisk-Modules-Repo/terminal_systemizer/3144ec547a66f948d57e9e73fa765dc7f76f0deb/META-INF/CERT.RSA -------------------------------------------------------------------------------- /META-INF/CERT.SF: -------------------------------------------------------------------------------- 1 | Signature-Version: 1.0 2 | SHA1-Digest-Manifest: yFhu7TfSRdC5xHROIC9V6tAWGUk= 3 | Created-By: 1.0 (Android SignApk) 4 | 5 | Name: META-INF/com/google/android/updater-script 6 | SHA1-Digest-Manifest: pVUJ9D5th6d2sD8aeNp5zhiBUcs= 7 | 8 | Name: common/aapt 9 | SHA1-Digest-Manifest: 4YV2lGD67XGVdLvutrY2zgnZKf4= 10 | 11 | Name: module.prop 12 | SHA1-Digest-Manifest: d1o8Xh4zlQhHPsiHHPjH4eSCTEw= 13 | 14 | Name: system/bin/systemize_magisk 15 | SHA1-Digest-Manifest: ZwgNn+STGAH602ajyyEv4BzNm30= 16 | 17 | Name: META-INF/com/google/android/update-binary 18 | SHA1-Digest-Manifest: mMBZ4zsqG8nP6tBnQV1WIWkLU6g= 19 | 20 | Name: common/post-fs-data.sh 21 | SHA1-Digest-Manifest: SyX3X/PeDY9ntN8RXeBKc888YZg= 22 | 23 | Name: common/system.prop 24 | SHA1-Digest-Manifest: HbzvC3Tyik76s7nzWE6amQuJyXg= 25 | 26 | Name: common/service.sh 27 | SHA1-Digest-Manifest: TOn/zXTfuf86lkAJLKXrKctujsY= 28 | 29 | Name: config.sh 30 | SHA1-Digest-Manifest: Njo4oCmhgcNamoN0Pf2sqlreJbU= 31 | 32 | Name: README.md 33 | SHA1-Digest-Manifest: 1uh3o9lGFi6E4LlfBM86xz+XrPo= 34 | 35 | Name: common/file_contexts_image 36 | SHA1-Digest-Manifest: d0Z/GcKeayRQbW+lqq5Fe4Ncjps= 37 | 38 | -------------------------------------------------------------------------------- /META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Created-By: 1.0 (Android SignApk) 3 | 4 | Name: META-INF/com/google/android/updater-script 5 | SHA1-Digest: Lzl1y1cC6TvXytLj6okU81/P8AA= 6 | 7 | Name: common/aapt 8 | SHA1-Digest: /QTAnE41/w9WjKi4klTircpywpM= 9 | 10 | Name: module.prop 11 | SHA1-Digest: PNa86qTUqUrMLt2+mes7V7Q0i70= 12 | 13 | Name: system/bin/systemize_magisk 14 | SHA1-Digest: rVkRDPgaDu2ScwfC/5X5aCH+7PY= 15 | 16 | Name: META-INF/com/google/android/update-binary 17 | SHA1-Digest: maDvkk1PGajRzQe4og+OUWtyuGQ= 18 | 19 | Name: common/post-fs-data.sh 20 | SHA1-Digest: W9c/DllxnfxrlloMGo5ef2mC+dc= 21 | 22 | Name: common/system.prop 23 | SHA1-Digest: 7TnZoxe4jX3vocrbr/oRcPziZMQ= 24 | 25 | Name: common/service.sh 26 | SHA1-Digest: hCOn0sjc2mEMqqqcb7TFt4BEcVM= 27 | 28 | Name: config.sh 29 | SHA1-Digest: FXgpbF8WaV3edRFWr4F3G9Kym5w= 30 | 31 | Name: README.md 32 | SHA1-Digest: T1dc3UTUFB4QuvKGVvjw2eIPxcs= 33 | 34 | Name: common/file_contexts_image 35 | SHA1-Digest: 3CMh9/rAwg+csTwthHJENOyhpmE= 36 | 37 | -------------------------------------------------------------------------------- /META-INF/com/google/android/update-binary: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | # This is a dummy file that should be replaced with a proper installer script 3 | 4 | # If you are creating a module locally for personal usage or testing, 5 | # download the script in the following URL: 6 | # https://github.com/topjohnwu/Magisk/blob/master/scripts/module_installer.sh 7 | # And replace this script with the downloaded script 8 | 9 | # Error, this script should always be replaced 10 | exit 1 11 | -------------------------------------------------------------------------------- /META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | #MAGISK 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## App Systemizer (Terminal Emulator) 2 | [More info and details in the XDA Thread](https://forum.xda-developers.com/apps/magisk/module-terminal-app-systemizer-ui-t3585851) 3 | 4 | Systemize your App systemlessly! 5 | Using terminal emulator. 6 | Enter this command and choose the app you want to systemize. 7 | 8 | systemize 9 | 10 | or 11 | 12 | systemize -h 13 | 14 | And you will be presented with a list of installed apps. 15 | And Reboot to apply changes. 16 | 17 | ## Error? 18 | Go to the menu and type `logs`, this will upload the log files of this module and will generate a link. Send that :) 19 | Alternatively, Send `/data/local/tmp/terminal_debloater-verbose.log` in the XDA thread. I'll examine it for problems and will try to fix it. 20 | 21 | ## Changelog 22 | 23 | ### v17.3.1 24 | * Updated mod-util 25 | ### v17.3 26 | * Updated mod-util 27 | ### v17.2.2 28 | * Fix errors systemizing 29 | ### v17.2 30 | * Updated mod-util 31 | ### v17.1 32 | * Support back Magisk v18 33 | ### v17 34 | * Update module template 35 | ### v16.2 36 | * Update mod-util 37 | * Support only Magisk v18+! 38 | ### v16.1 39 | * Update mod-util 40 | * Reverted A/B detection 41 | ### v16 42 | * Update mod-util 43 | * Changes related to Magisk's path changes (will be removed when it's added in stable) 44 | * Better A/B detection 45 | * Add -f option 46 | * This uses 'Set SELinux' function directly, and only once 47 | * Misc improvements 48 | ### v15.1 49 | * Update mod-util 50 | * This contains a fix for the ProgressBar on small devices (with small dpi) 51 | * Misc improvements 52 | ### v15 53 | * Properly fix systemizing when magisk.img is out of space 54 | * Misc improvements 55 | ### v14.3 56 | * Fix an error in systemizing large apps 57 | * Move systemize to xbin 58 | * Misc improvements 59 | ### v14.2.1 60 | * Misc improvements 61 | ### v14.2 62 | * Re-add root detection 63 | * Include app libs when systemizing 64 | ### v14.1 65 | * Update module template 66 | ### v14 67 | * Add Set SELinux option to make app detection faster 68 | * Make "Enter Label" option faster and more efficient 69 | * Name apk to it's parent folder 70 | * Misc improvements 71 | -------------------------------------------------------------------------------- /common/aapt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Magisk-Modules-Repo/terminal_systemizer/3144ec547a66f948d57e9e73fa765dc7f76f0deb/common/aapt -------------------------------------------------------------------------------- /common/file_contexts_image: -------------------------------------------------------------------------------- 1 | /magisk(/.*)? u:object_r:system_file:s0 2 | -------------------------------------------------------------------------------- /common/mod-util.sh: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # 3 | # Terminal Utility Functions 4 | # by veez21 5 | # 6 | ########################################################################################## 7 | 8 | # Versions 9 | MODUTILVER=v2.4 10 | MODUTILVCODE=240 11 | 12 | # Check A/B slot 13 | if [ -d /system_root ]; then 14 | isABDevice=true 15 | SYSTEM=/system_root/system 16 | SYSTEM2=/system 17 | CACHELOC=/data/cache 18 | else 19 | isABDevice=false 20 | SYSTEM=/system 21 | SYSTEM2=/system 22 | CACHELOC=/cache 23 | fi 24 | [ -z "$isABDevice" ] && { echo "Something went wrong!"; exit 1; } 25 | 26 | #=========================== Set Busybox up 27 | # Variables: 28 | # BBok - If busybox detection was ok (true/false) 29 | # _bb - Busybox binary directory 30 | # _bbname - Busybox name 31 | 32 | # set_busybox 33 | # alias busybox applets 34 | set_busybox() { 35 | if [ -x "$1" ]; then 36 | for i in $(${1} --list); do 37 | if [ "$i" != 'echo' ]; then 38 | alias "$i"="${1} $i" >/dev/null 2>&1 39 | fi 40 | done 41 | _busybox=true 42 | _bb=$1 43 | fi 44 | } 45 | _busybox=false 46 | if $_busybox; then 47 | true 48 | elif [ -x $SYSTEM2/xbin/busybox ]; then 49 | _bb=$SYSTEM2/xbin/busybox 50 | elif [ -x $SYSTEM2/bin/busybox ]; then 51 | _bb=$SYSTEM2/bin/busybox 52 | else 53 | echo "! Busybox not detected" 54 | echo "Please install one (@osm0sis' busybox recommended)" 55 | false 56 | fi 57 | set_busybox $_bb 58 | [ $? -ne 0 ] && exit $? 59 | [ -n "$ANDROID_SOCKET_adbd" ] && alias clear='echo' 60 | _bbname="$($_bb | head -n1 | awk '{print $1,$2}')" 61 | BBok=true 62 | if [ "$_bbname" == "" ]; then 63 | _bbname="BusyBox not found!" 64 | BBok=false 65 | fi 66 | 67 | #=========================== Default Functions and Variables 68 | 69 | # Set perm 70 | set_perm() { 71 | chown $2:$3 $1 || return 1 72 | chmod $4 $1 || return 1 73 | [ -z $5 ] && chcon 'u:object_r:system_file:s0' $1 || chcon $5 $1 || return 1 74 | } 75 | 76 | # Set perm recursive 77 | set_perm_recursive() { 78 | find $1 -type d 2>/dev/null | while read dir; do 79 | set_perm $dir $2 $3 $4 $6 80 | done 81 | find $1 -type f -o -type l 2>/dev/null | while read file; do 82 | set_perm $file $2 $3 $5 $6 83 | done 84 | } 85 | 86 | # Mktouch 87 | mktouch() { 88 | mkdir -p ${1%/*} 2>/dev/null 89 | [ -z $2 ] && touch $1 || echo $2 > $1 90 | chmod 644 $1 91 | } 92 | 93 | # Grep prop 94 | grep_prop() { 95 | local REGEX="s/^$1=//p" 96 | shift 97 | local FILES=$@ 98 | [ -z "$FILES" ] && FILES='/system/build.prop' 99 | sed -n "$REGEX" $FILES 2>/dev/null | head -n 1 100 | } 101 | 102 | # Abort 103 | abort() { 104 | echo "$1" 105 | exit 1 106 | } 107 | 108 | 109 | # Device Info 110 | # Variables: BRAND MODEL DEVICE API ABI ABI2 ABILONG ARCH 111 | BRAND=$(getprop ro.product.brand) 112 | MODEL=$(getprop ro.product.model) 113 | DEVICE=$(getprop ro.product.device) 114 | ROM=$(getprop ro.build.display.id) 115 | API=`grep_prop ro.build.version.sdk` 116 | ABI=`grep_prop ro.product.cpu.abi | cut -c-3` 117 | ABI2=`grep_prop ro.product.cpu.abi2 | cut -c-3` 118 | ABILONG=`grep_prop ro.product.cpu.abi` 119 | ARCH=arm 120 | ARCH32=arm 121 | IS64BIT=false 122 | if [ "$ABI" = "x86" ]; then ARCH=x86; ARCH32=x86; fi; 123 | if [ "$ABI2" = "x86" ]; then ARCH=x86; ARCH32=x86; fi; 124 | if [ "$ABILONG" = "arm64-v8a" ]; then ARCH=arm64; ARCH32=arm; IS64BIT=true; fi; 125 | if [ "$ABILONG" = "x86_64" ]; then ARCH=x64; ARCH32=x86; IS64BIT=true; fi; 126 | 127 | # Version Number 128 | VER=$(grep_prop version $MODDIR/module.prop) 129 | # Version Code 130 | REL=$(grep_prop versionCode $MODDIR/module.prop) 131 | # Author 132 | AUTHOR=$(grep_prop author $MODDIR/module.prop) 133 | # Mod Name/Title 134 | MODTITLE=$(grep_prop name $MODDIR/module.prop) 135 | 136 | # Colors 137 | G='\e[01;32m' # GREEN TEXT 138 | R='\e[01;31m' # RED TEXT 139 | Y='\e[01;33m' # YELLOW TEXT 140 | B='\e[01;34m' # BLUE TEXT 141 | V='\e[01;35m' # VIOLET TEXT 142 | Bl='\e[01;30m' # BLACK TEXT 143 | C='\e[01;36m' # CYAN TEXT 144 | W='\e[01;37m' # WHITE TEXT 145 | BGBL='\e[1;30;47m' # Background W Text Bl 146 | N='\e[0m' # How to use (example): echo "${G}example${N}" 147 | loadBar=' ' # Load UI 148 | # Remove color codes if -nc or in ADB Shell 149 | [ -n "$1" -a "$1" == "-nc" ] && shift && NC=true 150 | [ "$NC" -o -n "$ANDROID_SOCKET_adbd" ] && { 151 | G=''; R=''; Y=''; B=''; V=''; Bl=''; C=''; W=''; N=''; BGBL=''; loadBar='='; 152 | } 153 | 154 | # No. of characters in $MODTITLE, $VER, and $REL 155 | character_no=$(echo "$MODTITLE $VER $REL" | wc -c) 156 | 157 | # Divider 158 | div="${Bl}$(printf '%*s' "${character_no}" '' | tr " " "=")${N}" 159 | 160 | # title_div [-c] 161 | # based on $div with <title> 162 | title_div() { 163 | [ "$1" == "-c" ] && local character_no=$2 && shift 2 164 | [ -z "$1" ] && { local message=; no=0; } || { local message="$@ "; local no=$(echo "$@" | wc -c); } 165 | [ $character_no -gt $no ] && local extdiv=$((character_no-no)) || { echo "Invalid!"; return; } 166 | echo "${W}$message${N}${Bl}$(printf '%*s' "$extdiv" '' | tr " " "=")${N}" 167 | } 168 | 169 | # set_file_prop <property> <value> <prop.file> 170 | set_file_prop() { 171 | if [ -f "$3" ]; then 172 | if grep -q "$1=" "$3"; then 173 | sed -i "s/${1}=.*/${1}=${2}/g" "$3" 174 | else 175 | echo "$1=$2" >> "$3" 176 | fi 177 | else 178 | echo "$3 doesn't exist!" 179 | fi 180 | } 181 | 182 | # https://github.com/fearside/ProgressBar 183 | # ProgressBar <progress> <total> 184 | ProgressBar() { 185 | # Determine Screen Size 186 | if [[ "$COLUMNS" -le "57" ]]; then 187 | local var1=2 188 | local var2=20 189 | else 190 | local var1=4 191 | local var2=40 192 | fi 193 | # Process data 194 | local _progress=$(((${1}*100/${2}*100)/100)) 195 | local _done=$(((${_progress}*${var1})/10)) 196 | local _left=$((${var2}-$_done)) 197 | # Build progressbar string lengths 198 | local _done=$(printf "%${_done}s") 199 | local _left=$(printf "%${_left}s") 200 | 201 | # Build progressbar strings and print the ProgressBar line 202 | printf "\rProgress : ${BGBL}|${N}${_done// /${BGBL}$loadBar${N}}${_left// / }${BGBL}|${N} ${_progress}%%" 203 | } 204 | 205 | #https://github.com/fearside/SimpleProgressSpinner 206 | # Spinner <message> 207 | Spinner() { 208 | 209 | # Choose which character to show. 210 | case ${_indicator} in 211 | "|") _indicator="/";; 212 | "/") _indicator="-";; 213 | "-") _indicator="\\";; 214 | "\\") _indicator="|";; 215 | # Initiate spinner character 216 | *) _indicator="\\";; 217 | esac 218 | 219 | # Print simple progress spinner 220 | printf "\r${@} [${_indicator}]" 221 | } 222 | 223 | # cmd & spinner <message> 224 | e_spinner() { 225 | PID=$! 226 | h=0; anim='-\|/'; 227 | while [ -d /proc/$PID ]; do 228 | h=$(((h+1)%4)) 229 | sleep 0.02 230 | printf "\r${@} [${anim:$h:1}]" 231 | done 232 | } 233 | 234 | # test_connection 235 | # tests if there's internet connection 236 | test_connection() { 237 | echo -n "Testing internet connection " 238 | ping -q -c 1 -W 1 google.com >/dev/null 2>&1 && echo "- OK" || { echo "Error"; false; } 239 | } 240 | 241 | # Log files will be uploaded to termbin.com 242 | # Logs included: VERLOG LOG oldVERLOG oldLOG 243 | upload_logs() { 244 | $BBok && { 245 | test_connection || exit 246 | echo "Uploading logs" 247 | [ -s $VERLOG ] && verUp=$(cat $VERLOG | nc termbin.com 9999) || verUp=none 248 | [ -s $oldVERLOG ] && oldverUp=$(cat $oldVERLOG | nc termbin.com 9999) || oldverUp=none 249 | [ -s $LOG ] && logUp=$(cat $LOG | nc termbin.com 9999) || logUp=none 250 | [ -s $oldLOG ] && oldlogUp=$(cat $oldLOG | nc termbin.com 9999) || oldlogUp=none 251 | echo -n "Link: " 252 | echo "$MODEL ($DEVICE) API $API\n$ROM\n$ID\n 253 | O_Verbose: $oldverUp 254 | Verbose: $verUp 255 | 256 | O_Log: $oldlogUp 257 | Log: $logUp" | nc termbin.com 9999 258 | } || echo "Busybox not found!" 259 | exit 260 | } 261 | 262 | # Print Random 263 | # Prints a message at random 264 | # CHANCES - no. of chances <integer> 265 | # TARGET - target value out of CHANCES <integer> 266 | prandom() { 267 | local CHANCES=2 268 | local TARGET=2 269 | [ "$1" == "-c" ] && { local CHANCES=$2; local TARGET=$3; shift 3; } 270 | [ "$((RANDOM%CHANCES+1))" -eq "$TARGET" ] && echo "$@" 271 | } 272 | 273 | # Print Center 274 | # Prints text in the center of terminal 275 | pcenter() { 276 | local CHAR=$(printf "$@" | sed 's|\\e[[0-9;]*m||g' | wc -m) 277 | local hfCOLUMN=$((COLUMNS/2)) 278 | local hfCHAR=$((CHAR/2)) 279 | local indent=$((hfCOLUMN-hfCHAR)) 280 | echo "$(printf '%*s' "${indent}" '') $@" 281 | } 282 | 283 | # Heading 284 | mod_head() { 285 | clear 286 | echo "$div" 287 | echo "${W}$MODTITLE $VER${N}(${Bl}$REL${N})" 288 | echo "by ${W}$AUTHOR${N}" 289 | echo "$div" 290 | echo "${W}$_bbname${N}" 291 | echo "${Bl}$_bb${N}" 292 | echo "$div" 293 | [ -s $LOG ] && echo "Enter ${W}logs${N} to upload logs" && echo $div 294 | } 295 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # 3 | # Magisk Module Installer Script 4 | # 5 | ########################################################################################## 6 | ########################################################################################## 7 | # 8 | # Instructions: 9 | # 10 | # 1. Place your files into system folder (delete the placeholder file) 11 | # 2. Fill in your module's info into module.prop 12 | # 3. Configure and implement callbacks in this file 13 | # 4. If you need boot scripts, add them into common/post-fs-data.sh or common/service.sh 14 | # 5. Add your additional or modified system properties into common/system.prop 15 | # 16 | ########################################################################################## 17 | 18 | ########################################################################################## 19 | # Config Flags 20 | ########################################################################################## 21 | 22 | # Set to true if you do *NOT* want Magisk to mount 23 | # any files for you. Most modules would NOT want 24 | # to set this flag to true 25 | SKIPMOUNT=false 26 | 27 | # Set to true if you need to load system.prop 28 | PROPFILE=false 29 | 30 | # Set to true if you need post-fs-data script 31 | POSTFSDATA=false 32 | 33 | # Set to true if you need late_start service script 34 | LATESTARTSERVICE=false 35 | 36 | ########################################################################################## 37 | # Replace list 38 | ########################################################################################## 39 | 40 | # List all directories you want to directly replace in the system 41 | # Check the documentations for more info why you would need this 42 | 43 | # Construct your list in the following format 44 | # This is an example 45 | REPLACE_EXAMPLE=" 46 | /system/app/Youtube 47 | /system/priv-app/SystemUI 48 | /system/priv-app/Settings 49 | /system/framework 50 | " 51 | 52 | # Construct your own list here 53 | REPLACE=" 54 | " 55 | 56 | ########################################################################################## 57 | # 58 | # Function Callbacks 59 | # 60 | # The following functions will be called by the installation framework. 61 | # You do not have the ability to modify update-binary, the only way you can customize 62 | # installation is through implementing these functions. 63 | # 64 | # When running your callbacks, the installation framework will make sure the Magisk 65 | # internal busybox path is *PREPENDED* to PATH, so all common commands shall exist. 66 | # Also, it will make sure /data, /system, and /vendor is properly mounted. 67 | # 68 | ########################################################################################## 69 | ########################################################################################## 70 | # 71 | # The installation framework will export some variables and functions. 72 | # You should use these variables and functions for installation. 73 | # 74 | # ! DO NOT use any Magisk internal paths as those are NOT public API. 75 | # ! DO NOT use other functions in util_functions.sh as they are NOT public API. 76 | # ! Non public APIs are not guranteed to maintain compatibility between releases. 77 | # 78 | # Available variables: 79 | # 80 | # MAGISK_VER (string): the version string of current installed Magisk 81 | # MAGISK_VER_CODE (int): the version code of current installed Magisk 82 | # BOOTMODE (bool): true if the module is currently installing in Magisk Manager 83 | # MODPATH (path): the path where your module files should be installed 84 | # TMPDIR (path): a place where you can temporarily store files 85 | # ZIPFILE (path): your module's installation zip 86 | # ARCH (string): the architecture of the device. Value is either arm, arm64, x86, or x64 87 | # IS64BIT (bool): true if $ARCH is either arm64 or x64 88 | # API (int): the API level (Android version) of the device 89 | # 90 | # Availible functions: 91 | # 92 | # ui_print <msg> 93 | # print <msg> to console 94 | # Avoid using 'echo' as it will not display in custom recovery's console 95 | # 96 | # abort <msg> 97 | # print error message <msg> to console and terminate installation 98 | # Avoid using 'exit' as it will skip the termination cleanup steps 99 | # 100 | # set_perm <target> <owner> <group> <permission> [context] 101 | # if [context] is empty, it will default to "u:object_r:system_file:s0" 102 | # this function is a shorthand for the following commands 103 | # chown owner.group target 104 | # chmod permission target 105 | # chcon context target 106 | # 107 | # set_perm_recursive <directory> <owner> <group> <dirpermission> <filepermission> [context] 108 | # if [context] is empty, it will default to "u:object_r:system_file:s0" 109 | # for all files in <directory>, it will call: 110 | # set_perm file owner group filepermission context 111 | # for all directories in <directory> (including itself), it will call: 112 | # set_perm dir owner group dirpermission context 113 | # 114 | ########################################################################################## 115 | ########################################################################################## 116 | # If you need boot scripts, DO NOT use general boot scripts (post-fs-data.d/service.d) 117 | # ONLY use module scripts as it respects the module status (remove/disable) and is 118 | # guaranteed to maintain the same behavior in future Magisk releases. 119 | # Enable boot scripts by setting the flags in the config section above. 120 | ########################################################################################## 121 | 122 | # Set what you want to display when installing your module 123 | 124 | print_modname() { 125 | ui_print "*******************************" 126 | ui_print " Terminal App Systemizer " 127 | ui_print " by veez21 @ xda-developers " 128 | ui_print "*******************************" 129 | } 130 | 131 | # Copy/extract your module files into $MODPATH in on_install. 132 | 133 | on_install() { 134 | # The following is the default implementation: extract $ZIPFILE/system to $MODPATH 135 | # Extend/change the logic to whatever you want 136 | 137 | no_app=0 138 | no_privapp=0 139 | no_xml=0 140 | additional_size=0 141 | 142 | mkdir -p $TMPDIR/$MODID 143 | COPYPATH=$NVBASE/modules/$MODID 144 | 145 | if [ -d $COPYPATH/system/app ]; then 146 | cp -af $COPYPATH/system/app $TMPDIR/$MODID 147 | #additional_size=$((additional_size+$(du -ks $COPYPATH/system/app | awk '{print $1}'))) 148 | else 149 | no_app=1 150 | fi 151 | 152 | if [ -d $COPYPATH/system/priv-app ]; then 153 | cp -af $COPYPATH/system/priv-app $TMPDIR/$MODID 154 | #additional_size=$((additional_size+$(du -ks $COPYPATH/system/priv-app | awk '{print $1}'))) 155 | else 156 | no_privapp=1 157 | fi 158 | 159 | if [ -d $COPYPATH/system/etc/permissions ]; then 160 | cp -af $COPYPATH/system/etc/permissions $TMPDIR/$MODID 161 | #additional_size=$((additional_size+$(du -ks $COPYPATH/system/etc/permissions | awk '{print $1}'))) 162 | else 163 | no_xml=1 164 | fi 165 | 166 | #additional_size=$((additional_size / 1024 + 1)) 167 | #reqSizeM=$((reqSizeM+additional_size)) 168 | 169 | # Perform additional stuff 170 | se_value=$(grep_prop selinux $COPYPATH/module.prop) 171 | if [ "$se_value" != "true" ]; then 172 | se_value=false 173 | fi 174 | 175 | ui_print "- Extracting module files" 176 | unzip -o "$ZIPFILE" 'system/*' -d $MODPATH >&2 177 | 178 | if [ $no_app == 0 ]; then 179 | cp -af $TMPDIR/$MODID/app $MODPATH/system 180 | fi 181 | if [ $no_privapp == 0 ]; then 182 | cp -af $TMPDIR/$MODID/priv-app $MODPATH/system 183 | fi 184 | if [ $no_xml == 0 ]; then 185 | mkdir -p $MODPATH/system/etc 186 | cp -af $TMPDIR/$MODID/permissions $MODPATH/system/etc 187 | fi 188 | } 189 | 190 | # Only some special files require specific permissions 191 | # This function will be called after on_install is done 192 | # The default permissions should be good enough for most cases 193 | 194 | set_permissions() { 195 | # The following is the default rule, DO NOT remove 196 | set_perm_recursive $MODPATH 0 0 0755 0644 197 | 198 | # Here are some examples: 199 | # set_perm_recursive $MODPATH/system/lib 0 0 0755 0644 200 | # set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0 201 | # set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0 202 | # set_perm $MODPATH/system/lib/libart.so 0 0 0644 203 | cp -af $TMPDIR/aapt $MODPATH/aapt 204 | cp -af $TMPDIR/mod-util.sh $MODPATH/mod-util.sh 205 | bin=xbin 206 | if [ ! -d /system/xbin ]; then 207 | bin=bin 208 | mkdir $MODPATH/system/$bin 209 | mv $MODPATH/system/xbin/systemize $MODPATH/system/$bin 210 | rm -rf $MODPATH/system/xbin/* 211 | rmdir $MODPATH/system/xbin 212 | fi 213 | set_perm $MODPATH/system/$bin/systemize 0 0 0777 214 | set_perm $MODPATH/aapt 0 0 0777 215 | set_perm $MODPATH/mod-util.sh 0 0 0777 216 | echo "selinux=${se_value}" >> $MODPATH/module.prop 217 | } 218 | 219 | # You can add more functions to assist your custom script code 220 | -------------------------------------------------------------------------------- /module.prop: -------------------------------------------------------------------------------- 1 | id=terminal_systemizer 2 | name=App Systemizer (Terminal Emulator) 3 | version=v17.3.1 4 | versionCode=70 5 | author=veez21 6 | description=Turn apps to System Apps Systemlessly! Supports all device running Magisk. 7 | minMagisk=18000 8 | -------------------------------------------------------------------------------- /system/xbin/systemize: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # Terminal Magisk Mod Template 3 | # by veez21 @ xda-developers 4 | 5 | 6 | # Magisk Module ID ** 7 | ID="terminal_systemizer" 8 | 9 | # Detect root 10 | _name=$(basename $0) 11 | ls /data >/dev/null 2>&1 || { echo "$ID needs to run as root!"; echo "type 'su' then '$_name'"; exit 1; } 12 | 13 | # Magisk Mod Directory 14 | MOUNTPATH="/data/adb/modules" 15 | MODDIR="$MOUNTPATH/$ID" 16 | [ ! -d $MODDIR ] && { echo "Module not detected!"; exit 1; } 17 | 18 | # Load mod-util.sh 19 | . $MODDIR/mod-util.sh || exit $? 20 | 21 | # Set Log Files 22 | mount -o remount,rw /cache 2>/dev/null 23 | mount -o rw,remount /cache 2>/dev/null 24 | # > Logs should go in this file 25 | LOG=/data/local/tmp/$ID.log 26 | oldLOG=/data/local/tmp/$ID-old.log 27 | # > Verbose output goes here 28 | VERLOG=/data/local/tmp/$ID-verbose.log 29 | oldVERLOG=/data/local/tmp/$ID-verbose-old.log 30 | 31 | # Start Logging verbosely 32 | mv -f $VERLOG $oldVERLOG 2>/dev/null; mv -f $LOG $oldLOG 2>/dev/null 33 | set -x 2>$VERLOG 34 | 35 | # Main 36 | # > You can start your MOD here. 37 | # > You can add functions, variables & etc. 38 | # > Rather than editing the default vars above. 39 | 40 | help_me() { 41 | cat << EOF 42 | $MODTITLE $VER($REL) 43 | by $AUTHOR 44 | 45 | Usage: $_name 46 | or: $_name [options]... 47 | 48 | Options: 49 | -nc removes ANSI escape codes 50 | -f use 'Set SELinux' in the session for faster app listing 51 | -a [package name] systemizes the package name(s) provided 52 | -d [apk dir] systemizes the apk(s) provided 53 | -l list all systemized apps 54 | -h show this message 55 | EOF 56 | exit 57 | } 58 | 59 | use_aapt=false 60 | export PATH=$MODDIR:$PATH 61 | [[ "$(which aapt)" ]] && use_aapt=true 62 | sysapp=0 63 | privapp=0 64 | IFUPDATED="" 65 | perm_xml1=$SYSTEM/etc/permissions/privapp-permissions-platform.xml 66 | perm_xml=$MODDIR$SYSTEM2/etc/permissions/privapp-permissions-platform.xml 67 | [ -f $perm_xml1 ] && patch_xml=true || patch_xml=false 68 | LISTFILE=$MODDIR/systemize.list 69 | BOOTMODE=true 70 | RESCAN=true 71 | MERGEIMG=/data/adb/magisk_merge.img 72 | use_cmd=false 73 | se_set=false 74 | faster_flag=false 75 | [ -f $SYSTEM2/build.prop ] && SYSTEM=$SYSTEM2 76 | 77 | # Method 78 | if [ "$1" == "-f" ]; then 79 | use_cmd=true 80 | se_set=true 81 | faster_flag=true 82 | shift 83 | elif [ "$(grep_prop selinux $MODDIR/module.prop)" == "true" ]; then 84 | use_cmd=true 85 | se_set=true 86 | else 87 | [ $(getenforce) == "Permissive" ] && use_cmd=true || { 88 | [ $ANDROID_SOCKET_adbd ] && use_cmd=true || use_cmd=false 89 | } 90 | fi 91 | method="ls /data/data" 92 | detect="codePath=$SYSTEM|targetSdk=0|codePath=/vendor/overlay" 93 | if $use_cmd; then 94 | [ $API -le 23 ] && method="pm list packages -3" 95 | [ $API -ge 24 ] && method="cmd package list packages -3" 96 | detect="targetSdk=0" 97 | fi 98 | # Detect if /system/app is available 99 | [ -d $SYSTEM/app ] && sysapp=1 100 | 101 | # Detect if /system/priv-app is available 102 | [ -d $SYSTEM/priv-app ] && privapp=1 103 | 104 | # Detect free space 105 | free_space="$(df -m $MOUNTPATH | tail -n1 | awk '{print $4}')" 106 | total_space="$(df -m $MOUNTPATH | tail -n1 | awk '{print $2}')" 107 | 108 | # List installed apps 109 | list_installed_apps() { 110 | if $RESCAN; then 111 | if $se_set; then 112 | if [ "$(getenforce)" == "Enforcing" ]; then 113 | setenforce 0 114 | else 115 | se_set=false 116 | fi 117 | fi 118 | rm $LISTFILE 2>>$LOG; app=(); app1=(); app2=(); 119 | for i in $($method | sed 's/.*://'); do 120 | h=$(((h+1)%4)) 121 | Spinner "Loading Apps" 122 | if ! dumpsys package $i | grep -qEm1 -e "($detect)" - ; then 123 | app=${i##*/} 124 | package=$app 125 | package[c]=$package 126 | dir_app[c]=/data/app/$app-*/base.apk 127 | $use_aapt && { app=$(aapt d badging ${dir_app[c]} | grep 'application-label:'); app=${app#*:}; } 128 | app1[c]=$(echo "$app" | tr ' ' '_' | tr -d "'") 129 | echo "app${c}^=${app1[c]}^=${dir_app[c]}^=${package[c]}^=" >> $LISTFILE 130 | c=$((c+1)) 131 | fi 132 | done 133 | app2=($(echo "${app1[@]}" | sed "s/.*'//g")) 134 | app=($(printf '%s\n' "${app2[@]}" | sort -f)) 135 | RESCAN=false 136 | $se_set && setenforce 1 137 | fi 138 | } 139 | 140 | # List systemized apps 141 | list_systemized_apps() { 142 | systemized_apps=(); rev_dir=(); rev_label=(); rev_app=() 143 | [ "$tmpmodpath" ] && MODDIRS="$MODDIR $path" || MODDIRS="$MODDIR" 144 | systemized_apps=($(find $MODDIRS -name "*.apk" -type f)) 145 | cc=1 146 | for i in ${systemized_apps[@]}; do 147 | ProgressBar $cc ${#systemized_apps[@]} 148 | rev_dir[cc]=${i%/*} 149 | rev_label=${i%/*} 150 | rev_label[cc]=${rev_label##*/} 151 | rev_app[cc]=${rev_label[cc]} 152 | $use_aapt && { rev_app=$(aapt d badging $i | grep 'application-label:'); rev_app=${rev_app#*:}; rev_app[cc]=$(echo $rev_app | tr ' ' '_' | tr -d "'"); } 153 | cc=$((cc+1)) 154 | done 155 | } 156 | 157 | get_cfg() { 158 | APP_NAME=$(grep -wm1 "=${1}^" $LISTFILE | tr '^=' ' ' | awk '{print $2}') || abort "Package doesn't exist!" 159 | DIR_APP=$(grep -wm1 "=${1}^" $LISTFILE | tr '^=' ' ' | awk '{print $3}') || abort "Package doesn't exist!" 160 | PKG=$(grep -wm1 "=${1}^" $LISTFILE | tr '^=' ' ' | awk '{print $4}') || abort "Package doesn't exist!" 161 | } 162 | 163 | # Systemize function 164 | # Usage: systemize <install directory> <apk directory> 165 | systemize() { 166 | if [ "$2" ]; then 167 | apkdir="$(echo $2)" 168 | [ ! -f $apkdir ] && abort " $apkdir doesn't exist!" 169 | apk=${apkdir##*/} 170 | [ "$3" ] && PKG="$3" 171 | if [ "$PKG" ]; then 172 | name=$PKG 173 | else 174 | name=${apkdir%/*}; name=${name##*/} 175 | name=$(echo $name | tr -d ' ' | tr -d "'" | tr -d '*' | tr -d '-') 176 | $use_aapt && { 177 | name=$(aapt d badging $apkdir | head -n1 | awk '{print $2}') 178 | name=$(echo ${name#*=} | tr -d ' ' | tr -d "'") 179 | } 180 | fi 181 | fi 182 | chk_apk_size $apkdir 183 | echo " Transfering ${apk}(${name}) to '$1'..." 184 | if [ -d $SYSTEM/app/${name} ] || [ -d $SYSTEM/priv-app/${name} ] || [ -d $MODDIR$SYSTEM2/app/${name} ] || [ -d $MODDIR$SYSTEM2/priv-app/${name} ]; then 185 | $UNMOUNTIMG && { 186 | unmount_magisk_img 187 | IMG=$ORIGIMG 188 | MOUNTPATH=$ORIGMOUNTPATH 189 | MODDIR=$ORIGMODDIR 190 | } 191 | abort " App exists!" 192 | else 193 | mkdir -p ${MODDIR}${1}/${name} 194 | cp -f $apkdir ${MODDIR}${1}/${name}/${name}.apk 195 | if [ -d ${apkdir%/*}/lib ]; then 196 | echo " Transfering libs" 197 | cp -rf ${apkdir%/*}/lib ${MODDIR}${1}/${name} 198 | fi 199 | set_perm_recursive ${MODDIR}${1}/${name} 0 0 0755 0644 200 | $patch_xml && [ ${1##*/} == "priv-app" ] && { 201 | echo " Granting Permissions" 202 | mkdir -p $MODDIR$SYSTEM2/etc/permissions 2>/dev/null 203 | pp=0 204 | app_perm=(); perm=() 205 | for i in $(aapt d permissions $apkdir | grep -v 'package:' | awk '{print $2}'); do 206 | _perm=$(echo ${i#*=} | tr -d "'") 207 | perm[pp]=$_perm 208 | pp=$((pp+1)) 209 | done 210 | app_perm=($(echo "${perm[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')) 211 | echo "<?xml version=\"1.0\" encoding=\"utf-8\"?> 212 | <!-- 213 | Generated by $MODTITLE by $AUTHOR 214 | --> 215 | <permissions> 216 | <privapp-permissions package=\"${name}\">" >> $MODDIR$SYSTEM2/etc/permissions/privapp-permissions-${name}.xml 217 | for i in ${app_perm[@]}; do 218 | echo " <permission name=\"$i\"/>" >> $MODDIR$SYSTEM2/etc/permissions/privapp-permissions-${name}.xml 219 | done 220 | echo " </privapp-permissions> 221 | </permissions>" >> $MODDIR$SYSTEM2/etc/permissions/privapp-permissions-${name}.xml 222 | chmod 644 $MODDIR$SYSTEM2/etc/permissions/privapp-permissions-${name}.xml 223 | } 224 | echo " ${name} - ${W}Done${N}" 225 | $UNMOUNTIMG && { 226 | unmount_magisk_img 227 | IMG=$ORIGIMG 228 | MOUNTPATH=$ORIGMOUNTPATH 229 | MODDIR=$ORIGMODDIR 230 | } 231 | fi 232 | } 233 | 234 | enter_apk_dir() { 235 | clear 236 | echo "Enter APK Path" 237 | echo "Example: ${W}/sdcard/launcher.apk${N}" 238 | echo " x - ${Bl}Back to Menu${N}" 239 | echo -n " > " 240 | read apkdir 241 | [ "$apkdir" == "x" ] && menu 242 | echo -n "Checking if file exists" 243 | if [ -f "$apkdir" ]; then 244 | echo " - OK" 245 | apk=${apkdir##*/} 246 | echo -n "Checking if file is an APK" 247 | if [ "${apk##*.}" == "apk" ]; then 248 | echo " - OK" 249 | echo -n "Checking package name" 250 | name=${apk%'.apk'*} 251 | if [ $use_aapt ]; then 252 | name=$(aapt d badging $apkdir | head -n1 | awk '{print $2}') 253 | name=${name#*=} 254 | fi 255 | name=$(echo $name | tr -d ' ' | tr -d "'") 256 | echo " - $name" 257 | if [ $privapp == 1 ] && [ $sysapp == 1 ]; then 258 | echo "Where to install?" 259 | echo -n "< 1 - $SYSTEM/app | 2 - $SYSTEM/priv-app | 0 - cancel > : " 260 | read loc 261 | if [ "$loc" == 1 ]; then 262 | systemize /system/app 263 | elif [ "$loc" == 2 ]; then 264 | systemize /system/priv-app 265 | elif [ "$loc" == 0 ]; then 266 | echo " $name canceled"; exit 267 | else 268 | abort "Invalid!" 269 | fi 270 | elif [ $sysapp == 1 ] && [ $privapp == 0 ]; then 271 | systemize /system/app 272 | elif [ $privapp == 1 ] && [ $sysapp == 0 ]; then 273 | systemize /system/priv-app 274 | else 275 | abort " - No installation directory!" 276 | fi 277 | else 278 | abort " - $apk is not an APK!" 279 | fi 280 | else 281 | abort " - $apkdir doesn't exist!" 282 | fi 283 | } 284 | 285 | enter_apk_name() { 286 | clear 287 | echo "Enter the App Label of the installed app" 288 | echo "Example: com.android.launcher" 289 | echo " x - ${Bl}Back to Menu${N}" 290 | echo -n " > " 291 | read apklabel 292 | if [ ! "$apklabel" ]; then 293 | abort "error" 294 | elif [ "$apklabel" == "x" ]; then 295 | menu 296 | fi 297 | if [ $privapp == 1 ] && [ $sysapp == 1 ]; then 298 | echo " Where to install?" 299 | echo -n " < 1 - $SYSTEM/app | 2 - $SYSTEM/priv-app | 0 - cancel > : " 300 | read loc 301 | if [ "$loc" == 1 ]; then 302 | installdir="app" 303 | elif [ "$loc" == 2 ]; then 304 | installdir="priv-app" 305 | elif [ "$loc" == 0 ]; then 306 | echo " $apklabel canceled"; exit 307 | else 308 | abort "Invalid!" 309 | fi 310 | elif [ -d $SYSTEM/priv-app ]; then 311 | installdir="priv-app" 312 | else 313 | installdir="app" 314 | fi 315 | systemize /system/$installdir /data/app/${apklabel}-*/base.apk 316 | [ $? -ne 0 ] && abort "Failed!" 317 | } 318 | 319 | # Merge 320 | merge_img() { 321 | path=/dev/magisk_merge 322 | tmpmodpath=$path/${ID} 323 | [ ! "$ORIGIMG" ] && ORIGIMG=$IMG 324 | IMG=$MERGEIMG 325 | [ ! "$ORIGMOUNTPATH" ] && ORIGMOUNTPATH=$MOUNTPATH 326 | MOUNTPATH=$path 327 | [ ! "$ORIGMODDIR" ] && ORIGMODDIR=$MODDIR 328 | MODDIR=$tmpmodpath 329 | reqSizeM=$apk_sizeM 330 | mount_magisk_img 331 | cp -rf $ORIGMODDIR/. $MODDIR 332 | } 333 | 334 | # Unmount magisk img 335 | unmount_magisk_img() { 336 | check_filesystem $IMG $MOUNTPATH 337 | newSizeM=$((curUsedM / 32 * 32 + 64)) 338 | $MAGISKBIN/magisk imgtool umount $MOUNTPATH $MAGISKLOOP 339 | if [ $curSizeM -gt $newSizeM ]; then 340 | ui_print "- Shrinking $IMG to ${newSizeM}M" 341 | $MAGISKBIN/magisk imgtool resize $IMG $newSizeM >&2 342 | fi 343 | } 344 | 345 | # Check apk size 346 | chk_apk_size() { 347 | dir_app=$(echo $1) 348 | free_space="$(df -m $MOUNTPATH | tail -n1 | awk '{print $3}')" 349 | total_space="$(df -m $MOUNTPATH | tail -n1 | awk '{print $2}')" 350 | apk_sizeM="$(du -m $dir_app | awk '{print $1}')" 351 | [ -d ${dir_app%/*}/lib ] && { 352 | lib_sizeM="$(du -ms ${dir_app%/*}/lib | awk '{print $1}')" 353 | apk_sizeM="$((apk_sizeM+lib_sizeM))" 354 | } 355 | UNMOUNTIMG=false 356 | if [ "$apk_sizeM" -gt "$((free_space-10))" ] && [ "$MOUNTPATH" == "/sbin/.magisk/img" ]; then 357 | echo " Checking App size - ${W}${apk_sizeM}M${N}" 358 | echo "- Insufficient $MOUNTPATH space!" 359 | echo "- APK size: ${apk_sizeM}M | $MOUNTPATH Free: ${free_space}M" 360 | echo "- Using magisk_merge.img in systemizing..." 361 | UNMOUNTIMG=true 362 | merge_img ${dir_app} 2>>$LOG 363 | elif [ -f "$MERGEIMG" ] && [ "$MOUNTPATH" == "/sbin/.magisk/img" ]; then 364 | echo "- Using magisk_merge.img in systemizing..." 365 | UNMOUNTIMG=true 366 | merge_img ${dir_app} 2>>$LOG 367 | else 368 | echo " Checking APK size - ${W}${apk_sizeM}M${N}" 369 | fi 370 | } 371 | 372 | mount -o remount,rw $MOUNTPATH 2>>$LOG 373 | 374 | menu_list_systemized_apps() { 375 | clear 376 | list_installed_apps 2>>$LOG 377 | clear 378 | echo "$div" 379 | title_div "Installed Apps" 380 | echo "$div" 381 | echo "" 382 | for i in $(seq 0 $((${#app[@]}-1))); do 383 | echo " $((i+1)) - ${W}${app[i]}${N}" | tr '_' ' ' 384 | done 385 | echo "" 386 | echo " ${Bl}To systemize multiple apps, enter multiple number. Example:${N} \"1 $(echo ${#app[$((${#app[@]}/3))]}) $(echo ${#app[$((${#app[@]}/2))]})\"" 387 | echo " x - ${Bl}Back to Menu${N}" 388 | echo " r - ${Bl}Refresh list${N}" 389 | echo " 0 - ${Bl}Exit${N}" 390 | echo -n "[CHOICE]: " 391 | read installed 392 | [ "$installed" == "x" ] && menu 393 | [ "$installed" == "r" ] && RESCAN=true && menu_list_systemized_apps 394 | for i in $installed; do 395 | if [ "$i" -gt ${#app[@]} ] || [ "$i" -lt 0 ] || [ "$i" == "" ] || [ -n "$(echo $i | tr -d '0-9')" ] ; then 396 | abort "Invalid!" 397 | elif [ "$i" == 0 ]; then 398 | exit 399 | else 400 | echo "$div" 401 | i=$((i-1)) 402 | echo "Systemizing ${W}${app[i]}${N}" | tr '_' ' ' 403 | get_cfg ${app[i]} 404 | echo -n " Checking APK directory" 405 | if [ -f $DIR_APP ]; then 406 | echo " - ${W}OK${N}" 407 | apkdir=$DIR_APP 408 | apk=${apkdir##*/} 409 | name=${apkdir%/*}; name=${name##*/}; name=$(echo $name | tr -d ' ' | tr -d "'" | tr -d '*' | tr -d '-') 410 | echo " Checking package name - ${W}$PKG${N}" 411 | if [ $privapp == 1 ] && [ $sysapp == 1 ]; then 412 | echo " Where to install?" 413 | echo -n " < 1 - $SYSTEM/app | 2 - $SYSTEM/priv-app | 0 - cancel > : " 414 | read loc 415 | if [ "$loc" == 1 ]; then 416 | systemize /system/app 417 | elif [ "$loc" == 2 ]; then 418 | systemize /system/priv-app 419 | elif [ "$loc" == 0 ]; then 420 | echo " ${app[i]} canceled"; true 421 | else 422 | abort "Invalid!" 423 | fi 424 | elif [ $sysapp == 1 ] && [ $privapp == 0 ]; then 425 | systemize /system/app 426 | elif [ $privapp == 1 ] && [ $sysapp == 0 ]; then 427 | systemize /system/priv-app 428 | else 429 | abort " - No installation directory!" 430 | fi 431 | else 432 | abort " - APK doesn't exist!" 433 | fi 434 | fi 435 | done 436 | echo "Reboot to apply changes" 437 | echo -n "Return to menu? < y | n >: " 438 | read mchoice 439 | [ "$mchoice" == "y" ] && menu || exit 440 | } 441 | 442 | revert_apps() { 443 | list_systemized_apps 2>>$LOG 444 | clear 445 | echo "$div" 446 | title_div "Revert" 447 | echo "$div" 448 | echo "" 449 | for i in $(seq 1 $((${#rev_app[@]}-1))); do 450 | echo " $i - ${W}${rev_app[i]}${N}" | tr '_' ' ' 451 | done 452 | echo "" 453 | echo " ${Bl}To systemize multiple apps, enter multiple number. Example:${N} \"1 ${#rev_app[$((${#rev_app[@]}/3))]} ${#rev_app[$((${#rev_app[@]}/2))]}\"" 454 | echo " x - ${Bl}Back to Menu${N}" 455 | echo " 0 - Exit" 456 | echo -n "[CHOICE]: " 457 | read revert 458 | [ "$revert" == "x" ] && menu 459 | for i in $revert; do 460 | if [ "$i" -gt ${#rev_app[@]} ] || [ "$i" -lt 0 ] || [ "$i" == "" ] || [ -n "$(echo $i | tr -d '0-9')" ] ; then 461 | abort "Invalid!" 462 | elif [ "$i" == 0 ]; then 463 | exit 464 | else 465 | echo "Reverting ${rev_app[i]}..." | tr '_' ' ' 466 | rm -rf ${rev_dir[i]} 467 | rm -rf $MODDIR$SYSTEM2/etc/permissions/privapp-permissions-${rev_label[i]}.xml >>$LOG 2>&1 468 | fi 469 | done 470 | echo "Reboot to apply changes" 471 | echo -n "Return to menu? < y | n >: " 472 | read mchoice 473 | [ "$mchoice" == "y" ] && menu || exit 474 | } 475 | 476 | set_selinux() { 477 | clear 478 | echo "$div" 479 | title_div "Set SELinux" 480 | echo "$div" 481 | echo " This setting turns on the ability to dynamically disable" 482 | echo " SELinux if enabled (only when needed to enable unrestricted" 483 | echo " actions) for the script to execute noticeably faster." 484 | echo " It is fairly safe to do since it will immediately return" 485 | echo " SELinux status after a certain action." 486 | echo "$div" 487 | echo "" 488 | stat_color=$G 489 | $faster_flag || se_set="$(grep_prop selinux $MODDIR/module.prop)" 490 | [ "$se_set" != true ] && se_set=false && stat_color=$R 491 | echo " SELinux Status: $(getenforce)" 492 | echo " Enabled: ${stat_color}$se_set${N}" 493 | [ $(getenforce) == "Permissive" ] && echo " ${Y}SELinux is disabled! No need to enable this if it's permissive.${N}" 494 | echo "" 495 | echo " c - ${W}Change status${N}" 496 | echo " x - ${Bl}Back to Menu${N}" 497 | echo " 0 - Exit" 498 | echo -n "[CHOICE]: " 499 | read sechoice 500 | case "$sechoice" in 501 | x|X) menu;; 502 | c|C) if $faster_flag; then 503 | echo "Using '-f' (faster) option, changes will not be applied!" 504 | exit 505 | elif $se_set; then 506 | set_file_prop selinux false $MODDIR/module.prop 507 | echo "Set to false" 508 | echo "Exiting script to apply changes" 509 | exit 510 | else 511 | set_file_prop selinux true $MODDIR/module.prop 512 | echo "Set to true" 513 | echo "Exiting script to apply changes" 514 | exit 515 | fi;; 516 | 0) exit;; 517 | *) echo "Invalid!"; exit;; 518 | esac 519 | } 520 | 521 | menu() { 522 | mod_head 523 | stat_color=$G 524 | $faster_flag || se_set="$(grep_prop selinux $MODDIR/module.prop)" 525 | [ "$se_set" != true ] && se_set=false && stat_color=$R 526 | echo "Set SELinux Enabled: ${stat_color}$se_set${N}" 527 | echo "SELinux Status: $(getenforce)" 528 | echo "$div" 529 | echo "" 530 | echo " 1 - Systemize Installed Apps (Listed)" 531 | echo " 2 - Systemize Installed Apps (Enter label) " 532 | echo " 3 - Systemize given APK" 533 | if [[ $(find $MODDIR -name "*.apk" 2>>$LOG) ]]; then 534 | echo " 4 - Revert Systemized Apps" 535 | fi 536 | echo " s - Set SELinux" 537 | prandom " d - ${C}Donate${N}" 538 | echo " 0 - Exit" 539 | echo "" 540 | echo -n "[CHOICE]: " 541 | read choice 542 | case "$choice" in 543 | 1) menu_list_systemized_apps;; 544 | 2) enter_apk_name; exit $?;; 545 | 3) enter_apk_dir; exit $?;; 546 | 4) revert_apps; exit $?;; 547 | 548 | d|D) am start https://paypal.me/veez21 >>$LOG 2>&1;; 549 | logs) upload_logs;; 550 | s|S) set_selinux;; 551 | 0) exit;; 552 | *) echo "Invalid!"; exit 1;; 553 | esac 554 | } 555 | 556 | case "$1" in 557 | -a) shift 558 | for i in "$@"; do 559 | [ -d $SYSTEM/priv-app ] && systemize /system/priv-app "/data/app/${i}-*/base.apk" || systemize /system/app "/data/app/${i}-*/base.apk" "$i" 560 | echo "$div" 561 | done 562 | exit;; 563 | -d) shift 564 | for i in "$@"; do 565 | [ -d $SYSTEM/priv-app ] && systemize /system/priv-app "$i" || systemize /system/app "$i" 566 | echo "$div" 567 | done 568 | exit;; 569 | -l) list_systemized_apps 2>>$LOG 570 | echo 571 | for i in ${!rev_dir[@]}; do 572 | title_div "App $i" 573 | echo "Name\t: $(echo ${rev_app[i]}| tr '_' ' ')\nLabel\t: ${rev_label[i]}\nDirectory\t: $(echo ${rev_dir[i]} | sed 's/.*\/system\///g')" | expand -t 10 574 | done 575 | exit;; 576 | -h|--help) help_me;; 577 | esac 578 | 579 | menu 580 | exit $? 581 | --------------------------------------------------------------------------------