~优化了推送机制,现在统一使用POST接口进行推送

~新增加在支持的设备上创建/usr/bin/crash启动文件以修复部分设备的环境变量写入失败问题
~将singbox的内置tun网卡网段改为172.19.0.1/30,以修复tun模式下会将域名重定向到127.0.0.1的bug
~优化了延迟启动,现在延迟会在内核启动前进行而不是设置防火墙之前
~优化了小米设备的自启机制,现在仅当检测到wan口ip时才会进行启动,以解决部分设备无法自启的问题
~修复初始化脚本的若干报错
~脚本在支持ash的环境会强制调用ash解析而不是sh
~修复新装脚本时,无法调用iptables的bug
~
This commit is contained in:
juewuy
2024-04-04 20:29:46 +08:00
parent c20e8f3d15
commit ef4d6f51eb
3 changed files with 48 additions and 56 deletions

View File

@@ -160,10 +160,10 @@ else
[ -w /etc/systemd/system ] && sysdir=/etc/systemd/system
if [ -n "$sysdir" -a "$USER" = "root" -a "$(cat /proc/1/comm)" = "systemd" ];then
#创建shellcrash用户
type userdel && userdel shellcrash 2>/dev/null
userdel shellcrash 2>/dev/null
sed -i '/0:7890/d' /etc/passwd
sed -i '/x:7890/d' /etc/group
if type useradd >/dev/null 2>&1; then
if useradd -h >/dev/null 2>&1; then
useradd shellcrash -u 7890 2>/dev/null
sed -Ei s/7890:7890/0:7890/g /etc/passwd
else
@@ -181,8 +181,9 @@ else
fi
fi
#修饰文件及版本号
command -v bash >/dev/null 2>&1 && shtype=bash || shtype=sh
for file in start.sh task.sh ;do
command -v bash >/dev/null 2>&1 && shtype=bash
[ -x /bin/ash ] && shtype=ash
for file in start.sh task.sh menu.sh;do
sed -i "s|/bin/sh|/bin/$shtype|" ${CRASHDIR}/${file}
chmod 755 ${CRASHDIR}/${file}
done
@@ -203,7 +204,7 @@ fi
setconfig COMMAND "$COMMAND" ${CRASHDIR}/configs/command.env
#设置防火墙执行模式
[ -z "$(grep firewall_mod $CRASHDIR/configs/ShellClash.cfg 2>/dev/null)" ] && {
ckcmd iptables && firewall_mod=iptables
iptables -j REDIRECT -h >/dev/null 2>&1 && firewall_mod=iptables
nft add table inet shellcrash 2>/dev/null && firewall_mod=nftables
setconfig firewall_mod $firewall_mod
}
@@ -233,6 +234,14 @@ if [ -n "$profile" ];then
echo "export CRASHDIR=\"$CRASHDIR\"" >> ~/.zshrc
source ~/.zshrc >/dev/null 2>&1
}
#在允许的情况下创建/usr/bin/crash文件
[ -w /usr/bin ] && {
cat > /usr/bin/crash <<EOF
#/bin/$shtype
$CRASHDIR/menu.sh \$1 \$2 \$3 \$4 \$5
EOF
chmod +x /usr/bin/crash
}
else
echo -e "\033[33m无法写入环境变量请检查安装权限\033[0m"
exit 1