Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
E7KMbb committed Jun 28, 2021
1 parent 772a651 commit 3aa134f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 33 deletions.
28 changes: 14 additions & 14 deletions customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ chooseport() {

work_dir=/sdcard/Android/ADhosts
syshosts=/system/etc/hosts
export MAGISKTMP=`magisk --path 2>/dev/null`
[[ -z "$MAGISKTMP" ]] && export MAGISKTMP=`mount | grep "/.magisk/mirror/system" | awk -F ' ' '{print $1}' | awk -F '/.magisk/block/system' '{print $1}' | head -n 1`

if [ ! -d $work_dir ]; then
mkdir -p $work_dir
Expand Down Expand Up @@ -223,35 +221,37 @@ if chooseport; then
else
ui_print "已选择system模式"
sed -i "s/<mod>/system/g" $MODPATH/script/select.ini
rm -rf /data/adb/service.d/disable_ad_hosts.sh
if [ ! -e /data/adb/service.d/disable_ad_hosts.sh ]; then
cp $MODPATH/disable_ad_hosts.sh /data/adb/service.d/disable_ad_hosts.sh
fi
if [ ! -e $work_dir/syshosts.bak ]; then
ui_print "备份系统hosts文件至$work_dir/syshosts.bak"
cp $syshosts $work_dir/syshosts.bak
fi
for mount_path in /system / $MAGISKTMP/.magisk/mirror/system $MAGISKTMP/.magisk/mirror/system_root; do
for mount_path in /system /; do
mount -o remount,rw ${mount_path} &> /dev/null
if [ -w ${mount_path} ]; then
if [ ${mount_path} = $MAGISKTMP/.magisk/mirror/system_root ]; then
if [ -w "${mount_path}/system" ]; then
mount_path=${mount_path}/system
break;
else
abort "挂载失败请重新安装模块并选择systemless模式"
fi
break;
else
if [ ${mount_path} = / ]; then
abort "你的设备未解锁system导致挂载失败,请重新安装模块并选择systemless模式"
fi
break;
fi
done
mv -f $MODPATH/system/etc/hosts $syshosts
chmod 644 $syshosts
chown 0:0 $syshosts
chcon u:object_r:system_file:s0 $syshosts
mount -o remount,ro ${mount_path} &> /dev/null
rm -rf $MODPATH/system
fi
if [ -e $NVBASE/modules/hosts ]; then
ui_print "检测到你安装了systemless hosts模块"
touch $NVBASE/modules/hosts/disable
ui_print "已禁用"
ui_print "检测到你开启了Systemless hosts模块"
if [ ! -d $NVBASE/modules/hosts/disable ]; then
touch $NVBASE/modules/hosts/disable
ui_print "已禁用"
fi
fi

ui_print "是否启用开机自动更新"
Expand Down
14 changes: 14 additions & 0 deletions disable_ad_hosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ syshosts=/system/etc/hosts

if [ $install_mod = "system" ]; then
if [ -e /data/adb/modules/AD-Hosts/disable ]; then
for mount_path in /system /; do
mount -o remount,rw ${mount_path} &> /dev/null
if [ -w ${mount_path} ]; then
break;
else
if [ ${mount_path} = / ]; then
exit 0
fi
fi
done
cp -f $work_dir/syshosts.bak $syshosts
chmod 644 $syshosts
chown 0:0 $syshosts
chcon u:object_r:system_file:s0 $syshosts
mount -o remount,ro ${mount_path} &> /dev/null
fi
fi
21 changes: 7 additions & 14 deletions script/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
work_dir=/sdcard/Android/ADhosts
curdate="`date +%Y-%m-%d,%H:%M:%S`"
script_dir=${0%/*}
export MAGISKTMP=`magisk --path 2>/dev/null`
[[ -z "$MAGISKTMP" ]] && export MAGISKTMP=`mount | grep "/.magisk/mirror/system" | awk -F ' ' '{print $1}' | awk -F '/.magisk/block/system' '{print $1}' | head -n 1`

. $script_dir/select.ini

Expand Down Expand Up @@ -136,21 +134,16 @@ if [ $Now == $New ]; then
echo "没有更新: $curdate"
else
if [ $install_mod = "system" ]; then
for mount_path in /system / $MAGISKTMP/.magisk/mirror/system $MAGISKTMP/.magisk/mirror/system_root; do
for mount_path in /system /; do
mount -o remount,rw ${mount_path} &> /dev/null
if [ -w ${mount_path} ]; then
if [ ${mount_path} = $MAGISKTMP/.magisk/mirror/system_root ]; then
if [ -w "${mount_path}/system" ]; then
mount_path=${mount_path}/system
break;
else
echo "挂载失败请重新安装模块并选择systemless模式" >> $work_dir/update.log
sed -i '1d' $work_dir/update.log
echo "挂载失败请重新安装模块并选择systemless模式"
exit 0
fi
fi
break;
else
if [ ${mount_path} = / ]; then
echo "你的设备未解锁system导致挂载失败,请重新安装模块并选择systemless模式" >> $work_dir/update.log
sed -i '1d' $work_dir/update.log
echo "你的设备未解锁system导致挂载失败,请重新安装模块并选择systemless模式""
fi
fi
done
fi
Expand Down
4 changes: 3 additions & 1 deletion thanks.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ coolapk@坑神硕哥

coolapk@我和你断了联系

coolapk@香飘飘エウ
coolapk@香飘飘エウ

coolapk@炜锅
7 changes: 3 additions & 4 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ script_dir=${0%/*}/script

. ${script_dir}/select.ini

for mount_path in /system / $MAGISKTMP/.magisk/mirror/system $MAGISKTMP/.magisk/mirror/system_root $MAGISKTMP/.magisk/block/system_root; do
for mount_path in /system /; do
mount -o remount,rw ${mount_path} &> /dev/null
if [ -w ${mount_path} ]; then
break;
fi
if [ ${mount_path} = $MAGISKTMP/.magisk/block/system_root ]; then
if [ ! -w ${mount_path} ]; then
else
if [ ${mount_path} = / ]; then
exit 0
fi
fi
Expand Down

0 comments on commit 3aa134f

Please sign in to comment.