1 Star 0 Fork 1

白开水/Han.GJZS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Util_Functions.sh 29.08 KB
一键复制 编辑 原始数据 按行查看 历史
情非得已c 提交于 2021-05-04 21:04 . 2021-05-04 21:04:36 Termux同步
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
#Custom variable
export Util_Functions_Code=2021050400
export SDdir=/data/media/0
export Modules_Dir=/data/adb/modules
export Script_Dir=$TMPDIR/tmp
export install_MOD=$ShellScript/Magisk_Module/install_Module_Script.sh
export install_Frame=$ShellScript/Geek/install_Frame_Script.sh
export Install_Method=$ShellScript/Geek/Installation_Check.sh
export APK_Name_list=$Data_Dir/APK_Name.log
export APK_Name_list2=$Data_Dir/APK_Name2.log
export jian="$Script_Dir/update-binary"
export jian2="$Script_Dir/updater-script"
export Frame_Dir=/data/misc/$Package_name
export Charging_control=/sys/class/power_supply/battery/input_suspend
export Charging_control2=/sys/class/power_supply/battery/charging_enabled
export Game_Toolbox_File=/data/data/com.miui.securitycenter/files/gamebooster/freeformlist
export Status=$Data_Dir/Status.log
export Termux=$DATA_DIR/com.termux/files
export BOOTMODE=true
export Choice=0
export New_Version=2.10.9
export New_Code=2021041203
export ChongQi Configuration File File_Name Download_File File_MD5 id name version versionCode author description MODID MODNAME MODPATH MAGISK_VER MAGISK_VER_CODE LOCKED
$Have_ROOT && LOCKED=false || LOCKED=true
#Dynamic variable
export Time=`date '+%s'`
export ABI=`getprop ro.product.cpu.abi`
[[ -z "$ABI" ]] && export ABI=`getprop ro.product.cpu.abi2`
if [[ -f "$Data_Dir/GJZS_PATH" ]]; then
export GJZS=$(cat "$Data_Dir/GJZS_PATH")
else
export GJZS="$SD_PATH/$Package_name"
fi
export lu=$GJZS/Batch_installation
export lu2=$GJZS/Add_Modules
export lu3=$GJZS/XianShua
#Function
mask() {
export Magisk=`$which magisk`
export MAGISKTMP=`$Magisk --path 2>/dev/null`
[[ -z "$MAGISKTMP" ]] && export MAGISKTMP=/sbin
if [[ "$1" == '-v' ]]; then
if [[ -x $Magisk ]]; then
MAGISK_VER=`$Magisk -v | sed 's/:.*//'`
MAGISK_VER_CODE=`$Magisk -V`
else
abort "!未检测到Magisk,请确定Magisk Manager主页已显示安装了Magisk"
fi
elif [[ "$1" == '-vc' ]]; then
if [[ -x $Magisk ]]; then
MAGISK_VER=`$Magisk -v | sed 's/:.*//'`
MAGISK_VER_CODE=`$Magisk -V`
else
abort "!未检测到Magisk,请确定Magisk Manager主页已显示安装了Magisk"
fi
if [[ -d $Modules_Dir ]]; then
echo "已安装Magisk版本:$MAGISK_VER$MAGISK_VER_CODE)"
[[ $MAGISK_VER_CODE -lt 19000 ]] && abort "!未适配Magisk 19.0以下的版本,19.0以下版本采用magisk.img方式挂载模块"
echo "---------------------------------------------------------"
[[ `sh $ShellScript/support/Missing_file.sh` = 1 ]] && abort -e "已检测到Magisk需要修复运行环境\n缺失 Magisk 正常工作所需的文件,如果不修复您将无法使用模块功能,可在Magisk Manger里修复也可以在Magisk专区一键修复Magisk运行环境" || return 0
fi
elif [[ -n "$1" ]]; then
Module="$Modules_Dir/$1"
Module_XinXi="$Module/module.prop"
Module_S="$Module/post-fs-data.sh"
Module_S2="$Module/service.sh"
Module_us="$Module/uninstall.sh"
Module_prop="$Module/system.prop"
Module_Disable="$Module/disable"
Module_Remove="$Module/remove"
Module_Skip_Mount="$Module/skip_mount"
Module_Update="$Module/update"
if [[ -f $Module_XinXi ]]; then
version=`grep_prop version "$Module_XinXi"`
versionCode=`grep_prop versionCode "$Module_XinXi"`
fi
fi
}
adb() (
local ADB=`$which adb`
if [[ $# -eq 0 ]]; then
exec "$ADB"
fi
case "$1" in
help | --help | kill-server | start-server | reconnect | devices | keygen | tcpip | connect | disconnect | usb | wait-for-*)
exec "$ADB" "$@"
;;
-reset)
"$ADB" kill-server
exec "$ADB" start-server
esac
[[ -z `"$ADB" devices | egrep -vi 'List of.*'` ]] && error "!无设备连接" && exit 126
exec "$ADB" "$@"
)
fastboot() (
local FASTBOOT=`$which fastboot`
if [[ $# -eq 0 ]]; then
exec "$FASTBOOT"
fi
case "$1" in
help | --help | -h | devices)
: ;;
*)
[[ -z `"$FASTBOOT" devices` ]] && error "!无设备连接" && exit 126
;;
esac
exec "$FASTBOOT" "$@"
)
error() {
echo "$@" 1>&2
}
abort() {
error "$@"
sleep 3
exit 1
}
abort2() {
abort -e "$@\n\n错误代码:`cat $Status`"
}
show_progress() {
[[ -n $2 ]] && echo "progress:[$1/$2]" || echo "progress:[$1/100]"
}
adb2() {
if [[ "$#" -eq 0 ]]; then
adb shell
if [[ $? -ne 0 ]]; then
abort "没有设备连接无法继续哦⊙∀⊙!"
fi
elif [[ "$1" = "-s" && "$#" -eq 2 ]]; then
shift
adb shell < "$1"
elif [[ "$1" = "-c" ]]; then
shift
adb shell "$@"
fi
}
adbsu() {
local a b
a=`adb shell su --help | grep '\-c'`
[[ -n "$a" ]] && b=true || b=false
if [[ "$#" -eq 0 ]]; then
adb shell su
elif [[ "$1" = "-s" && "$#" -eq 2 ]]; then
shift
adb shell su < "$1"
elif [[ "$1" = "-c" ]]; then
shift
$b && adb shell su -c \'"$@"\' || echo "Link@" | adb shell su
fi
}
Install_curl() {
curl -where &>/dev/null && return 0
unzip --help &>/dev/null || return 1
wget -where &>/dev/null || return 1
[[ ! -f $Load ]] && return 1
local jian jian2
. $Load curl
jian=$TMPDIR/curl.zip
jian2=$Script_Dir/META-INF/com/google/android/update-binary
WGET -c -O $jian "http://d0.ananas.chaoxing.com/download/$url"
[[ ! -f "$jian" ]] && abort "!下载文件失败"
echo "- 开始安装curl"
rm -rf $Script_Dir
mkdir -p $Script_Dir
unzip -oq "$jian" 'META-INF/com/google/android/update-binary' -d $Script_Dir
if [[ -f "$jian2" ]]; then
sh "$jian2" $Package_name 1 "$jian"
PATH="$PATH"
else
abort "!解压文件失败"
fi
rm -f $jian
}
Install_Applet() {
JCe="$PeiZhi_File/Applet_Installed.log"
[[ -f "$JCe" ]] && JCe3=`cat $JCe`
Start_Install2() {
Download "$@"
if [[ -f "$Download_File" ]]; then
[[ ! -d $ELF2_Path ]] && mkdir -p "$ELF2_Path" && chown $APP_USER_ID:$APP_USER_ID $ELF2_Path || rm -rf $ELF2_Path/*
unzip -oq "$Download_File" -d "$ELF2_Path"
if [[ $? = 0 ]]; then
echo "$versionCode" >$JCe
chmod -R 700 $ELF2_Path/*
chown -R $APP_USER_ID:$APP_USER_ID $ELF2_Path/*
case "$ABI" in
arm64*)
mv -f "$ELF2_Path/arm64/"* "$ELF2_Path"
;;
arm*)
mv -f "$ELF2_Path/arm/"* "$ELF2_Path"
;;
*)
echo "! 未知的架构 ${ABI},无法安装adb & fastboot"
rm -f "$ELF2_Path/adb"
[[ $ABI = x86* ]] && mv -f "$ELF2_Path/x86/"* "$ELF2_Path"
;;
esac
echo "- $name-$versionCode安装成功。"
rm -rf "$Download_File" $ELF2_Path/{arm,arm64,x86}
fi
fi
}
if [[ -z "$JCe3" || ! -f "$ELF2_Path/CQ" ]]; then
echo "- 开始安装$name-$versionCode"
Start_Install2 "$@"
elif [[ "$JCe3" -lt "$versionCode" ]]; then
echo "- 开始更新$name-$versionCode"
Start_Install2 "$@"
fi
}
Cloud_Update() {
local File S
File="$PeiZhi_File/Cloud.zip"
JCe="${PeiZhi_File}/Cloud_Version.log"
[[ -f "$JCe" ]] && JCe5=`cat "$JCe"`
unset S
if [[ -z "$JCe5" || ! -f "$Pages/Home.xml" ]]; then
S=初始化
elif [[ "$JCe5" -lt "$Cloud_Version" ]]; then
S=更新
fi
if [[ -n "$S" ]]; then
echo "- 正在$S云端页面:$Cloud_Version"
XiaZai -s "$CODING/$Cloud_ID" "$File"
if [[ -f "$File" ]]; then
Check_MD5=`md5sum "$File" 2>/dev/null | sed 's/ .*//g'`
if [[ "$Check_MD5" != "$Cloud_MD5" ]]; then
rm -f $File
abort2 "- 更新云端页面失败"
else
unzip -oq "$File" -d ~
if [[ $? = 0 ]]; then
echo "- $S云端页面成功"
echo "$Cloud_Version" >"$JCe"
find ~ -exec chmod 700 {} \; -exec chown $APP_USER_ID:$APP_USER_ID {} \; &
rm -f "$File"
else
echo "!$S云端页面失败❌"
fi
fi
else
abort "!未连接到网络❓"
fi
fi
}
Start_Installing_Busybox() {
JCe=$PeiZhi_File/busybox_Installed.log
[[ -f $JCe ]] && JCe2=`cat $JCe`
case "$ABI" in
arm64*) Type=arm64;;
arm*) Type=arm;;
x86_64*) Type=x86_64;;
x86*) Type=x86;;
mips64*) Type=mips64;;
mips*) Type=mips;;
*) echo "! 未知的架构 ${ABI},无法安装busybox"; return 1;;
esac
Start_Install() { CloudBusybox="$8"; }
. "$Load" Install_busybox
Start_Install() {
Download "$@"
if [[ -f "$Download_File" ]]; then
BusyBox2=$ELF4_Path/busybox
[[ ! -d $ELF4_Path ]] && mkdir -p "$ELF4_Path" && chown $APP_USER_ID:$APP_USER_ID $ELF4_Path || rm -f $ELF4_Path/*
cp "$Download_File" "$BusyBox2" && chmod 700 $BusyBox2
echo "- 正在安装busybox-$Type版-$7($8)"
"$BusyBox2" --install -s "$ELF4_Path" &>/dev/null
if [[ -L "$ELF4_Path/true" ]]; then
echo "- busybox-$Type版-$7($8)安装成功。"
echo "$8" >$JCe
chown $APP_USER_ID:$APP_USER_ID "$BusyBox2"
rm -f $Download_File
else
echo "!busybox安装失败❌"
rm -f "$BusyBox2"
sleep 3
fi
fi
}
if [[ -z "$JCe2" || ! -L $ELF4_Path/true ]]; then
echo "- 开始安装busybox"
. "$Load" Install_busybox
elif [[ "$JCe2" -lt "$CloudBusybox" ]]; then
echo "- 开始更新busybox"
. "$Load" Install_busybox
fi
}
Installing_Busybox() {
Install_curl
Cloud_Update
[[ $Version_code != $New_Code ]] && exit 1
Start_Installing_Busybox
. $Load Install_Applet
[[ ! -d $lu ]] && mkdir -p $lu &>/dev/null
[[ ! -d $lu2 ]] && mkdir -p $lu2 &>/dev/null
[[ ! -d $lu3 ]] && mkdir -p $lu3 &>/dev/null
}
Start_Time() {
Start_ns=`date +'%s%N'`
}
End_Time() {
#小时、分钟、秒、毫秒、纳秒
local h min s ms ns End_ns time ms1 ms2
End_ns=`date +'%s%N'`
time=`expr $End_ns - $Start_ns`
[[ -z "$time" ]] && return 0
ns=${time:0-9}
s=${time%$ns}
ms1=`expr $ns / 1000000`
ms2=`expr $ns % 1000000`
[[ -n "$ms2" ]] && ms=$ms1.$ms2 || ms=$ms1
if [[ $s -ge 3600 ]]; then
h=`expr $s / 3600`
h=`expr $s % 3600`
if [[ $s -ge 60 ]]; then
min=`expr $s / 60`
s=`expr $s % 60`
fi
echo "- 本次$1用时:$h小时$min分钟$s$ms毫秒"
elif [[ $s -ge 60 ]]; then
min=`expr $s / 60`
s=`expr $s % 60`
echo "- 本次$1用时:$min分钟$s$ms毫秒"
elif [[ -n $s ]]; then
echo "- 本次$1用时:$s$ms毫秒"
else
echo "- 本次$1用时:$ms毫秒"
fi
}
CURL() {
local v=`getprop ro.build.version.release`
local model="`getprop ro.product.model`"
[[ -z "$v" ]] && v=10
[[ -z "$model" ]] && model='Redmi K30 5G'
curl -A "Mozilla/5.0 (Linux; Android $v; $model) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.93 Mobile Safari/537.36" "$@"
}
WGET() {
local v=`getprop ro.build.version.release`
local model="`getprop ro.product.model`"
[[ -z "$v" ]] && v=10
[[ -z "$model" ]] && model='Redmi K30 5G'
wget -U "Mozilla/5.0 (Linux; Android $v; $model) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.93 Mobile Safari/537.36" "$@"
}
XiaZai() {
local code
echo none >"$Status"
if [[ "$#" -lt 3 ]]; then
echo 2 >"$Status"
abort "!没有参数无法下载"
fi
local dir
dir=${3%/*}
if [[ ! -d "$dir" ]]; then
echo 2 >"$Status"
abort "!No such \"$dir\" directory"
fi
CURL $1 -C - -o "$3" -w "- HTTP状态码:%{http_code}\n" -kL "$2"
code=$?
echo "$code" >"$Status"
[[ $code -eq 6 ]] && error "!未连接到互联网"
[[ $code -ne 0 ]] && error "!错误代码:$code"
}
EndMD5() {
md5_down=`md5sum "$Download_File" | sed 's/ .*//g'`
if [[ "$File_MD5" != "$md5_down" ]]; then
Deleting_file
abort2 "! ["$File_Name"] MD5校验失败✘,如果一直无法下载请在关于页面私信我QQ处理"
else
echo "- ["$File_Name"]文件MD5校验成功✔"
echo "- MD5=$md5_down"
return 0
fi
}
Start_Download() {
Check_command2() {
$1 -where &>/dev/null
return $?
}
local Download_File2 File_Type YiXZ YiXZ_2 YiXZ_SuDu Remaining_Time Percentage Size2 md5_down code
Download_File2="$2"
if Check_command2 awk && Check_command2 wc && Check_command2 md5sum; then
Start_Time
XiaZai -s "$@" &
usleep 50000
code=`cat "$Status"`
[[ $code = 2 || $code = 6 ]] && abort
until [[ -f "$Download_File2" ]]; do
[[ `cat "$Status"` != none ]] && break
done
echo "- 连接服务器成功"
if [[ $File_Size -ge 1048576 ]]; then
File_Type=`awk "BEGIN{print $File_Size/1048576}"`MB
elif [[ $File_Size -ge 1024 ]]; then
File_Type=`awk "BEGIN{print $File_Size/1024}"`kb
elif [[ $File_Size -le 1024 ]]; then
File_Type=${File_Size}b
fi
echo "- 正在下载 [$File_Name2],文件总大小:${File_Type}"
echo -e "\n-----------------------------------------"
[[ `cat "$Status"` != none ]] && End_Time 下载 && EndMD5
until [[ $code != none ]]; do
YiXZ=`wc -c < $Download_File2`
sleep 1
YiXZ_2=`wc -c < $Download_File2`
if [[ $YiXZ -gt 0 ]]; then
YiXZ_SuDu=$(($YiXZ_2-$YiXZ))
Remaining_Time=`awk "BEGIN{print ($File_Size-$YiXZ_2)/$YiXZ_SuDu}" 2>/dev/null`
Remaining_Time=${Remaining_Time:-0}
Percentage=`awk "BEGIN{print $YiXZ_2/($File_Size/100)}" 2>/dev/null`
show_progress ${Percentage%.*}
if [[ $YiXZ_2 -ge 1048576 ]]; then
Size2=`awk "BEGIN{print $YiXZ_2/1048576}"`MB
elif [[ $YiXZ_2 -ge 1024 ]]; then
Size2=`awk "BEGIN{print $YiXZ_2/1024}"`kb
elif [[ $YiXZ_2 -le 1024 ]]; then
Size2=${YiXZ_2}b
fi
Schedule() { echo "- 已下载:${Size2}/$File_Type 已完成${Percentage}%" ; echo "-----------------------------------------"; }
if [[ $YiXZ_SuDu -ge 1048576 ]]; then
echo -n "- 正在飞一般的下载:`awk "BEGIN{print $YiXZ_SuDu/1048576}"`MB/s"; echo " 剩余时间$Remaining_Time/s"; Schedule
elif [[ $YiXZ_SuDu -ge 1024 ]]; then
echo -n "- 正在慢速下载:`awk "BEGIN{print $YiXZ_SuDu/1024}"`kb/s"; echo " 剩余时间$Remaining_Time/s"; Schedule
elif [[ $YiXZ_SuDu -lt 1024 && $YiXZ_SuDu -gt 0 ]]; then
echo -n "- 正在龟速下载:${YiXZ_SuDu}b/s"; echo " 剩余时间$Remaining_Time/s"; Schedule
elif [[ $YiXZ_SuDu -eq 0 ]]; then
code=`cat "$Status"`
if [[ $code = 0 ]]; then
[[ $Options = -split ]] && break
echo "- 下载完成,开始MD5校验……"
End_Time 下载
EndMD5
else
Schedule
echo "- 与服务器连接已断开,如果网络正常或别的资源可以下请私信我修复……"
sleep 1
fi
fi
fi
done
else
echo "- 正在下载 [$File_Name2]配置文件……文件总大小:${File_Size}b"
Start_Time
XiaZai -# "$@"
End_Time 下载
EndMD5
fi
}
Download() {
if [[ "$#" -lt 5 ]]; then
abort "!没有参数无法提供下载"
fi
Deleting_file() {
rm -rf "$PeiZhi_File/$Delete"*
}
MD5() {
if [[ -f "$Download_File" ]]; then
md5_down=`md5sum "$Download_File" | sed 's/ .*//g'`
if [[ "$File_MD5" != "$md5_down" ]]; then
Deleting_file
echo "- 文件已升级正在重新下载"
return 1
else
return 0
fi
else
Deleting_file
echo "- 正在连接服务器下载中……"
return 1
fi
}
local Han Options ID File_Name2 File_Size Delete split_size Total_size n size xsize PeiZhi_File0
Han=0
Options="$1"
ID="$2"
case "$Options" in
-url)
shift
Link="$ID"
;;
-net)
shift
Link="http://d0.ananas.chaoxing.com/download/$ID"
;;
-lz)
shift
Link="http://api.funs.ml/lzy/api.php?url=$ID&type=down"
;;
*)
abort "!暂不支持下载"
;;
esac
File_Name="$2"
File_Size="$3"
File_MD5="$4"
Delete="$5"
Download_File="$PeiZhi_File/$File_Name"
MD5
[[ $? -eq 0 ]] && return 0
File_Name2="$File_Name"
Start_Download "$Link" "$Download_File"
}
Mount_Write() {
GZai=$1
Result=1
echo "开始使用`which mount`挂载$2可读写$3"
mount -o rw,remount $GZai
if [[ -w /$2 ]]; then
system=/system
vendor=/vendor
Result=0
return 0
elif [[ -w "$GZai" ]]; then
Result=0
if [[ "$GZai" = / ]]; then
unset GZai
elif [[ "$GZai" = $MAGISKTMP/.magisk/mirror/system_root ]]; then
if [[ -w "$GZai/system" ]]; then
GZai="$GZai/system"
Result=0
else
unset GZai
Result=1
return 1
fi
fi
return 0
fi
echo "开始使用`busybox -where` mount挂载$2可读写$3"
echo
busybox mount -o rw,remount $GZai
if [[ -w /$2 ]]; then
system=/system
vendor=/vendor
Result=0
return 0
elif [[ -w "$GZai" ]]; then
Result=0
if [[ "$GZai" = / ]]; then
unset GZai
elif [[ "$GZai" = $MAGISKTMP/.magisk/mirror/system_root ]]; then
if [[ -w "$GZai/system" ]]; then
GZai=$GZai/system
Result=0
else
unset GZai
Result=1
return 1
fi
fi
else
unset GZai
Result=1
return 1
fi
}
Check_Mount() {
[[ "$Result" -eq 0 ]] && echo "挂载$1读写成功。"
if [[ "$Result" -eq 1 ]]; then
error "!您的`getprop ro.product.model`(Android `getprop ro.build.version.release`)设备未解锁system"
echo -e "\n\n错误详情:\n"
mount | grep -m 1 /system 1>&2
abort
fi
}
Mount_system() {
mask
Mount_Write /system system . 2>/dev/null
if [[ $? -eq 1 ]]; then
Mount_Write $MAGISKTMP/.magisk/mirror/system system .. 2>/dev/null
if [[ $? -eq 1 ]]; then
Mount_Write $MAGISKTMP/.magisk/mirror/system_root system ... 2>/dev/null
if [[ $? -eq 1 ]]; then
Mount_Write / system .... 2>/dev/null
fi
fi
fi
export system=${GZai:-/system}
export audio="$system/media/audio/ui"
Check_Mount system
Unload(){
mount -o ro,remount "$GZai" &>/dev/null
[[ -w "$GZai" ]] && busybox mount -o ro,remount "$GZai" &>/dev/null
#umount -r $GZai
}
}
Mount_vendor() {
mask
Mount_Write /vendor vendor . 2>/dev/null
if [[ $? -eq 1 ]]; then
Mount_Write $MAGISKTMP/.magisk/mirror/vendor vendor .. 2>/dev/null
if [[ $? -eq 1 ]]; then
Mount_Write / vendor ... 2>/dev/null
fi
fi
export vendor=${GZai:-/vendor}
Check_Mount vendor
Unload_vendor(){
mount -o ro,remount "$GZai" &>/dev/null
[[ ! -w "$GZai" ]] && busybox mount -o ro,remount "$GZai" &>/dev/null
#umount -r $GZai
}
}
grep_prop() {
local J="s/^$1=//p"
[[ -z "$2" ]] && { getprop $1; return $?; }
[[ -f "$2" ]] && sed -n "$J" $2 2>/dev/null | head -n 1 || return 2
}
mkdir() {
umask 022
`$which mkdir` "$@"
}
touch() {
umask 022
`$which touch` "$@"
}
set_perm() {
chown $2:$3 $1 || return 1
chmod $4 $1 || return 1
CON=$5
[ -z $CON ] && CON=u:object_r:system_file:s0
chcon $CON $1 || return 1
}
set_perm_recursive() {
find $1 -type d 2>/dev/null | while read dir; do
set_perm $dir $2 $3 $4 $6
done
find $1 -type f -o -type l 2>/dev/null | while read file; do
set_perm $file $2 $3 $5 $6
done
}
mktouch() {
mkdir -p ${1%/*} 2>/dev/null
[[ -z $2 ]] && touch "$1" || echo "$2" > "$1"
chmod 644 "$1"
}
Write_Record() {
local system=${system%/*}
local jian=$MODPATH/Write_Record.sh
cd $MODPATH
for c in `find system`; do
[[ -d "$c" ]] && continue
if [[ -f "$system/$c" ]]; then
#Original_file
echo "$c文件存在源文件开始备份"
dir=`dirname "$c"`
mkdir -p "$MODPATH/Original_file/$dir"
cp -arf "$system/$c" "$MODPATH/Original_file/$dir"
else
#Add_file
echo "$system/$c文件属于新添加文件开始写入记录"
echo "rm -f \$$c" >>$jian
fi
done
}
Inject_prop() {
if [[ -f "$MODPATH/system.prop" ]]; then
grep '^[^#]' "$MODPATH/system.prop" | while read i; do
if ! grep -q ^"$i"$ "$system/build.prop"; then
echo "$i" >>"$system/build.prop"
echo "$i" >>"$MODPATH/build.prop"
fi
done
fi
}
Delete_prop() {
if [[ -f "$MODPATH/build.prop" ]]; then
cat "$MODPATH/build.prop" | while read i; do
sed -i "/"$i"/d" "$system/build.prop"
done
fi
}
End_installation() {
lu="$MODPATH/system"
Inject_prop
case "$MODID" in
riru_edxposed | riru_edxposed_sandhook)
echo "- 已跳过模块启动脚本"
;;
*)
[[ -f "$MODPATH/service.sh" ]] && sh "$MODPATH/service.sh" &>/dev/null
[[ -f "$MODPATH/post-fs-data.sh" ]] && sh "$MODPATH/post-fs-data.sh" &>/dev/null
;;
esac
[[ ! -d "$lu" ]] && ls "$MODPATH" >"$Status" && abort2 "\n! "$MODNAME"安装失败"
Write_Record
cp -arf "$lu"/* "$system"
[[ $? = 0 ]] && echo "- "$MODNAME"安装成功" && rm -rf "$lu" || abort "!$MODNAME安装失败"
Unload
if [[ -f "$MODPATH/module.prop" ]]; then
echo "THE END"
[[ "$Result" = 0 ]] && CQ
else
abort "!未在框架目录里找到module.prop"
fi
}
check_ab_device() {
. $ShellScript/Block_Device_Name.sh | egrep -q 'boot_a|boot_b'
return $?
}
set_Game_Toolbox() {
am force-stop com.miui.securitycenter
set_perm /data/data/com.miui.securitycenter/files/gamebooster system system 700
set_perm "$Game_Toolbox_File" system system 444
echo "将在下次启动游戏时立即生效,不需要重启手机哦 ⊙∀⊙"
}
Check_Riru() {
No_Riru() {
error "*********************************************************"
error "!未安装Riru - Core 框架,安装失败!!!"
abort "*********************************************************"
}
if [[ ! -f "/data/misc/riru/api_version" && ! -f "/data/misc/riru/api_version.new" ]]; then
No_Riru
fi
}
Frame_installation_Check() {
if [[ -d "$Modules_Dir/$MODID" ]]; then
abort -e "!已检测到用Magisk模块方式安装了$MODID,无法再次安装\n模块安装目录:\"$Modules_Dir/$MODID\""
fi
}
Play_Music() {
am start -n $Package_name/com.projectkr.shell.MusicPlayer --es music "$1" 1>/dev/null
}
Power() {
echo "`cat /sys/class/power_supply/battery/capacity 2>/dev/null`%"
}
Notice() {
cat <<Han
<!-- <text> -->
<!-- <slices> -->
<!-- <slice size="12" color="#FFFF0000">服务器由于频繁被人恶意刷流量,一直ddos导致频繁奔溃,部分联网功能会无法正常使用,由于经常迁移数据库单纯累了,后续也估计不会再恢复了</slice> -->
<!-- <slice break="true"></slice> -->
<!-- <slice break="true"></slice> -->
<!-- <slice size="12" color="#FFFF0000">搞机助手一直秉承免费且开源,从酷安事件后我就只是只在自己群里发布,网上那么多人分享我也没管过什么哈。有那时间管我打打LOL多香,如果搞机助手免费得罪了你,阻碍了你的发展前途,你可以私信我QQ协商处理哈,你这样故意恶搞我,搞得多少人不开心。我开发搞机助手服务器功能只是方便别人不到处找资源而已直接搞机助手一步到位就行了,这工具对于大佬根本上用不着哈。这年头好心都得不到一个好报吗,哎!都开发2年多了一个人维护也不容易哈</slice> -->
<!-- </slices> -->
<!-- </text> -->
Han
}
module_prop() {
echo "- 正在打印模块信息……"
cat <<Han >$Module_XinXi
id=$id
name=$name
version=$version
versionCode=$versionCode
author=$author
description=$description
Han
}
Clean_install() {
[[ -z "$id" ]] && abort"!未设置id"
mask $id
rm -rf $Module
mkdir -p $Module
ui_print "- 开始安装 $name-$version($versionCode)"
ui_print "- 安装目录:$Module"
ui_print "- 模块作者:$author"
ui_print "- Powered by Magisk & topjohnwu"
abort() {
rm -rf $Module
error "$@"
sleep 3
exit 1
}
}
man() {
URL="https://gitee.com/youngdriver/command_help/raw/master"
COMMAND=`curl -sL "${URL}/help_list" | sed -n "/^$1$/p"`
[[ $COMMAND ]] || (echo "命令 [ $1 ] 不存在中文帮助,检查是否输入有误或联系管理员解决" && exit 1)
curl -sL $URL/$COMMAND
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jellyhai/Han.GJZS.git
git@gitee.com:jellyhai/Han.GJZS.git
jellyhai
Han.GJZS
Han.GJZS
master

搜索帮助