2022-03-16 15:00:11 +08:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
# Copyright (C) Juewuy
|
|
|
|
|
|
2024-01-03 12:21:38 +08:00
|
|
|
|
CRASHDIR="$(uci get firewall.ShellCrash.path | sed 's/\/misnap_init.sh//')"
|
2022-03-16 15:00:11 +08:00
|
|
|
|
profile=/etc/profile
|
|
|
|
|
|
2023-04-04 10:23:19 +08:00
|
|
|
|
autoSSH(){
|
|
|
|
|
#自动开启SSH
|
|
|
|
|
[ "`uci -c /usr/share/xiaoqiang get xiaoqiang_version.version.CHANNEL`" != 'stable' ] && {
|
2023-06-11 20:52:17 +08:00
|
|
|
|
uci -c /usr/share/xiaoqiang set xiaoqiang_version.version.CHANNEL='stable'
|
|
|
|
|
uci -c /usr/share/xiaoqiang commit xiaoqiang_version.version
|
2023-04-04 10:23:19 +08:00
|
|
|
|
}
|
|
|
|
|
[ -z "$(pidof dropbear)" -o -z "$(netstat -ntul | grep :22)" ] && {
|
2023-06-11 20:52:17 +08:00
|
|
|
|
sed -i 's/channel=.*/channel="debug"/g' /etc/init.d/dropbear
|
|
|
|
|
/etc/init.d/dropbear restart
|
2024-01-02 17:09:11 +08:00
|
|
|
|
mi_autoSSH_pwd=$(grep 'mi_autoSSH_pwd=' $CRASHDIR/configs/ShellCrash.cfg | awk -F "=" '{print $2}')
|
2023-06-11 20:52:17 +08:00
|
|
|
|
[ -n "$mi_autoSSH_pwd" ] && echo -e "$mi_autoSSH_pwd\n$mi_autoSSH_pwd" | passwd root
|
2023-04-04 10:23:19 +08:00
|
|
|
|
}
|
2023-06-11 20:52:17 +08:00
|
|
|
|
#配置nvram
|
|
|
|
|
[ "$(nvram get ssh_en)" = 0 ] && nvram set ssh_en=1
|
|
|
|
|
[ "$(nvram get telnet_en)" = 0 ] && nvram set telnet_en=1
|
|
|
|
|
nvram commit &> /dev/null
|
2023-04-04 10:23:19 +08:00
|
|
|
|
#备份还原SSH秘钥
|
2024-01-02 17:09:11 +08:00
|
|
|
|
[ -f $CRASHDIR/configs/dropbear_rsa_host_key ] && ln -sf $CRASHDIR/configs/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key
|
|
|
|
|
[ -f $CRASHDIR/configs/authorized_keys ] && ln -sf $CRASHDIR/configs/authorized_keys /etc/dropbear/authorized_keys
|
2023-04-16 21:31:52 +08:00
|
|
|
|
#自动清理升级备份文件夹
|
|
|
|
|
rm -rf /data/etc_bak
|
2023-04-04 10:23:19 +08:00
|
|
|
|
}
|
2023-03-01 14:06:53 +08:00
|
|
|
|
tunfix(){
|
2023-04-04 20:45:35 +08:00
|
|
|
|
ko_dir=$(modinfo ip_tables | grep -Eo '/lib/modules.*/ip_tables.ko' | sed 's|/ip_tables.ko||' )
|
2023-03-01 14:06:53 +08:00
|
|
|
|
#在/tmp创建并挂载overlay
|
2023-03-17 23:32:30 +08:00
|
|
|
|
mkdir -p /tmp/overlay
|
|
|
|
|
mkdir -p /tmp/overlay/upper
|
|
|
|
|
mkdir -p /tmp/overlay/work
|
2023-04-04 12:14:25 +08:00
|
|
|
|
mount -o noatime,lowerdir=${ko_dir},upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work -t overlay "overlay_mods_only" ${ko_dir}
|
2023-03-01 14:06:53 +08:00
|
|
|
|
#将tun.ko链接到lib
|
2024-03-17 15:13:54 +08:00
|
|
|
|
ln -sf $CRASHDIR/tools/tun.ko ${ko_dir}/tun.ko || $CRASHDIR/start.sh loggger "小米Tun模块修复失败!"
|
2023-03-01 14:06:53 +08:00
|
|
|
|
}
|
2023-08-09 21:41:27 +08:00
|
|
|
|
tproxyfix(){
|
|
|
|
|
sed -i 's/sysctl -w net.bridge.bridge-nf-call-ip/#sysctl -w net.bridge.bridge-nf-call-ip/g' /etc/init.d/qca-nss-ecm
|
|
|
|
|
sysctl -w net.bridge.bridge-nf-call-iptables=0
|
|
|
|
|
sysctl -w net.bridge.bridge-nf-call-ip6tables=0
|
|
|
|
|
}
|
2023-03-01 14:06:53 +08:00
|
|
|
|
init(){
|
2023-04-28 19:49:11 +08:00
|
|
|
|
#等待启动完成
|
2024-04-05 18:22:33 +08:00
|
|
|
|
while ! ip a| grep -q lan; do
|
2024-03-17 15:13:54 +08:00
|
|
|
|
sleep 10
|
2023-04-28 19:49:11 +08:00
|
|
|
|
done
|
2024-04-05 18:22:33 +08:00
|
|
|
|
sleep 20
|
2023-01-16 17:35:06 +08:00
|
|
|
|
#初始化环境变量
|
2024-01-03 18:15:07 +08:00
|
|
|
|
sed -i "/alias crash/d" $profile
|
2024-01-15 18:46:18 +08:00
|
|
|
|
sed -i "/alias clash/d" $profile
|
2024-01-02 17:09:11 +08:00
|
|
|
|
sed -i "/export CRASHDIR/d" $profile
|
2024-01-10 22:02:15 +08:00
|
|
|
|
echo "alias crash=\"sh $CRASHDIR/menu.sh\"" >>$profile
|
2024-01-15 18:46:18 +08:00
|
|
|
|
echo "alias clash=\"sh $CRASHDIR/menu.sh\"" >>$profile
|
2024-01-02 17:09:11 +08:00
|
|
|
|
echo "export CRASHDIR=\"$CRASHDIR\"" >>$profile
|
2023-04-04 10:23:19 +08:00
|
|
|
|
#软固化功能
|
2023-04-28 19:49:11 +08:00
|
|
|
|
autoSSH
|
2023-03-01 14:06:53 +08:00
|
|
|
|
#设置init.d服务
|
2024-01-10 22:02:15 +08:00
|
|
|
|
cp -f $CRASHDIR/shellcrash.procd /etc/init.d/shellcrash
|
2024-01-06 22:35:41 +08:00
|
|
|
|
chmod 755 /etc/init.d/shellcrash
|
2023-03-01 14:06:53 +08:00
|
|
|
|
#启动服务
|
2024-01-02 17:09:11 +08:00
|
|
|
|
if [ ! -f $CRASHDIR/.dis_startup ]; then
|
2023-03-01 14:06:53 +08:00
|
|
|
|
#AX6S/AX6000修复tun功能
|
2024-06-06 14:40:22 +08:00
|
|
|
|
[ -s $CRASHDIR/tools/tun.ko ] && tunfix
|
2023-08-01 22:33:44 +08:00
|
|
|
|
#小米7000/小米万兆修复tproxy
|
2024-01-03 18:15:07 +08:00
|
|
|
|
[ -f /etc/init.d/qca-nss-ecm ] && [ -n "$(grep 'redir_mod=Tproxy' $CRASHDIR/configs/ShellCrash.cfg )" ] && tproxyfix
|
2024-06-06 14:40:22 +08:00
|
|
|
|
#自动覆盖根证书文件
|
|
|
|
|
[ -s $CRASHDIR/tools/ca-certificates.crt ] && cp -f $CRASHDIR/tools/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
2023-04-16 21:31:52 +08:00
|
|
|
|
#启动服务
|
2024-03-17 15:13:54 +08:00
|
|
|
|
$CRASHDIR/start.sh start
|
2024-01-06 22:35:41 +08:00
|
|
|
|
/etc/init.d/shellcrash enable
|
2023-01-16 17:35:06 +08:00
|
|
|
|
fi
|
2023-03-01 14:06:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
|
tunfix) tunfix ;;
|
2023-08-09 21:41:27 +08:00
|
|
|
|
tproxyfix) tproxyfix ;;
|
2023-03-01 14:06:53 +08:00
|
|
|
|
init) init ;;
|
|
|
|
|
*)
|
2024-01-06 22:35:41 +08:00
|
|
|
|
if [ -z $(pidof CrashCore) ];then
|
2023-04-28 19:49:11 +08:00
|
|
|
|
init &
|
2023-03-01 14:06:53 +08:00
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|