Skip to content

Commit

Permalink
更新工作流配置,完善文件删除逻辑,增强脚本稳定性,升级版本号,精炼文档描述。
Browse files Browse the repository at this point in the history
  • Loading branch information
YumeYuka committed Jan 21, 2025
1 parent 2215a5c commit ac701d2
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Create Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: 同步 repo
run: |
rm -rf ./*.zip
rm -rf ./*.hash
rm -rf ./*.hash
bash -c 'if [ $(git status --porcelain | wc -l) -eq 0 ]; then
echo "工作树无变更,跳过提交步骤..."
else
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
magisk/hashList.dat
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
> 由于本人无法提供太多规则,请自行添加规则,可以pr到此仓库,具体自定义规则请查看[文档](https://intelligent.nightrainmilkyway.cn)

## 协议
## 开源许可证
### [Apache License 2.0](https://github.com/NightRainMilkyWay/intelligent/blob/master/LICENSE)
4 changes: 2 additions & 2 deletions config.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CONFIG_ENV=config.env
ZIP_FILENAME=intelligent
CONFIG_NAME=configs
IS_PRERELEASE=false
VERSION=V1.4.1
VERSIONCODE=250118
VERSION=V1.4.2
VERSIONCODE=250121

FILE=intelligent.json
9 changes: 5 additions & 4 deletions magisk/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cover_config() {
key=$(until_key)

if [ "$key" = "down" ]; then
cp "$Config" "$Config_DIR"
cp -f "$Config" "$Config_DIR"
ui_print "- 配置文件已覆盖"
else
ui_print "- 配置文件未覆盖"
Expand All @@ -38,12 +38,13 @@ if [ -d "$Config_DIR" ]; then
cover_config
else
mkdir -p "$Config_DIR"
cp "$Config" "$Config_DIR"
cp -f "$Config" "$Config_DIR"
rm -rf "$Config"
fi

ui_print ""
ui_print ""
sleep 0.5
ui_print "配置路径在/storage/emulated/0/Android/Intelligent/config.json"
ui_print "Github: https://github.com/YumeYuka/intelligent"
ui_print "如果可以的话,请给我一个Star"

skt_mod_install_finish # Don't write code after this line!
Binary file removed magisk/hashList.dat
Binary file not shown.
21 changes: 18 additions & 3 deletions magisk/service.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
// code by @YumeYuka

sleep 120
chmod 777 $MODDIR/Intelligent
nohup $MODDIR/Intelligent > /dev/null 2>&1 &
baseDir="$(dirname "$(readlink -f "$0")")"
[ -f "$baseDir/skt-utils.sh" ] && . "$baseDir/skt-utils.sh" || exit

# code before boot completed

until_boot 90
nohup_bin "$baseDir/Intelligent"

# code after boot completed and before unlocked

# run boot-completed.sh if it exists and root is not supported by KernelSU or APatch, then other code in this script will not run
run_boot_completed_if_magisk "$baseDir"

until_unlock

# code after unlocked


52 changes: 45 additions & 7 deletions magisk/skt-utils.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# useful code by Sakitin
# useful code by Sakitin(GitHub@GunRain 酷安@芙洛洛 bilibili@安音咲汀)

# GitHub link: https://github.com/GunRain/Magisk-Module-EG/blob/aaa/mod-root/skt-utils.sh

alias del=rm # for rm check

check_files() {
targetDir="$1"
hashListFile="$targetDir/hashList.dat"
test ! -f "$hashListFile" && { abort '! File "hashList.dat" does not exist!' || { echo '! File "hashList.dat" does not exist!'; exit 1; }; }
test ! -f "$hashListFile" && { abort '! File "hashList.dat" does not exist!' 2>/dev/null || { echo '! File "hashList.dat" does not exist!'; exit 1; }; }
hashList="$(cat "$hashListFile" | zcat)"
for file in $(find "$targetDir/" -type f -not -path '*META-INF*' -not -name hashList.dat); do
[ "$(echo -n "$hashList" | grep " ${file#$targetDir/}" | awk '{print $1}')" = "$(sha1sum "$file" | awk '{print $1}')" ] || { abort '! File validation failed!' || { echo '! File validation failed!'; exit 1; }; }
[ "$(echo -n "$hashList" | grep -E " ${file#$targetDir/}$" | awk '{print $1}')" = "$(sha1sum "$file" | awk '{print $1}')" ] || { abort "! Failed to verify file \"${file#$targetDir/}\"!" 2>/dev/null || { echo "! Failed to verify file \"${file#$targetDir/}\"!"; exit 1; }; }
done
}

get_target_bin() {
targetDir="$1"
fileName="$2"
targetArch="$3"
mv -f "$targetDir/$fileName.$ARCH" "$targetDir/$fileName" || { abort "! Arch \"$targetArch\" is not supported!" || { echo "! Arch \"$targetArch\" is not supported!"; exit 1; }; }
mv -f "$targetDir/$fileName.$targetArch" "$targetDir/$fileName" || { abort "! Arch \"$targetArch\" is not supported!" 2>/dev/null || { echo "! Arch \"$targetArch\" is not supported!"; exit 1; }; }
del -f $targetDir/$fileName.*
chmod a+x "$targetDir/$fileName"
}
Expand All @@ -26,9 +28,9 @@ until_key() {
eventInfo="$(getevent -qlc 1)"
eventType="$(echo -n "$eventInfo" | awk '{print $2}')"
[ "$eventType" = EV_KEY ] || continue
eventCode="$(echo -n "$eventInfo" | awk '{print $3}')"
eventValue="$(echo -n "$eventInfo" | awk '{print $4}')"
[ "$eventValue" = DOWN ] || continue
eventCode="$(echo -n "$eventInfo" | awk '{print $3}')"
case "$eventCode" in
KEY_VOLUMEUP) echo -n up; return;;
KEY_VOLUMEDOWN) echo -n down; return;;
Expand All @@ -55,6 +57,41 @@ until_key_power() {
done
}

get_work_dir() {
echo -n "$(dirname "$(readlink -f "$1")")"
}

until_boot() {
resetprop -w sys.boot_completed 0 >/dev/null 2>&1
[ "$1" = '' ] || sleep "$1"
}

until_unlock() {
until_boot
until [ -d /sdcard/Android ]; do sleep 1; done
[ "$1" = '' ] || sleep "$1"
}

run_bin() {
file="$1"
[ -f "$file" ] || return
chmod a+x "$file" 2>/dev/null
shift
eval "\"$file\" $@"
}

nohup_bin() {
file="$1"
[ -f "$file" ] || return
chmod a+x "$file" 2>/dev/null
shift
eval "nohup \"$file\" $@ >/dev/null 2>&1 &" &
}

run_boot_completed_if_magisk() {
[ "$KSU$APATCH" != true ] && [ -f "$1/boot-completed.sh" ] && { . "$1/boot-completed.sh"; exit; }
}

set_system_file() {
chcon -R u:object_r:system_file:s0 ${@}
}
Expand All @@ -66,13 +103,14 @@ set_dir_perm() {
}

skt_mod_install() {
[ "$MODPATH" = '' ] && { abort '! Value "MODPATH" does not exist!' || { echo '! Value "MODPATH" does not exist!'; exit 1; }; }
[ "$MODPATH" = '' ] && { abort '! Value "MODPATH" does not exist!' 2>/dev/null || { echo '! Value "MODPATH" does not exist!'; exit 1; }; }
check_files "$MODPATH"
del -f "$hashListFile"
[ "$1" = official ] && ui_print '- Official website: https://www.mod.latestfile.zip'
}

skt_mod_install_finish() {
[ "$MODPATH" = '' ] && { abort '! Value "MODPATH" does not exist!' || { echo '! Value "MODPATH" does not exist!'; exit 1; }; }
[ "$MODPATH" = '' ] && { abort '! Value "MODPATH" does not exist!' 2>/dev/null || { echo '! Value "MODPATH" does not exist!'; exit 1; }; }
[ -d "$MODPATH/system" ] && {
set_system_file "$MODPATH/system"
set_dir_perm "$MODPATH/system"
Expand Down

0 comments on commit ac701d2

Please sign in to comment.