├── META-INF └── com │ └── google │ └── android │ ├── updater-script │ └── update-binary ├── module ├── service.sh ├── wget ├── module.prop ├── functions.sh ├── system │ └── xbin │ │ └── mmsu └── updater.sh ├── .gitattributes ├── config.sh ├── install.sh └── README.md /META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | #MAGISK 2 | -------------------------------------------------------------------------------- /module/service.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | MODDIR=${0%/*} 4 | 5 | sh $MODDIR/updater.sh & 6 | -------------------------------------------------------------------------------- /module/wget: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeicPro/magisk-manager-snapshot-updater/HEAD/module/wget -------------------------------------------------------------------------------- /module/module.prop: -------------------------------------------------------------------------------- 1 | id=magisk-manager-snapshot-updater 2 | name=Magisk Manager Snapshot Updater 3 | version=v3.3.0 4 | versionCode=12 5 | author=Deiki 6 | description=Checks for updates and install them automatically. Run "mmsu" from terminal to configurate the module 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Declare files that will always have LF line endings on checkout. 2 | module/** text eol=lf 3 | META-INF/** text eol=lf 4 | config.sh text eol=lf 5 | install.sh text eol=lf 6 | 7 | # Denote all files that are truly binary and should not be modified. 8 | module/wget binary 9 | -------------------------------------------------------------------------------- /config.sh: -------------------------------------------------------------------------------- 1 | MODID=magisk-manager-snapshot-updater 2 | 3 | print_modname() { 4 | ui_print "*******************************" 5 | ui_print " Magisk Manager Snapshot" 6 | ui_print " Updater Module v3.3.0" 7 | ui_print " By Deiki (@Deic/DeicPro)" 8 | ui_print "*******************************" 9 | } 10 | 11 | set_permissions() { 12 | set_perm_recursive $MODPATH 0 0 0755 0644 13 | } 14 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | [ -d /data/magisk-manager-snapshot-updater ] || mkdir -p /data/magisk-manager-snapshot-updater 4 | 5 | cd /data/magisk-manager-snapshot-updater 6 | 7 | source module_update.txt 8 | 9 | /data/magisk/busybox unzip -o $EXTERNAL_STORAGE/MagiskManager/$module_file "module/*" 10 | 11 | cp -rf module/* /magisk/magisk-manager-snapshot-updater/ 12 | 13 | touch /magisk/magisk-manager-snapshot-updater/auto_mount 14 | 15 | chmod -R 755 /magisk/magisk-manager-snapshot-updater 16 | 17 | rm -rf module 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magisk Manager Snapshot Updater 2 | This module checks for updates & install them automatically 3 | 4 | https://forum.xda-developers.com/apps/magisk/unofficial-magisk-v10-beta-built-t3521901 5 | 6 | This project uses this tools, thanks to the awesome devs 7 | 8 | wget binary - https://github.com/pelya/wget-android 9 | 10 | Notify4Scripts apk - https://github.com/halnovemila/Notify4Scripts 11 | 12 | aapt binaries extracted from Apktool X apk - https://www.androidfilehost.com/?w=profile&uid=24562946973631820 13 | 14 | Clipper apk - https://github.com/majido/clipper 15 | -------------------------------------------------------------------------------- /module/functions.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | MODDIR=${0%/*} 4 | mod_data=/data/magisk-manager-snapshot-updater 5 | bbx=/data/magisk/busybox 6 | strg=$EXTERNAL_STORAGE/MagiskManager 7 | 8 | cd $mod_data 9 | 10 | config() { 11 | [ -f config.txt ] || { 12 | cat > config.txt < .tmp_null 2>&1 61 | error=$? 62 | [ "$error" == 0 ] && break || { [ "$error" == 4 ] && { 63 | echo "No internet connection or server is down:" 64 | echo $2; }; } || cat .tmp_null 65 | sleep 3 66 | done 67 | 68 | rm -f .tmp_null 69 | } 70 | 71 | install_tool() { 72 | apk_number=$(ls /data/app | grep $1*) 73 | 74 | while :; do 75 | [ "$apk_number" == "$(ls /data/app | grep $1*)" ] && { 76 | [ "$downloaded" ] || { 77 | download $strg/$2 $3 78 | downloaded=1 79 | } 80 | [ "$installed" ] || { 81 | notification "Install Magisk Manager ${lastest_version}" "2" "1" 82 | am start -a android.intent.action.INSTALL_PACKAGE -d file:$strg/$2 83 | notification "Updating Magisk Manager..." "2" 84 | installed=1 85 | } 86 | } || { 87 | sleep 10 88 | unset downloaded installed 89 | break 90 | } 91 | sleep 3 92 | done 93 | } 94 | -------------------------------------------------------------------------------- /module/system/xbin/mmsu: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | source /magisk/magisk-manager-snapshot-updater/functions.sh 4 | 5 | cd $mod_data 6 | 7 | val=$2 8 | 9 | usage() { 10 | [ -f config.txt ] && { chmod 755 config.txt; source config.txt; } 11 | 12 | echo "Magisk Manager Snapshot Updater Config 13 | 14 | Usage: mmsu [option] [value] 15 | 16 | Options:" 17 | 18 | [ ! "$opt" ] || [ "$opt" == wifi_only ] && { echo " wifi [0|1] 19 | Disable or enable Wi-Fi only to download, default: 1 (current: $wifi_only) 20 | "; } 21 | 22 | [ ! "$opt" ] || [ "$opt" == update_interval ] && echo " interval [N] 23 | Seconds between checks for updates, default: 600 (current: $update_interval) 24 | " 25 | 26 | [ ! "$opt" ] || [ "$opt" == notification_ticker ] && echo " ticker [0|1] 27 | Disable or enable notification's ticker, default: 1 (current: $notification_ticker) 28 | " 29 | 30 | [ ! "$opt" ] || [ "$opt" == updater_log ] && echo " log [current|old|oldest] [upload] 31 | Show target log: 32 | current - Show current log 33 | old - Show previous log 34 | oldest - Show previous' previous log 35 | upload - Upload target log to Pastebin and print URL 36 | " 37 | 38 | echo " help 39 | Show this help information 40 | " 41 | [ ! "$2" ] || [ "$2" == help ] || echo "Incorrect $1: $2 42 | " 43 | } 44 | 45 | updater_log() { 46 | [ "$1" == current ] && log=updater.log 47 | 48 | [ "$1" == old ] && log=old_updater.log 49 | 50 | [ "$1" == oldest ] && log=oldest_updater.log 51 | 52 | [ "$log" ] && [ ! "$2" ] && { [ -f $log ] && { cat $log; return; } || { echo " 53 | Log not exist"; return; }; } 54 | 55 | [ "$2" == upload ] && { 56 | echo "Uploading log..." 57 | /magisk/magisk-manager-snapshot-updater/wget --post-data "api_option=paste&api_dev_key=2dc5d9876384c0232c6ce30ae0558479&api_paste_code=$(cat $log)&api_paste_name=$log" http://pastebin.com/api/api_post.php > /dev/null 2>&1 58 | echo "Done 59 | " 60 | while :; do 61 | echo -n "What do you want to do with the URL? 62 | 1) Copy to clipboard 63 | 2) Print in terminal 64 | 3) Open in web browser 65 | > " 66 | read i 67 | [ "$i" == 1 ] && { am startservice ca.zgrs.clipper/.ClipboardService > /dev/null 2>&1; am broadcast -a clipper.set -e text "$(cat api_post.php)" > /dev/null 2>&1; echo "Copied to clipboard 68 | "; break; } 69 | [ "$i" == 2 ] && { cat api_post.php; echo; break; } 70 | [ "$i" == 3 ] && { am start -a android.intent.action.VIEW -d $(cat api_post.php) > /dev/null 2>&1; break; } 71 | echo "$i is not a valid option 72 | " 73 | done 74 | rm -f api_post.php 75 | return 76 | } 77 | 78 | [ "$2" ] && usage value $2 || usage value $1 79 | } 80 | 81 | bi_number() { [ "$1" == 0 ] || [ "$1" == 1 ] && set_value || usage value $1; } 82 | 83 | multi_number() { [ "$(echo "$1" | grep -E ^[0-9]+$)" != '' ] && set_value || usage value $1; } 84 | 85 | set_value() { 86 | [ -f config.txt ] && [ "$(grep "$opt=" config.txt)" ] && { 87 | $bbx sed -i "s/$opt=.*/$opt=$val/" config.txt 88 | } || { 89 | echo "$opt=$val" >> config.txt 90 | } 91 | } 92 | 93 | case $1 in 94 | wifi) opt=wifi_only; bi_number $val;; 95 | interval) opt=update_interval; multi_number $val;; 96 | ticker) opt=notification_ticker; bi_number $val;; 97 | log) opt=updater_log; $opt $2 $3;; 98 | *|help) usage option $1;; 99 | esac 100 | -------------------------------------------------------------------------------- /module/updater.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | while :; do [ "$(getprop sys.boot_completed)" == 1 ] && break; sleep 1; done 4 | 5 | MODDIR=${0%/*} 6 | 7 | source $MODDIR/functions.sh 8 | 9 | log_print() { 10 | echo "### Magisk Manager Snapshot Updater ### $1" 11 | echo "### Magisk Manager Snapshot Updater ### $1" >> /cache/magisk.log 12 | log -p i -t Magisk Manager Snapshot Updater "### Magisk Manager Snapshot Updater ### $1" 13 | } 14 | 15 | log_print " 16 | Run \"mmsu\" from terminal to configurate the module" 17 | 18 | [ -f $mod_data ] || mkdir -p $mod_data 19 | 20 | cd $mod_data 21 | 22 | [ -f old_updater.log ] && mv old_updater.log oldest_updater.log 23 | [ -f updater.log ] && mv updater.log old_updater.log 24 | 25 | exec &> updater.log 26 | 27 | cat /system/build.prop | grep ro.build 28 | cat /system/build.prop | grep ro.product 29 | cat /system/build.prop | grep ro.board 30 | 31 | #module_version=3.3.0 32 | module_update_file=module_update.txt 33 | update_file=magisk_manager_update.txt 34 | url=https://raw.githubusercontent.com/stangri/MagiskFiles/master 35 | 36 | module_update() { 37 | [ "$first_run" ] || notification "Checking for module updates..." "1" 38 | 39 | download $module_update_file https://raw.githubusercontent.com/DeicPro/magisk-manager-snapshot-updater/updates/$module_update_file 40 | 41 | chmod 755 $module_update_file 42 | 43 | source $module_update_file 44 | 45 | [ "$module_version" ] && [ "$module_lastest_version" ] && [ "$module_lastest_version" != "$module_version" ] && { 46 | notification "New module v${module_lastest_version} found" "1" "1" 47 | notification "Downloading module v${module_lastest_version}..." "1" 48 | download $strg/$module_file $module_download_url 49 | notification "Updating module..." "1" 50 | $bbx unzip -o $strg/$module_file install.sh 51 | chmod 755 install.sh 52 | sh install.sh 53 | rm -f install.sh 54 | notification "Module successfully updated" "1" 55 | sh $MODDIR/service.sh & 56 | exit 57 | } 58 | 59 | [ "$first_run" ] || notification "Module is up-to-date" "1" 60 | } 61 | 62 | update() { 63 | #[ "$arch" == x86_64 ] && { [ -f magisk_manager_version.txt ] || echo "version=170312" > magisk_manager_version.txt; chmod 755 magisk_manager_version.txt; source magisk_manager_version.txt; } || 64 | get_version com.topjohnwu.magisk 9 65 | 66 | echo " 67 | $(date "+[%y/%m/%d %H:%M:%S]") MAGISK MANAGER VERSION: $version 68 | " 69 | 70 | [ "$first_run" ] || notification "Checking for Magisk Manager updates..." "2" 71 | 72 | download $update_file $url/updates/$update_file 73 | 74 | chmod 755 $update_file 75 | 76 | source $update_file 77 | 78 | [ "$version" ] && [ "$lastest_version" ] && [ "$lastest_version" != "$version" ] && { 79 | [ -f $strg ] || mkdir -p $strg 80 | notification "New Magisk Manager v${lastest_version} found" "2" "1" 81 | notification "Downloading Magisk Manager v${lastest_version}..." "2" 82 | install_tool "com.topjohnwu.magisk" "$apk_file" "$download_url" 83 | #["$arch" == x86_64 ] && echo "version=$lastest_version" > magisk_manager_version.txt 84 | notification "Magisk Manager successfully updated" "2" 85 | } 86 | 87 | [ "$first_run" ] || { notification "Magisk Manager is up-to-date" "2"; first_run=1; } 88 | } 89 | 90 | echo " 91 | $(date "+[%y/%m/%d %H:%M:%S]") MODULE VERSION: $module_version 92 | " 93 | 94 | arch=Armv7 95 | 96 | [ "$(getprop ro.product.cpu.abi | $bbx cut -c-3)" == x86 ] && arch=x86 97 | [ "$(getprop ro.product.cpu.abi2 | $bbx cut -c-3)" == x86 ] && arch=x86 98 | [ "$(getprop ro.product.cpu.abi)" == arm64-v8a ] && arch=Arm64 99 | #[ "$(getprop ro.product.cpu.abi)" == x86_64 ] && arch=x86_64 100 | 101 | #[ "$arch" == x86_64 ] || { 102 | [ -f $MODDIR/aapt ] || download $MODDIR/aapt https://raw.githubusercontent.com/DeicPro/magisk-manager-snapshot-updater/bin/aapt-$arch #; } 103 | 104 | get_version com.hal9k.notify4scripts 5 105 | 106 | [ -f /data/app/com.hal9k.notify4scripts*/*.apk ] && [ "$version" == 1.0-mmsu ] || { 107 | [ -f /data/app/com.hal9k.notify4scripts*/*.apk ] && { 108 | notification "Is required to uninstall and install an app, tap please" "3" "1" 109 | am start -a android.intent.action.UNINSTALL_PACKAGE -d package:com.hal9k.notify4scripts 110 | while :; do 111 | [ -f /data/app/com.hal9k.notify4scripts*/*.apk ] || { 112 | rm -f /data/system/customized_icons/com.hal9k.notify4scripts* 113 | sleep 10 114 | break 115 | } 116 | sleep 3 117 | done 118 | } 119 | install_tool "com.hal9k.notify4scripts" "com.hal9k.notify4scripts.apk" "https://github.com/DeicPro/magisk-manager-snapshot-updater/raw/bin/com.hal9k.notify4scripts.apk" 120 | } 121 | 122 | config 123 | 124 | while :; do module_update; update; sleep $update_interval; done 125 | -------------------------------------------------------------------------------- /META-INF/com/google/android/update-binary: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | ########################################################################################## 4 | # Functions 5 | ########################################################################################## 6 | 7 | ui_print() { 8 | if ($BOOTMODE); then 9 | echo "$1" 10 | else 11 | echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD 12 | echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD 13 | fi 14 | } 15 | 16 | grep_prop() { 17 | REGEX="s/^$1=//p" 18 | shift 19 | FILES=$@ 20 | if [ -z "$FILES" ]; then 21 | FILES='/system/build.prop' 22 | fi 23 | cat $FILES 2>/dev/null | sed -n $REGEX | head -n 1 24 | } 25 | 26 | is_mounted() { 27 | if [ ! -z "$2" ]; then 28 | cat /proc/mounts | grep $1 | grep $2, >/dev/null 29 | else 30 | cat /proc/mounts | grep $1 >/dev/null 31 | fi 32 | return $? 33 | } 34 | 35 | mount_image() { 36 | if [ ! -d "$2" ]; then 37 | mkdir -p $2 2>/dev/null 38 | chmod 755 $2 39 | [ ! -d "$2" ] && return 1 40 | fi 41 | if (! is_mounted $2); then 42 | LOOPDEVICE= 43 | for LOOP in 0 1 2 3 4 5 6 7; do 44 | if (! is_mounted $2); then 45 | LOOPDEVICE=/dev/block/loop$LOOP 46 | if [ ! -f "$LOOPDEVICE" ]; then 47 | mknod $LOOPDEVICE b 7 $LOOP 48 | fi 49 | losetup $LOOPDEVICE $1 50 | if [ "$?" -eq "0" ]; then 51 | mount -t ext4 -o loop $LOOPDEVICE $2 52 | if (! is_mounted $2); then 53 | /system/bin/toolbox mount -t ext4 -o loop $LOOPDEVICE $2 54 | fi 55 | if (! is_mounted $2); then 56 | /system/bin/toybox mount -t ext4 -o loop $LOOPDEVICE $2 57 | fi 58 | fi 59 | if (is_mounted $2); then 60 | ui_print "- Mounting $1 to $2" 61 | break; 62 | fi 63 | fi 64 | done 65 | fi 66 | } 67 | 68 | set_perm() { 69 | chown $2:$3 $1 || exit 1 70 | chmod $4 $1 || exit 1 71 | if [ "$5" ]; then 72 | chcon $5 $1 2>/dev/null 73 | else 74 | chcon 'u:object_r:system_file:s0' $1 2>/dev/null 75 | fi 76 | } 77 | 78 | set_perm_recursive() { 79 | find $1 -type d 2>/dev/null | while read dir; do 80 | set_perm $dir $2 $3 $4 $6 81 | done 82 | find $1 -type f 2>/dev/null | while read file; do 83 | set_perm $file $2 $3 $5 $6 84 | done 85 | } 86 | 87 | mktouch() { 88 | mkdir -p ${1%/*} 89 | if [ -z "$2" ]; then 90 | touch $1 91 | else 92 | echo $2 > $1 93 | fi 94 | chmod 644 $1 95 | } 96 | 97 | payload_size_check() { 98 | reqSizeM=0; 99 | for entry in $(unzip -l "$@" 2>/dev/null | tail -n +4 | awk '{ print $1 }'); do 100 | test $entry != "--------" && reqSizeM=$((reqSizeM + entry)) || break; 101 | done; 102 | test $reqSizeM -lt 1048576 && reqSizeM=1 || reqSizeM=$((reqSizeM / 1048576)); 103 | } 104 | 105 | target_size_check() { 106 | e2fsck -p -f $1 107 | curBlocks=`e2fsck -n $1 2>/dev/null | cut -d, -f3 | cut -d\ -f2`; 108 | curUsedM=$((`echo "$curBlocks" | cut -d/ -f1` * 4 / 1024)); 109 | curSizeM=$((`echo "$curBlocks" | cut -d/ -f2` * 4 / 1024)); 110 | curFreeM=$((curSizeM - curUsedM)); 111 | } 112 | 113 | ########################################################################################## 114 | # Flashable update-binary preparation 115 | ########################################################################################## 116 | 117 | OUTFD=$2 118 | ZIP=$3 119 | 120 | readlink /proc/$$/fd/$OUTFD 2>/dev/null | grep /tmp >/dev/null 121 | if [ "$?" -eq "0" ]; then 122 | OUTFD=0 123 | 124 | for FD in `ls /proc/$$/fd`; do 125 | readlink /proc/$$/fd/$FD 2>/dev/null | grep pipe >/dev/null 126 | if [ "$?" -eq "0" ]; then 127 | ps | grep " 3 $FD " | grep -v grep >/dev/null 128 | if [ "$?" -eq "0" ]; then 129 | OUTFD=$FD 130 | break 131 | fi 132 | fi 133 | done 134 | fi 135 | 136 | if [ -z "$BOOTMODE" ]; then 137 | BOOTMODE=false 138 | fi 139 | 140 | if ($BOOTMODE) && (! is_mounted /magisk); then 141 | ui_print "! Magisk is not activated!... abort" 142 | exit 1 143 | fi 144 | 145 | # Fix SuperSU..... 146 | ($BOOTMODE) && /data/magisk/sepolicy-inject -s fsck --live 147 | 148 | TMPDIR=/tmp 149 | MOUNTPATH=/magisk 150 | IMGNAME=magisk.img 151 | 152 | if ($BOOTMODE); then 153 | TMPDIR=/dev/tmp 154 | MOUNTPATH=/dev/magisk_merge 155 | IMGNAME=magisk_merge.img 156 | fi 157 | 158 | mkdir -p $TMPDIR 2>/dev/null 159 | cd $TMPDIR 160 | unzip -o "$ZIP" config.sh 161 | 162 | if [ ! -f "config.sh" ]; then 163 | ui_print "! Failed: Unable to extract zip file!" 164 | exit 1 165 | fi 166 | 167 | source config.sh 168 | 169 | INSTALLER=$TMPDIR/$MODID 170 | MODPATH=$MOUNTPATH/$MODID 171 | 172 | mkdir -p $INSTALLER 173 | cd $INSTALLER 174 | unzip -o "$ZIP" "module/*" 175 | 176 | ########################################################################################## 177 | # Main 178 | ########################################################################################## 179 | 180 | # Print mod name 181 | print_modname 182 | 183 | # Please leave this message in your flashable zip for credits :) 184 | ui_print "******************************" 185 | ui_print "Powered by Magisk (@topjohnwu)" 186 | ui_print "******************************" 187 | 188 | ui_print "- Mounting /system(ro), /vendor(ro), /data, /cache" 189 | mount -o ro /system 2>/dev/null 190 | mount -o ro /vendor 2>/dev/null 191 | mount /data 2>/dev/null 192 | mount /cache 2>/dev/null 193 | 194 | if [ ! -f '/system/build.prop' ]; then 195 | ui_print "! Failed: /system could not be mounted!" 196 | exit 1 197 | fi 198 | 199 | API=$(grep_prop ro.build.version.sdk) 200 | ABI=$(grep_prop ro.product.cpu.abi | cut -c-3) 201 | ABI2=$(grep_prop ro.product.cpu.abi2 | cut -c-3) 202 | ABILONG=$(grep_prop ro.product.cpu.abi) 203 | 204 | ARCH=arm 205 | IS64BIT=false 206 | if [ "$ABI" = "x86" ]; then ARCH=x86; fi; 207 | if [ "$ABI2" = "x86" ]; then ARCH=x86; fi; 208 | if [ "$ABILONG" = "arm64-v8a" ]; then ARCH=arm64; IS64BIT=true; fi; 209 | if [ "$ABILONG" = "x86_64" ]; then ARCH=x64; IS64BIT=true; fi; 210 | 211 | # You can get the Android API version from $API, the CPU architecture from $ARCH 212 | # Useful if you are creating Android version / platform dependent mods 213 | 214 | IMG= 215 | if (is_mounted /data); then 216 | IMG=/data/$IMGNAME 217 | if [ ! -f "/data/magisk.img" ]; then 218 | ui_print "! Magisk is not installed!" 219 | ui_print "! Magisk is required for this mod!" 220 | exit 1 221 | fi 222 | else 223 | IMG=/cache/magisk.img 224 | ui_print " " 225 | ui_print "***********************************" 226 | ui_print "* !! Data unavailible !! *" 227 | ui_print "* Magisk detection is impossible *" 228 | ui_print "* Installation will still proceed *" 229 | ui_print "* But please make sure you have *" 230 | ui_print "* Magisk installed!! *" 231 | ui_print "***********************************" 232 | ui_print " " 233 | fi 234 | 235 | payload_size_check "$ZIP" "*" 236 | 237 | echo "/magisk(/.*)? u:object_r:system_file:s0" > file_contexts_image 238 | 239 | if [ -f "$IMG" ]; then 240 | ui_print "- $IMG detected!" 241 | target_size_check $IMG 242 | if [ "$reqSizeM" -gt "$curFreeM" ]; then 243 | SIZE=$((((reqSizeM + curUsedM) / 32 + 2) * 32)) 244 | ui_print "- Resizing $IMG to ${SIZE}M..." 245 | resize2fs $IMG ${SIZE}M 246 | fi 247 | else 248 | SIZE=$(((reqSizeM / 32 + 2) * 32)); 249 | ui_print "- Creating $IMG with size ${SIZE}M" 250 | make_ext4fs -l ${SIZE}M -a /magisk -S $INSTALLER/file_contexts_image $IMG 251 | fi 252 | 253 | mount_image $IMG $MOUNTPATH 254 | if (! is_mounted $MOUNTPATH); then 255 | ui_print "! $IMG mount failed... abort" 256 | exit 1 257 | fi 258 | 259 | # Create mod paths 260 | rm -rf $MODPATH 2>/dev/null 261 | mkdir -p $MODPATH 262 | 263 | # Copy files 264 | ui_print "- Copying files" 265 | 266 | mktouch $MODPATH/auto_mount 267 | 268 | # Module info 269 | cp -af $INSTALLER/module/module.prop $MODPATH/module.prop 270 | if ($BOOTMODE); then 271 | # Update info for Magisk Manager 272 | mktouch /magisk/$MODID/update 273 | cp -af $INSTALLER/module/module.prop /magisk/$MODID/module.prop 274 | fi 275 | 276 | cp -af $INSTALLER/module/service.sh $MODPATH/service.sh 277 | cp -af $INSTALLER/module/updater.sh $MODPATH/updater.sh 278 | cp -af $INSTALLER/module/wget $MODPATH/wget 279 | cp -af $INSTALLER/module/system/ $MODPATH/system/ 280 | 281 | ui_print "- Setting permissions" 282 | set_permissions 283 | chmod -R 755 $MODPATH 284 | 285 | ui_print "- Unmounting partitions" 286 | 287 | umount $MOUNTPATH 288 | losetup -d $LOOPDEVICE 289 | rmdir $MOUNTPATH 290 | 291 | # Shrink the image if possible 292 | target_size_check $IMG 293 | NEWDATASIZE=$(((curUsedM / 32 + 2) * 32)) 294 | if [ "$curSizeM" -gt "$NEWDATASIZE" ]; then 295 | ui_print "- Shrinking $IMG to ${NEWDATASIZE}M..." 296 | resize2fs $IMG ${NEWDATASIZE}M 297 | fi 298 | 299 | if (! $BOOTMODE); then 300 | umount /system 301 | umount /vendor 2>/dev/null 302 | fi 303 | 304 | ui_print "- Done" 305 | exit 0 306 | --------------------------------------------------------------------------------