Skip to content

Commit

Permalink
去除system模式
Browse files Browse the repository at this point in the history
  • Loading branch information
E7KMbb committed Jan 8, 2022
1 parent a59eefb commit e5bfcc5
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 148 deletions.
8 changes: 4 additions & 4 deletions Han.GJZS.prop
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
id='AD-Hosts'
name='AD Hosts'
version='v6.3.1'
versionCode='6310'
version='v6.3.2'
versionCode='6320'
author='依然的爱'
description='屏蔽大部分广告,请记住hosts不是万能的具有局限性,不能全部屏蔽。hosts规则均来自于网络搜索,github,人工抓取及酷友提供,使用时请关闭其它带有hosts文件的模块,例如:systemless hosts模块。'
time='2021年11月28号'
size=1008914
md5=4aed8f54c9a363de5ae5d4ecd9e60ed5
size=1007462
md5=dff39138ccffc95aab71b575b7e9c66f
zipurl="https://aisauce.coding.net/p/ad-hosts/d/ad-hosts/git/raw/master/release/AD_hosts_latest.zip"
69 changes: 33 additions & 36 deletions customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ if (timeout 1 getevent -lc 1 2>&1 | grep EV_ABS > $TMPDIR/touch); then
fi

chmod -R 0755 $MODPATH/tools
chooseportold() {
# Keycheck binary by someone755 @Github, idea for code below by Zappo @xda-developers
# Calling it first time detects previous input. Calling it second time will do what we want
while true; do
$MODPATH/tools/$ARCH32/keycheck
$MODPATH/tools/$ARCH32/keycheck
local SEL=$?
if [ "$1" == "UP" ]; then
UP=$SEL
break
elif [ "$1" == "DOWN" ]; then
DOWN=$SEL
break
elif [ $SEL -eq $UP ]; then
return 0
elif [ $SEL -eq $DOWN ]; then
return 1
fi
done
}

chooseport_legacy() {
# Keycheck binary by someone755 @Github, idea for code below by Zappo @xda-developers
# Calling it first time detects previous input. Calling it second time will do what we want
Expand All @@ -108,7 +129,14 @@ chooseport_legacy() {
elif [ $sel -eq 41 ]; then
return 1
elif $error; then
abort "未检测到音量键!"
ui_print "未检测到音量键!尝试使用旧的keycheck方案"
export chooseport=chooseportold
ui_print " "
ui_print "- 音量键录入 -"
ui_print " 请按音量+键:"
chooseport "UP"
ui_print " 请按音量–键"
chooseport "DOWN"
else
error=true
echo "- 未检测到音量键。再试一次。"
Expand Down Expand Up @@ -145,8 +173,8 @@ chooseport() {
done
}


work_dir=/sdcard/Android/ADhosts
syshosts=/system/etc/hosts

if [ ! -d $work_dir ]; then
mkdir -p $work_dir
Expand Down Expand Up @@ -205,40 +233,6 @@ else
sed -i "s/<link>/https:\/\/aisauce.coding.net\/p\/ad-hosts\/d\/ad-hosts\/git\/raw\/master\/system\/etc\/hosts/g" $MODPATH/script/select.ini
fi

ui_print "选择hosts安装模式"
ui_print " 音量+ = systemless"
ui_print " 音量– = system"
if chooseport; then
ui_print "已选择systemless模式"
sed -i "s/<mod>/systemless/g" $MODPATH/script/select.ini
else
ui_print "已选择system模式(仅支持解锁了system的设备)"
sed -i "s/<mod>/system/g" $MODPATH/script/select.ini
rm -rf $NVBASE/service.d/disable_ad_hosts.sh
if [ ! -e $NVBASE/service.d/disable_ad_hosts.sh ]; then
cp $MODPATH/script/disable_ad_hosts.sh $NVBASE/service.d/disable_ad_hosts.sh
fi
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
abort "你的设备未解锁system导致挂载失败,请重新安装模块并选择systemless模式"
fi
fi
done
if [ ! -e $work_dir/syshosts.bak ]; then
ui_print "备份系统hosts文件至$work_dir/syshosts.bak"
cp $syshosts $work_dir/syshosts.bak
fi
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 [ -d $NVBASE/modules/hosts ]; then
if [ ! -e $NVBASE/modules/hosts/disable ]; then
ui_print "检测到你开启了Systemless hosts模块"
Expand Down Expand Up @@ -320,6 +314,9 @@ if [ -d /data/data/com.coolapk.market ]; then
fi

# 删除多余文件
if [ -e $SERVICED/disable_ad_hosts.sh ]; then
rm -rf $SERVICED/disable_ad_hosts.sh
fi
rm -rf \
$MODPATH/system/placeholder $MODPATH/customize.sh \
$MODPATH/*.md $MODPATH/.git* $MODPATH/LICENSE $MODPATH/tools 4>/dev/null
Expand Down
4 changes: 2 additions & 2 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=AD-Hosts
name=AD Hosts
version=v6.3.0
versionCode=6300
version=v6.3.2
versionCode=6320
author=依然的爱
description=屏蔽大部分广告,请记住hosts不是万能的具有局限性,不能全部屏蔽。hosts规则均来自于网络搜索,github,人工抓取及酷友提供,使用时请关闭其它带有hosts文件的模块,例如:systemless hosts模块。
Binary file modified release/AD_hosts_latest.zip
Binary file not shown.
26 changes: 0 additions & 26 deletions script/disable_ad_hosts.sh

This file was deleted.

43 changes: 2 additions & 41 deletions script/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
work_dir=/sdcard/Android/ADhosts
curdate="`date +%Y-%m-%d,%H:%M:%S`"
script_dir=${0%/*}
modules_dir=$(dirname ${script_dir})
hosts_dir=${modules_dir}/system/etc

. $script_dir/select.ini

Expand Down Expand Up @@ -49,30 +51,6 @@ if [ ! -e $work_dir/Start.sh ];then
echo "sh $script_dir/functions.sh" >> $work_dir/Start.sh
fi

# 判断安装模式
if [ $install_mod = "systemless" ]; then
hosts_dir=/data/adb/modules/AD-Hosts/system/etc
if [ ! -d $hosts_dir ];then
mkdir -p $hosts_dir
fi
if [ -e /data/adb/service.d/disable_ad_hosts.sh ]; then
rm -rf /data/adb/service.d/disable_ad_hosts.sh
fi
elif [ $install_mod = "system" ]; then
hosts_dir=/system/etc
if [ -d /data/adb/modules/AD-Hosts/system ];then
rm -rf /data/adb/modules/AD-Hosts/system
fi
if [ ! -e /data/adb/service.d/disable_ad_hosts.sh ]; then
cp $script_dir/disable_ad_hosts.sh /data/adb/service.d/disable_ad_hosts.sh
fi
else
echo "Error: 没有变量请检查$script_dir/select.ini是否存在" >> $work_dir/update.log
sed -i '1d' $work_dir/update.log
echo "Error: 没有变量请检查$script_dir/select.ini是否存在"
exit 0
fi

# 下载hosts文件
if $(curl -V > /dev/null 2>&1) ; then
for i in $(seq 1 20); do
Expand Down Expand Up @@ -126,27 +104,10 @@ if [ $Now == $New ]; then
sed -i '1d' $work_dir/update.log
echo "没有更新: $curdate"
else
if [ $install_mod = "system" ]; 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
echo "你的设备未解锁system导致挂载失败,请重新安装模块并选择systemless模式" >> $work_dir/update.log
sed -i '1d' $work_dir/update.log
echo "你的设备未解锁system导致挂载失败,请重新安装模块并选择systemless模式"
fi
fi
done
fi
mv -f $work_dir/hosts $hosts_dir/hosts
chmod 644 $hosts_dir/hosts
chown 0:0 $hosts_dir/hosts
chcon u:object_r:system_file:s0 $hosts_dir/hosts
if [ $install_mod = "system" ]; then
mount -o remount,ro ${mount_path} &> /dev/null
fi
echo -n "上次更新时间: $curdate" >> $work_dir/update.log
echo " hosts文件目录:$hosts_dir/hosts" >> $work_dir/update.log
sed -i '1d' $work_dir/update.log
Expand Down
2 changes: 0 additions & 2 deletions script/select.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# hosts源链接
hosts_link="<link>"
# 安装模式 systemless/system
install_mod="<mod>"
# 开机自启动更新 true/false
update_boot_start="<update_boot>"
# 开机启动自动更新服务(是否启动根据Cron.ini参数判断) true/false
Expand Down
37 changes: 0 additions & 37 deletions uninstall.sh

This file was deleted.

0 comments on commit e5bfcc5

Please sign in to comment.