Skip to content

Commit

Permalink
Update for Magisk Module Installer
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu authored and simonsmh committed Mar 29, 2019
1 parent 1b9b41f commit 8f22063
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 310 deletions.
204 changes: 7 additions & 197 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
@@ -1,200 +1,10 @@
#!/sbin/sh
##########################################################################################
#
# Magisk Module Template Install Script
# by topjohnwu
#
##########################################################################################
# This is a dummy file that should be replaced with a proper installer script

TMPDIR=/dev/tmp
INSTALLER=$TMPDIR/install
# Always mount under tmp
MOUNTPATH=$TMPDIR/magisk_img
# If you are creating a module locally for personal usage or testing,
# download the script in the following URL:
# https://github.com/topjohnwu/Magisk/blob/master/scripts/module_installer.sh
# And replace this script with the downloaded script

# Default permissions
umask 022

# Initial cleanup
rm -rf $TMPDIR 2>/dev/null
mkdir -p $INSTALLER

# echo before loading util_functions
ui_print() { echo "$1"; }

require_new_magisk() {
ui_print "*******************************"
ui_print " Please install Magisk v17.0+! "
ui_print "*******************************"
exit 1
}

##########################################################################################
# Environment
##########################################################################################

OUTFD=$2
ZIP=$3

mount /data 2>/dev/null

# Load utility functions
if [ -f /data/adb/magisk/util_functions.sh ]; then
. /data/adb/magisk/util_functions.sh
elif [ -f /data/magisk/util_functions.sh ]; then
NVBASE=/data
. /data/magisk/util_functions.sh
else
require_new_magisk
fi

# Use alternative image if in BOOTMODE
$BOOTMODE && IMG=$NVBASE/magisk_merge.img

# Preperation for flashable zips
setup_flashable

# Mount partitions
mount_partitions

# Detect version and architecture
api_level_arch_detect

# You can get the Android API version from $API, the CPU architecture from $ARCH
# Useful if you are creating Android version / platform dependent mods

# Setup busybox and binaries
$BOOTMODE && boot_actions || recovery_actions

##########################################################################################
# Preparation
##########################################################################################

# Extract common files
unzip -o "$ZIP" module.prop config.sh 'common/*' -d $INSTALLER >&2

[ ! -f $INSTALLER/config.sh ] && abort "! Unable to extract zip file!"
# Load configurations
. $INSTALLER/config.sh

# Check the installed magisk version
MIN_VER=`grep_prop minMagisk $INSTALLER/module.prop`
[ ! -z $MAGISK_VER_CODE -a $MAGISK_VER_CODE -ge $MIN_VER ] || require_new_magisk
MODID=`grep_prop id $INSTALLER/module.prop`
MODPATH=$MOUNTPATH/$MODID

# Print mod name
print_modname

# Please leave this message in your flashable zip for credits :)
ui_print "******************************"
ui_print "Powered by Magisk (@topjohnwu)"
ui_print "******************************"

##########################################################################################
# Install
##########################################################################################

# Get the variable reqSizeM. Use your own method to determine reqSizeM if needed
request_zip_size_check "$ZIP"

# This function will mount $IMG to $MOUNTPATH, and resize the image based on $reqSizeM
mount_magisk_img

# Create mod paths
rm -rf $MODPATH 2>/dev/null
mkdir -p $MODPATH

# Extract files to system. Use your own method if needed
ui_print "- Extracting module files"
unzip -o "$ZIP" 'system/*' -d $MODPATH >&2

# Remove placeholder
rm -f $MODPATH/system/placeholder 2>/dev/null

# Handle replace folders
for TARGET in $REPLACE; do
mktouch $MODPATH$TARGET/.replace
done

# Auto Mount
$AUTOMOUNT && touch $MODPATH/auto_mount

# prop files
$PROPFILE && cp -af $INSTALLER/common/system.prop $MODPATH/system.prop

# Module info
cp -af $INSTALLER/module.prop $MODPATH/module.prop
if $BOOTMODE; then
# Update info for Magisk Manager
mktouch /sbin/.core/img/$MODID/update
cp -af $INSTALLER/module.prop /sbin/.core/img/$MODID/module.prop
fi

# post-fs-data mode scripts
$POSTFSDATA && cp -af $INSTALLER/common/post-fs-data.sh $MODPATH/post-fs-data.sh

# service mode scripts
$LATESTARTSERVICE && cp -af $INSTALLER/common/service.sh $MODPATH/service.sh

Cfg_Migration(){
mkdir -p $MODPATH$CFGPATH
if [ -f /sbin/.core/magisk/mirror$CFGPATH$CFG ]; then
cp -af /sbin/.core/mirror$CFGPATH$CFG $MODPATH$CFGPATH$CFG
else
cp -af $CFGPATH$CFG $MODPATH$CFGPATH$CFG
fi
ui_print "- Starting modifiy"
sed -i 's/gChannelBondingMode24GHz=0/gChannelBondingMode24GHz=1/g;s/gChannelBondingMode5GHz=0/gChannelBondingMode5GHz=1/g;s/#gChannelBondingMode24GHz=1/gChannelBondingMode24GHz=1/g;s/#gChannelBondingMode5GHz=1/gChannelBondingMode5GHz=1/g' $MODPATH$CFGPATH$CFG
if [ -z $(grep gChannelBondingMode24GHz $MODPATH$CFGPATH$CFG) ]; then
sed -i 's/^END$/gChannelBondingMode24GHz=1\nEND/g' $MODPATH$CFGPATH$CFG
fi
if [ -z $(grep gChannelBondingMode5GHz $MODPATH$CFGPATH$CFG) ]; then
sed -i 's/^END$/gChannelBondingMode5GHz=1\nEND/g' $MODPATH$CFGPATH$CFG
fi
sed -i 's/gForce1x1Exception=1/gForce1x1Exception=0/g;s/#gForce1x1Exception=0/gForce1x1Exception=0/g' $MODPATH$CFGPATH$CFG
if [ -z $(grep gForce1x1Exception $MODPATH$CFGPATH$CFG) ]; then
sed -i 's/^END$/gForce1x1Exception=0\nEND/g' $MODPATH$CFGPATH$CFG
fi
}

ui_print "- Migrating WCNSS_qcom_cfg.ini"
CFG=WCNSS_qcom_cfg.ini
if [ -f /system/etc/wifi/$CFG ]; then
CFGPATH=/system/etc/wifi/
Cfg_Migration
elif [ -f /system/vendor/etc/wifi/$CFG ]; then
CFGPATH=/system/vendor/etc/wifi/
Cfg_Migration
elif [ -f /system/etc/firmware/wlan/qca_cld/$CFG ]; then
CFGPATH=/system/etc/firmware/wlan/qca_cld/
Cfg_Migration
elif [ -f /system/vendor/firmware/wlan/qca_cld/$CFG ]; then
CFGPATH=/system/vendor/firmware/wlan/qca_cld/
Cfg_Migration
elif [ -f /system/etc/firmware/wlan/prima/$CFG ]; then
CFGPATH=/system/etc/firmware/wlan/prima/
Cfg_Migration
elif [ -f /system/vendor/firmware/wlan/prima/$CFG ]; then
CFGPATH=/system/vendor/firmware/wlan/prima/
Cfg_Migration
else
ui_print "- Migration FAILED. "
ui_print " Please report it to the developer with"
ui_print " your WCNSS_qcom_cfg.ini path."
fi

ui_print "- Setting permissions"
set_permissions

##########################################################################################
# Finalizing
##########################################################################################

# Unmount magisk image and shrink if possible
unmount_magisk_img

$BOOTMODE || recovery_cleanup
rm -rf $TMPDIR

ui_print "- Done"
exit 0
# Error, this script should always be replaced
exit 1
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#### Magisk WiFi Bonding and MTK AP useful
# Magisk WiFi Bonding and MTK AP useful

Make 2.4Ghz/5Ghz WiFi running at 40Mhz and make 2x2 on MTK solution AP working on your Qualcomm devices!
Make 2.4Ghz/5Ghz WiFi running at 40Mhz and make 2x2 on MTK solution AP working on your Qualcomm devices!
[中文说明](https://github.com/Magisk-Modules-Repo-CN/magisk-wifi-bonding/blob/master/README.md)

#### Instructions
## Instructions

Please follow the instuction below from @axeldna:

Expand All @@ -18,14 +18,14 @@ Please follow the instuction below from @axeldna:

This module should work on most of the devices. By default, some devices provided an ini file to control the wifi behavior. This module modified the `WCNSS_qcom_cfg.ini` in order to support 40mhz. The basic logic is simple, but not all devices need such kind of module. If you can find `WCNSS_qcom_cfg.ini` in your system partition, please open an issue to report it to me; if you can't, this module won't work for you, including almost all Nexus/Pixel devices.

#### NOTICE
## NOTICE

* You should use latest Magisk Manager to install this module. If you meet any problem under installation from Magisk Manager, please try to install it from recovery.
* Recent fixes:
Magisk v17 Template 17000 compatabilities
New Magisk Module Format

#### Credit & Support
## Credit & Support

* Copyright (C) 2017-2018 simonsmh <[email protected]>
* Copyright (C) 2017-2019 simonsmh <[email protected]>
* Any issue or pull request is welcomed.
* Star this module at [GitHub](https://github.com/Magisk-Modules-Repo/magisk-wifi-bonding).
8 changes: 5 additions & 3 deletions common/post-fs-data.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/system/bin/sh
# Please don't hardcode /magisk/modname/... ; instead, please use $MODDIR/...
# This will make your scripts compatible even if Magisk change its mount point in the future
# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}

# This script will be executed in post-fs-data mode
# More info in the main Magisk thread
8 changes: 5 additions & 3 deletions common/service.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/system/bin/sh
# Please don't hardcode /magisk/modname/... ; instead, please use $MODDIR/...
# This will make your scripts compatible even if Magisk change its mount point in the future
# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}

# This script will be executed in late_start service mode
# More info in the main Magisk thread
99 changes: 0 additions & 99 deletions config.sh

This file was deleted.

Loading

0 comments on commit 8f22063

Please sign in to comment.