71 Commits

Author SHA1 Message Date
juewuy
1afb261d0e ~优化定时任务 2026-02-08 20:13:55 +08:00
juewuy
32d73c18c4 ~1.9.4rc6 pkg 2026-02-08 19:38:01 +08:00
juewuy
cb9d5a783b ~修复保守模式部分情况下反复重启的bug 2026-02-08 19:31:23 +08:00
juewuy
c4bdd18195 ~修复ddns工具的一些bug 2026-02-08 19:14:45 +08:00
juewuy
7f0b0fa870 ~bug fix 2026-02-08 18:36:50 +08:00
juewuy
d5d9fab8e0 ~bug fix 2026-02-08 18:28:05 +08:00
juewuy
053f05d394 ~修复docker相关bug 2026-02-08 18:25:47 +08:00
juewuy
fc1c3c4415 ~bug fix 2026-02-08 18:05:01 +08:00
juewuy
6a1d4086f3 ~1.9.4r5 pkg 2026-02-04 19:05:22 +08:00
juewuy
b59da3be8a ~fix 2026-02-04 18:53:46 +08:00
juewuy
76efd54d03 ~bug fix 2026-02-04 18:52:11 +08:00
juewuy
ace8b08407 ~优化容器部署说明,修复持久化问题 2026-02-04 18:46:25 +08:00
juewuy
f70e642fea ~修复部分情况下自启状态显示不正确的bug 2026-02-04 18:27:29 +08:00
juewuy
614bc696bb ~继续优化定时任务功能 2026-02-04 18:20:43 +08:00
juewuy
cd7d4232b6 ~修复因.start_error失败标记导致的部分bug 2026-02-04 17:59:20 +08:00
juewuy
fd4ca02ff3 ~1.9.4r4.1 pkg 2026-02-02 21:50:43 +08:00
juewuy
7d2e1c54c4 Merge branch 'stable' of https://github.com/juewuy/ShellCrash into master 2026-02-02 20:25:42 +08:00
juewuy
f3cd3ff18a ~1.9.4r4 pkg 2026-02-02 20:25:14 +08:00
juewuy
1196557d4c ~修复部分任务命令执行失败的bug 2026-02-02 20:21:53 +08:00
juewuy
1af6cf36d2 ~修复部分情况下配置文件拉取失败的bug 2026-02-02 20:15:53 +08:00
juewuy
1f59a971cf ~修复部分小米设备Tproxy自启失效的bug 2026-02-02 20:13:04 +08:00
juewuy
9cad2c21e8 ~优化定时任务日志记录 2026-02-02 20:04:53 +08:00
juewuy
0b1d297622 ~修复华硕padavan小米等设备因意外循环重启的bug 2026-02-02 20:02:02 +08:00
juewuy
0ca7bb8eb2 ~现在跳过证书验证开关对内置下载工具也有效 2026-02-02 19:30:43 +08:00
juewuy
1bd16b5ca6 ~重写 set_cron.sh 尝试修复因为定时任务导致系统crontab内容丢失的问题 2026-02-02 19:23:03 +08:00
juewuy
88ae50bc43 Merge pull request #1192 from juewuy/master
~1.9.4r3 pkg
2026-01-31 20:25:20 +08:00
juewuy
3682a99a79 ~bug fix 2026-01-31 18:07:26 +08:00
juewuy
1129eb79b5 ~1.9.4r3 pkg 2026-01-31 17:59:04 +08:00
juewuy
dfae7195b3 ~修复TG-BOT无法使用自定义命令呼出的bug 2026-01-31 17:42:07 +08:00
juewuy
da23b70ca4 ~singbox内核改为默认启用sniff 2026-01-31 17:34:50 +08:00
juewuy
70bd8ed591 ~修复局域网过滤显示异常 2026-01-31 17:30:18 +08:00
juewuy
b17286b73b ~优化定时任务实现,尝试修复意外清空定时任务内容的bug 2026-01-31 17:26:48 +08:00
juewuy
d63b75b790 ~修复TG-BOT无法正确设置版本号和路由状态的bug 2026-01-31 17:14:57 +08:00
juewuy
6170a0461d ~1.9.4r2 pkg
~修复小闪存模式启动失败的bug
2026-01-27 20:14:50 +08:00
juewuy
48705a0dd9 ~修复小闪存模式内核位置错乱的bug 2026-01-27 19:54:10 +08:00
juewuy
4a2a982c8d ~修复部分小米设备自启失败的bug 2026-01-27 19:33:31 +08:00
juewuy
6e41971725 ~1.9.4r1.3 pkg 2026-01-27 17:34:33 +08:00
juewuy
bbe711b1ce ~修复停止服务时未同步停止tg_bot进程的bug 2026-01-27 17:33:52 +08:00
juewuy
ee523035a6 ~1.9.4r1.2 pkg 2026-01-27 15:25:07 +08:00
juewuy
847010399d ~修复小米自启动失败的bug 2026-01-27 15:23:25 +08:00
juewuy
b9a29a69a7 ~1.9.4r1.1 pkg 2026-01-27 09:39:12 +08:00
juewuy
a0901b8083 ~优化 2026-01-27 09:38:41 +08:00
juewuy
399928f6ea ~修复小米软固化及自启动失败的bug 2026-01-27 09:30:50 +08:00
juewuy
13b291ccc7 ~修复setconfig()函数变更带来的bug 2026-01-27 09:19:19 +08:00
juewuy
2b3720b8f3 ~1.9.4r1 pkg 2026-01-26 19:44:37 +08:00
juewuy
6d904eb297 ~修复Wireguard网段会被公网防火墙拦截的bug 2026-01-26 19:18:39 +08:00
juewuy
d2d25a60eb ~bug fix 2026-01-26 19:13:53 +08:00
juewuy
5e58823cee ~优化实现 2026-01-26 19:11:39 +08:00
juewuy
d00f558ae2 ~1.9.5b7 pkg 2026-01-25 21:31:09 +08:00
juewuy
acff8898a2 ~修复tailscale网段会被公网防火墙拦截的bug 2026-01-25 21:26:50 +08:00
juewuy
019ab1bd07 ~bug fix 2026-01-25 21:23:06 +08:00
juewuy
3ae53623d7 ~bug fix 2026-01-25 20:58:47 +08:00
juewuy
d98501fe66 ~增加日志容量,取消60分钟以内定时任务的日志记录 2026-01-25 20:43:34 +08:00
juewuy
828d70e4f8 ~bug fix 2026-01-25 20:35:46 +08:00
juewuy
0014c5c32a ~bug fix
# Conflicts:
#	scripts/menu.sh
2026-01-25 20:32:51 +08:00
juewuy
961aeb5bb1 ~增加版本回退时需重新进入新手引导的机制
# Conflicts:
#	scripts/menus/9_upgrade.sh
2026-01-25 20:31:52 +08:00
juewuy
daee138365 ~修复部分小米路由自启时出现多个进程的bug 2026-01-25 20:29:02 +08:00
juewuy
9029a2ce82 ~优化bot_tg机器人绑定提示
# Conflicts:
#	scripts/menus/7_gateway.sh
#	scripts/menus/bot_tg_bind.sh
2026-01-25 20:28:33 +08:00
juewuy
213eccc436 ~bug fix 2026-01-21 19:16:44 +08:00
juewuy
acf34714cc ~1.9.4b6 pkg 2026-01-21 19:06:12 +08:00
juewuy
56cb4a327f ~优化测试相关命令
~优化版本回退功能,现在支持回退到近期tags
~修复保守模式停止服务时未正确注销防火墙的bug
~修复小米设备因安装在u盘等导致自启命令不正确的bug
2026-01-21 19:05:40 +08:00
juewuy
f7f39af5e3 ~1.9.4b5 pkg 2026-01-20 22:22:52 +08:00
juewuy
f9be142dfa ~增加ChatID校验机制
~bug fix
2026-01-20 22:20:20 +08:00
juewuy
de7b57330e ~修复小闪存模式更新内核失败的bug
~修复部分情况下本机代理导致dns失效的bug
~增加Mihomo内核direct-nameserver默认配置
2026-01-20 21:51:57 +08:00
juewuy
4f9ffbb7d7 ~bug fix 2026-01-18 20:27:45 +08:00
juewuy
100dee42be ~bug fix 2026-01-18 20:26:30 +08:00
juewuy
98a610eb58 ~1.9.4beta4打包 2026-01-18 18:49:32 +08:00
juewuy
02129b3109 ~适配更多模版 2026-01-18 18:46:03 +08:00
juewuy
023e0caeb9 ~bug fix 2026-01-18 18:30:40 +08:00
juewuy
c816d97893 ~bug fix 2026-01-16 20:15:26 +08:00
juewuy
48c60b8ea0 ~1.9.4beta3.2打包 2026-01-16 18:39:48 +08:00
41 changed files with 277 additions and 174 deletions

View File

@@ -57,8 +57,7 @@ RUN apk add --no-cache \
ca-certificates \
tzdata \
nftables \
iproute2 \
dcron
iproute2
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo "${TZ}" > /etc/timezone

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
meta_v=v1.19.17
singboxr_v=1.13.0-alpha.27
versionsh=1.9.4beta3.1
versionsh=1.9.4rc6
GeoIP_v=20251205

View File

@@ -57,6 +57,7 @@ docker run -d \
--cap-add NET_ADMIN \
--cap-add NET_RAW \
--cap-add SYS_ADMIN \
--sysctl net.ipv4.ip_forward=1 \
--device /dev/net/tun:/dev/net/tun \
--restart unless-stopped \
juewuy/shellcrash:latest
@@ -87,14 +88,10 @@ mkdir -p /root/ShellCrash
```shell
docker run -d \
………………
-v /root/ShellCrash:/etc/ShellCrash \
-v shellcrash_configs:/etc/ShellCrash/configs \
………………
```
------
------
## Compose DeploymentCompose部署
@@ -102,8 +99,8 @@ docker run -d \
### 1. 创建宿主机目录并进入目录
```shell
mkdir -p /root/ShellCrash
cd /root/ShellCrash
mkdir -p /tmp/ShellCrash
cd /tmp/ShellCrash
```
### 2. 下载Compose模版
@@ -126,8 +123,29 @@ docker compose up -d
------
### Notes
## Delete移除容器镜像或删除卷
### Docker删除容器
```shell
docker rm -f shellcrash
```
### Docker删除卷
```shell
docker volume rm shellcrash_configs
```
### Compose删除容器&卷
```shell
docker-compose down -v
```
## Notes
- 内置公网防火墙功能无法管理宿主机网络请自行做好宿主机7890/9999端口的网络防护
- 旁路由模式需要宿主机支持 `TUN`
- macvlan 网络下宿主机默认无法直接访问容器 IP
- 透明代理场景可能需要额外的网络规划

View File

@@ -14,11 +14,15 @@ services:
devices:
- "/dev/net/tun:/dev/net/tun"
sysctls:
net.ipv4.ip_forward: 1
- net.ipv4.ip_forward: 1
# - net.ipv6.conf.all.forwarding=1
volumes:
- /etc/ShellCrash:/root/ShellCrash
- shellcrash_configs:/etc/ShellCrash/configs:rw
restart: unless-stopped
volumes:
shellcrash_configs:
networks:
macvlan_lan:
name: macvlan_lan

View File

@@ -130,7 +130,7 @@ if [ "$systype" = "mi_snapshot" -o "$systype" = "ng_snapshot" ]; then
chmod 755 "$CRASHDIR"/starts/snapshot_init.sh
if [ "$systype" = "mi_snapshot" ];then
path="/data/shellcrash_init.sh"
setconfig CRASHDIR "$CRASHDIR" "$CRASHDIR"/starts/snapshot_init.sh
sed -i "s#^CRASHDIR=.*#CRASHDIR=$CRASHDIR#" "$CRASHDIR"/starts/snapshot_init.sh
mv -f "$CRASHDIR"/starts/snapshot_init.sh "$path"
[ ! -f /data/auto_start.sh ] && echo '#用于自定义需要开机启动的功能或者命令,会在开机后自动运行' > /data/auto_start.sh
else

View File

@@ -3,6 +3,7 @@ check_autostart(){
[ ! -f "$CRASHDIR"/.dis_startup ] && return 0
elif [ -f /etc/rc.common -a "$(cat /proc/1/comm)" = "procd" ]; then
[ -n "$(find /etc/rc.d -name '*shellcrash')" ] && return 0
[ ! -f "$CRASHDIR"/.dis_startup ] && return 0
elif ckcmd systemctl; then
[ "$(systemctl is-enabled shellcrash.service 2>&1)" = enabled ] && return 0
elif grep -q 's6' /proc/1/comm; then

View File

@@ -23,7 +23,9 @@ core_unzip() { #$1:需要解压的文件 $2:目标文件名
}
core_find(){
if [ ! -f "$TMPDIR"/CrashCore ];then
core_dir=$(find "$BINDIR"/CrashCore.* $find_para 2>/dev/null)
[ -n "$(find "$CRASHDIR"/CrashCore.* $find_para 2>/dev/null)" ] && [ "$CRASHDIR" != "$BINDIR" ] &&
mv -f "$CRASHDIR"/CrashCore.* "$BINDIR"/
core_dir=$(find "$BINDIR"/CrashCore.* $find_para 2>/dev/null | head -n 1)
[ -n "$core_dir" ] && core_unzip "$core_dir" CrashCore
fi
}
@@ -40,16 +42,20 @@ core_check(){
COMMAND='"$TMPDIR/CrashCore -d $BINDIR -f $TMPDIR/config.yaml"'
fi
if [ -z "$v" ]; then
rm -rf "$TMPDIR"/core_new
rm -rf "$1"
rm -rf "$1" "$TMPDIR"/core_new
return 2
else
rm -f "$BINDIR"/CrashCore.tar.gz "$BINDIR"/CrashCore.gz "$BINDIR"/CrashCore.upx
mv -f "$TMPDIR"/core_new "$TMPDIR"/CrashCore
if [ -f "$1" ];then
mv -f "$1" "$BINDIR/CrashCore.${zip_type}"
if [ -z "$zip_type" ];then
gzip -c "$TMPDIR/core_new" > "$BINDIR/CrashCore.gz"
else
gzip -c "$TMPDIR"/CrashCore > "$BINDIR"/CrashCore.gz
mv -f "$1" "$BINDIR/CrashCore.$zip_type"
fi
if [ "$zip_type" = 'upx' ];then
rm -f "$1" "$TMPDIR"/core_new
ln -sf "$TMPDIR/CrashCore.upx" "$TMPDIR/CrashCore"
else
mv -f "$TMPDIR/core_new" "$TMPDIR/CrashCore"
fi
core_v="$v"
setconfig COMMAND "$COMMAND" "$CRASHDIR"/configs/command.env && . "$CRASHDIR"/configs/command.env
@@ -64,17 +70,17 @@ core_webget(){
. "$CRASHDIR"/libs/check_target.sh
if [ -z "$custcorelink" ];then
[ -z "$zip_type" ] && zip_type='tar.gz'
get_bin "$TMPDIR/CrashCore.${zip_type}" "bin/$crashcore/${target}-linux-${cpucore}.${zip_type}"
get_bin "$TMPDIR/Coretmp.$zip_type" "bin/$crashcore/${target}-linux-${cpucore}.$zip_type"
else
zip_type=$(echo "$custcorelink" | grep -oE 'tar.gz$')
[ -z "$zip_type" ] && zip_type=$(echo "$custcorelink" | grep -oE 'gz$')
[ -n "$zip_type" ] && webget "$TMPDIR/CrashCore.${zip_type}" "$custcorelink"
[ -n "$zip_type" ] && webget "$TMPDIR/Coretmp.$zip_type" "$custcorelink"
fi
#校验内核
if [ "$?" = 0 ];then
core_check "$TMPDIR/CrashCore.${zip_type}"
core_check "$TMPDIR/Coretmp.$zip_type"
else
rm -rf "$TMPDIR/CrashCore.${zip_type}"
rm -f "$TMPDIR/Coretmp.$zip_type"
return 1
fi
}

View File

@@ -1,3 +1,6 @@
# 检查配置文件
[ -f "$CRASHDIR"/configs/ShellCrash.cfg ] || . "$CRASHDIR"/init.sh >/dev/null 2>&1
. "$CRASHDIR"/configs/command.env >/dev/null 2>&1
. "$CRASHDIR"/configs/ShellCrash.cfg
@@ -13,10 +16,7 @@ routing_mark=$((fwmark + 2))
[ -z "$dns_nameserver" ] && {
dns_nameserver='223.5.5.5, 1.2.4.8'
cat /proc/net/udp | grep -q '0035' && dns_nameserver='localhost'
netstat -ntlup 2>/dev/null | grep -q '127.0.0.1:53' && dns_nameserver='127.0.0.1'
}
[ -z "$dns_fallback" ] && dns_fallback="1.1.1.1, 8.8.8.8"
[ -z "$dns_resolver" ] && {
dns_resolver="223.5.5.5, 2400:3200::1"
cat /proc/net/udp | grep -q '0035' && dns_resolver='127.0.0.1'
}
[ -z "$dns_resolver" ] && dns_resolver="223.5.5.5, 2400:3200::1"

View File

@@ -1,14 +1,15 @@
#日志工具
. "$CRASHDIR"/libs/web_json.sh
#$1日志内容$2显示颜色$3是否推送
#$1日志内容$2显示颜色$3是否推送$4是否覆盖上一条
logger() {
TMPDIR=/tmp/ShellCrash
[ -n "$2" -a "$2" != 0 ] && echo -e "\033[$2m$1\033[0m"
[ -n "$2" -a "$2" != 0 ] && printf "\033[%sm%s\033[0m\n" "$2" "$1"
log_text="$(date "+%G-%m-%d_%H:%M:%S")~$1"
[ "$4" = on ] && sed -i "/$1/d" "$TMPDIR"/ShellCrash.log
echo "$log_text" >>"$TMPDIR"/ShellCrash.log
[ "$(wc -l "$TMPDIR"/ShellCrash.log | awk '{print $1}')" -gt 99 ] && sed -i '1,50d' "$TMPDIR"/ShellCrash.log
[ "$(wc -l "$TMPDIR"/ShellCrash.log | awk '{print $1}')" -gt 199 ] && sed -i '1,20d' "$TMPDIR"/ShellCrash.log
#推送远程日志
[ -z "$3" ] && {
[ "$3" != off ] && {
[ -n "$device_name" ] && log_text="$log_text($device_name)"
[ -n "$push_TG" ] && {
url="https://api.telegram.org/bot${push_TG}/sendMessage"
@@ -18,7 +19,7 @@ logger() {
}
[ -n "$push_bark" ] && {
url="${push_bark}"
content="{\"body\":\"${log_text}\",\"title\":\"ShellCrash日志推送\",\"level\":\"passive\",\"badge\":\"1\"}"
content="{\"body\":\"${log_text}\",\"title\":\"ShellCrash_log\",\"level\":\"passive\",\"badge\":\"1\"}"
web_json_post "$url" "$content" &
}
[ -n "$push_Deer" ] && {
@@ -28,17 +29,17 @@ logger() {
}
[ -n "$push_Po" ] && {
url="https://api.pushover.net/1/messages.json"
content="{\"token\":\"${push_Po}\",\"user\":\"${push_Po_key}\",\"title\":\"ShellCrash日志推送\",\"message\":\"$log_text\"}"
content="{\"token\":\"${push_Po}\",\"user\":\"${push_Po_key}\",\"title\":\"ShellCrash_log\",\"message\":\"$log_text\"}"
web_json_post "$url" "$content" &
}
[ -n "$push_PP" ] && {
url="http://www.pushplus.plus/send"
content="{\"token\":\"${push_PP}\",\"title\":\"ShellCrash日志推送\",\"content\":\"$log_text\"}"
content="{\"token\":\"${push_PP}\",\"title\":\"ShellCrash_log\",\"content\":\"$log_text\"}"
web_json_post "$url" "$content" &
}
[ -n "$push_Gotify" ] && {
url="${push_Gotify}"
content="{\"title\":\"ShellCrash日志推送\",\"message\":\"$log_text\",\"priority\":5}"
content="{\"title\":\"ShellCrash_log\",\"message\":\"$log_text\",\"priority\":5}"
web_json_post "$url" "$content" &
}
[ -n "$push_SynoChat" ] && {

View File

@@ -1,9 +1,6 @@
#参数1代表变量名参数2代表变量值,参数3即文件路径
setconfig() {
[ -z "$3" ] && configpath="$CRASHDIR"/configs/ShellCrash.cfg || configpath="${3}"
if grep -q "^${1}=" "$configpath"; then
sed -i "s#^${1}=.*#${1}=${2}#g" "$configpath"
else
sed -i "/^${1}=.*/d" "$configpath"
printf '%s=%s\n' "$1" "$2" >>"$configpath"
fi
}

View File

@@ -1,27 +1,39 @@
crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}')"
crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}'| tr -d ' ')"
[ ! -w "$crondir" ] && crondir="/etc/storage/cron/crontabs"
[ ! -w "$crondir" ] && crondir="/var/spool/cron/crontabs"
[ ! -w "$crondir" ] && crondir="/var/spool/cron"
tmpcron="$TMPDIR"/cron_tmp
[ -z "$USER" ] && USER=$(whoami 2>/dev/null)
tmpcron=/tmp/cron_tmp
touch "$tmpcron"
croncmd() { #定时任务工具
if [ -n "$(crontab -h 2>&1 | grep '\-l')" ]; then
cronadd() { #定时任务工具
if crontab -h 2>&1 | grep -q '\-l'; then
crontab "$1"
elif [ -w "$crondir" ] && [ -n "$USER" ];then
[ "$1" = "-l" ] && cat "$crondir"/"$USER" 2>/dev/null
[ -f "$1" ] && cat "$1" >"$crondir"/"$USER"
killall -HUP crond 2>/dev/null
elif [ -f "$crondir/$USER" ];then
cat "$1" >"$crondir"/"$USER" && cru a REFRESH "0 0 1 1 * /bin/true" 2>/dev/null
else
echo "找不到可用的crond或者crontab应用No available crond or crontab application can be found!"
fi
}
cronload() { #定时任务工具
if crontab -h 2>&1 | grep -q '\-l'; then
crontab -l
elif [ -f "$crondir/$USER" ];then
cat "$crondir"/"$USER" 2>/dev/null
else
return 1
fi
}
cronset() { #定时任务设置
# 参数1代表要移除的关键字,参数2代表要添加的任务语句
croncmd -l >"$tmpcron"
sed -i "/$1/d" "$tmpcron"
sed -i '/^$/d' "$tmpcron"
echo "$2" >>"$tmpcron"
croncmd "$tmpcron"
cronload | grep -v '^$' | grep -vF "$1" >"$tmpcron"
[ -n "$2" ] && echo "$2" >>"$tmpcron"
cronadd "$tmpcron"
#华硕/Padavan固件存档在本地,其他则删除
if [ -d /jffs ] || [ -d /etc/storage/ShellCrash ];then
mv -f "$tmpcron" "$CRASHDIR"/task/cron
else
rm -f "$tmpcron"
fi
}

View File

@@ -5,4 +5,5 @@ set_profile() {
echo "alias ${my_alias}=\"$shtype $CRASHDIR/menu.sh\"" >>"$1" #设置快捷命令环境变量
sed -i '/export CRASHDIR=*/'d "$1"
echo "export CRASHDIR=\"$CRASHDIR\"" >>"$1" #设置路径环境变量
. "$1" >/dev/null 2>&1 || true
}

View File

@@ -13,18 +13,26 @@ webget(){
#参数【$1】代表下载目录【$2】代表在线地址
#参数【$3】代表输出显示【$4】不启用重定向
#参数【$5】代表验证证书【$6】使用自定义UA
[ -n "$6" ] && agent="--user-agent \"$6\""
[ -n "$6" ] && agent="--user-agent $6"
if wget --help 2>&1 | grep -q 'show-progress' >/dev/null 2>&1; then
[ "$3" = "echooff" ] && progress='-q' || progress='-q --show-progress'
[ "$4" = "rediroff" ] && redirect='--max-redirect=0' || redirect=''
[ "$5" = "skipceroff" ] && certificate='' || certificate='--no-check-certificate'
if [ "$5" = "skipceroff" ] || [ "$skip_cert" = OFF ];then
certificate=''
else
certificate='--no-check-certificate'
fi
wget -Y on $agent $progress $redirect $certificate --timeout=3 -O "$1" "$url" && return 0 #成功则退出否则重试
wget -Y off $agent $progress $redirect $certificate --timeout=5 -O "$1" "$2"
return $?
elif curl --version >/dev/null 2>&1; then
[ "$3" = "echooff" ] && progress='-s' || progress='-#'
[ "$4" = "rediroff" ] && redirect='' || redirect='-L'
[ "$5" = "skipceroff" ] && certificate='' || certificate='-k'
if [ "$5" = "skipceroff" ] || [ "$skip_cert" = OFF ];then
certificate=''
else
certificate='-k'
fi
if curl --version | grep -q '^curl 8.' && ckcmd base64; then
auth_b64=$(printf '%s' "$authentication" | base64)
result=$(curl $agent -w '%{http_code}' --connect-timeout 3 --proxy-header "Proxy-Authorization: Basic $auth_b64" $progress $redirect $certificate -o "$1" "$url")
@@ -43,7 +51,7 @@ webget(){
wget -Y off $progress -O "$1" "$2"
return $?
else
echo "找不到可用下载工具请安装Curl或Wget"
echo "No Curl or Wget"
return 1
fi
}

View File

@@ -26,7 +26,7 @@ web_save() { #最小化保存面板节点选择
. "$CRASHDIR"/libs/compare.sh && compare "$TMPDIR/$file" "$CRASHDIR/configs/$file"
[ "$?" = 0 ] && rm -f "$TMPDIR/$file" || mv -f "$TMPDIR/$file" "$CRASHDIR/configs/$file"
else
rm -f "$CRASHDIR/configs/$file" #空文件时移除旧文件
> "$CRASHDIR/configs/$file" #空文件时移除旧文件
fi
done
}

View File

@@ -44,12 +44,6 @@ checkport() { #检查端口冲突
done
}
ckstatus() { #脚本启动前检查
#检查脚本配置文件
if [ -f "$CFG_PATH" ]; then
[ -n "$(awk 'a[$0]++' $CFG_PATH)" ] && awk '!a[$0]++' "$CFG_PATH" >"$CFG_PATH" #检查重复行并去除
else
. "$CRASHDIR"/init.sh >/dev/null 2>&1
fi
versionsh=$(cat "$CRASHDIR"/version)
[ -n "$versionsh" ] && versionsh_l=$versionsh
[ -z "$redir_mod" ] && redir_mod=纯净模式
@@ -100,13 +94,15 @@ ckstatus() { #脚本启动前检查
echo "-----------------------------------------------"
#检查新手引导
if [ -z "$userguide" ]; then
userguide=1
setconfig userguide 1
. "$CRASHDIR"/menus/8_tools.sh && userguide
. "$CRASHDIR"/configs/ShellCrash.cfg
fi
#检查执行权限
[ ! -x "$CRASHDIR"/start.sh ] && chmod +x "$CRASHDIR"/start.sh
#检查/tmp内核文件
for file in $(ls /tmp | grep -v [/$] | grep -v ' ' | grep -Ev ".*(zip|7z|tar)$" | grep -iE 'CrashCore|^clash$|^clash-linux.*|^mihomo.*|^sing.*box|meta.*'); do
for file in $(ls /tmp | grep -v [/$] | grep -v ' ' | grep -Ev ".*(zip|7z|tar)$" | grep -iE 'CrashCore|^clash$|^clash-linux.*|^mihomo.*|^sing.*box'); do
echo -e "发现可用的内核文件: \033[36m/tmp/$file\033[0m "
read -p "是否加载(会停止当前服务)(1/0) > " res
[ "$res" = 1 ] && {
@@ -240,18 +236,24 @@ case "$1" in
main_menu
;;
-t)
shtype=sh && [ -n "$(ls -l /bin/sh | grep -o dash)" ] && shtype=bash
shtype=sh
ckcmd bash && shtype=bash
$shtype -x "$CRASHDIR"/menu.sh
;;
-s)
"$CRASHDIR"/start.sh $2 $3 $4 $5 $6
"$CRASHDIR"/start.sh "$2" "$3" "$4" "$5" "$6"
;;
-i)
. "$CRASHDIR"/init.sh 2>/dev/null
;;
-st)
shtype=sh && [ -n "$(ls -l /bin/sh | grep -o dash)" ] && shtype=bash
$shtype -x "$CRASHDIR"/start.sh $2 $3 $4 $5 $6
shtype=sh
ckcmd bash && shtype=bash
"$shtype" -x "$CRASHDIR"/starts/bfstart.sh
. "$CRASHDIR"/starts/start_legacy.sh
start_legacy "$COMMAND" 'shellcrash'
"$shtype" -x "$CRASHDIR"/starts/afstart.sh
"$CRASHDIR"/start.sh stop
;;
-d)
shtype=sh && [ -n "$(ls -l /bin/sh | grep -o dash)" ] && shtype=bash

View File

@@ -7,7 +7,10 @@ __IS_MODULE_2_SETTINGS_LOADED=1
settings() { #功能设置
#获取设置默认显示
[ -z "$skip_cert" ] && skip_cert=ON
[ -z "$sniffer" ] && sniffer=OFF
[ -z "$sniffer" ] && {
sniffer=OFF
echo "$crashcore" | grep -q 'singbox' && sniffer=ON
}
[ -z "$dns_mod" ] && dns_mod='redir_host'
#
echo "-----------------------------------------------"
@@ -633,7 +636,7 @@ fw_filter_lan() { #局域网设备过滤
fi
######
echo -e "\033[30;47m请在此添加或移除设备\033[0m"
echo -e "当前过滤方式为:\033[33m$fw_filter_lan_type模式\033[0m"
echo -e "当前过滤方式为:\033[33m$macfilter_type模式\033[0m"
echo -e "仅列表内设备流量\033[36m$fw_filter_lan_scrip经过\033[0m内核"
if [ -n "$(cat "$CRASHDIR"/configs/mac)" ]; then
echo "-----------------------------------------------"
@@ -662,7 +665,7 @@ fw_filter_lan() { #局域网设备过滤
macfilter_type=$fw_filter_lan_over
setconfig macfilter_type $macfilter_type
echo "-----------------------------------------------"
echo -e "\033[32m已切换为$fw_filter_lan_type模式\033[0m"
echo -e "\033[32m已切换为$macfilter_type模式\033[0m"
fw_filter_lan
;;
2)

View File

@@ -108,9 +108,7 @@ task_add(){ #任务添加
}
task_del(){ #任务删除
#删除定时任务
croncmd -l > "$TMPDIR"/cron
sed -i "/$1/d" "$TMPDIR"/cron && croncmd "$TMPDIR"/cron
rm -f "$TMPDIR"/cron
cronset "$1"
#删除条件任务
sed -i "/$1/d" "$CRASHDIR"/task/cron 2>/dev/null
sed -i "/$1/d" "$CRASHDIR"/task/bfstart 2>/dev/null
@@ -214,7 +212,7 @@ task_type(){ #任务条件选择菜单
task_manager(){ #任务管理列表
echo "-----------------------------------------------"
#抽取并生成临时列表
croncmd -l > "$TMPDIR"/task_cronlist
cronload > "$TMPDIR"/task_cronlist
cat "$TMPDIR"/task_cronlist "$CRASHDIR"/task/running 2>/dev/null | sort -u | grep -oE "task/task.sh .*" | awk -F ' ' '{print $2" "$3}' > "$TMPDIR"/task_list
cat "$CRASHDIR"/task/bfstart "$CRASHDIR"/task/afstart "$CRASHDIR"/task/affirewall 2>/dev/null | awk -F ' ' '{print $2" "$3}' >> "$TMPDIR"/task_list
cat "$TMPDIR"/task_cronlist 2>/dev/null | sort -u | grep -oE " #.*" | grep -v "守护" | awk -F '#' '{print "0 旧版任务-"$2}' >> "$TMPDIR"/task_list
@@ -254,9 +252,8 @@ task_manager(){ #任务管理列表
read -p "旧版任务不支持管理,是否移除?(1/0) > " res
[ "$res" = 1 ] && {
cronname=$(echo $task_txt | awk -F '-' '{print $2}')
croncmd -l > $TMPDIR/conf && sed -i "/$cronname/d" $TMPDIR/conf && croncmd $TMPDIR/conf
sed -i "/$cronname/d" $clashdir/tools/cron 2>/dev/null
rm -f $TMPDIR/conf
cronset "$cronname"
sed -i "/$cronname/d" "$CRASHDIR"/task/cron 2>/dev/null
}
else
task_des=$(echo $task_txt | awk '{print $2}')

View File

@@ -515,7 +515,7 @@ EOF
sed -i '$s/},/}]}/' "$TMPDIR"/providers/outbounds_add.json
sed -i '$s/},/}]}/' "$TMPDIR"/providers/providers.json
#使用模版生成outbounds和rules模块
cat "$TMPDIR"/provider_temp_file | sed "s/{providers_tags}/$providers_tags/g" > "$TMPDIR"/providers/outbounds.json
cat "$TMPDIR"/provider_temp_file | sed "s/{providers_tags}/$providers_tags/g" | sed "s/\"providers_tags\"/$providers_tags/g" > "$TMPDIR"/providers/outbounds.json
rm -rf "$TMPDIR"/provider_temp_file
#调用内核测试
. "$CRASHDIR"/starts/check_core.sh && check_core && "$TMPDIR"/CrashCore merge "$TMPDIR"/config.json -C "$TMPDIR"/providers

View File

@@ -155,13 +155,13 @@ set_bot_tg_config(){
JSON=$(cat <<EOF
{
"commands": [
{"command": "crash", "description": "呼出ShellCrash菜单"},
{"command": "$my_alias", "description": "呼出ShellCrash菜单"},
{"command": "help", "description": "查看帮助"}
]
}
EOF
)
TEXT='已完成Telegram机器人设置'
TEXT="已完成Telegram机器人设置请使用 /$my_alias 呼出功能菜单!"
. "$CRASHDIR"/libs/web_json.sh
bot_api="https://api.telegram.org/bot$TOKEN"
web_json_post "$bot_api/setMyCommands" "$JSON"

View File

@@ -140,6 +140,7 @@ getscripts(){
error_down
else
. "$CRASHDIR"/init.sh >/dev/null
echo "$release_type" | grep -qE '^[0-9]' && setconfig userguide #回退时重新新手引导
echo -e "\033[32m脚本更新成功\033[0m"
fi
fi
@@ -1041,16 +1042,17 @@ setserver() {
echo "-----------------------------------------------"
if [ -n "$url_id" ] && [ "$url_id" -lt 200 ];then
echo -ne "\033[32m正在获取版本信息\033[0m\r"
get_bin "$TMPDIR"/release_version bin/release_version
. "$CRASHDIR"/libs/web_get_lite.sh
web_get_lite https://github.com/juewuy/ShellCrash/tags | grep -o 'releases/tag/.*data'|awk -F '/' '{print $3}'|sed 's/".*//g' > "$TMPDIR"/tags
if [ "$?" = "0" ];then
echo -e "\033[31m请选择想要回退至的稳定版版本:\033[0m"
cat "$TMPDIR"/release_version | awk '{print " "NR" "$1}'
echo -e "\033[31m请选择想要回退至的具体版本:\033[0m"
cat "$TMPDIR"/tags | awk '{print " "NR" "$1}'
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" -o "$num" = 0 ]; then
continue
elif [ $num -le $(cat "$TMPDIR"/release_version 2>/dev/null | awk 'END{print NR}') ]; then
release_type=$(cat "$TMPDIR"/release_version | awk '{print $1}' | sed -n "$num"p)
elif [ $num -le $(cat "$TMPDIR"/tags 2>/dev/null | awk 'END{print NR}') ]; then
release_type=$(cat "$TMPDIR"/tags | awk '{print $1}' | sed -n "$num"p)
update_url=''
saveserver
else
@@ -1065,7 +1067,7 @@ setserver() {
sleep 1
continue
fi
rm -rf "$TMPDIR"/release_version
rm -rf "$TMPDIR"/tags
else
echo -e "\033[31m当前源不支持版本回退请尝试更换其他安装源\033[0m"
sleep 1

View File

@@ -2,6 +2,7 @@
[ -z "$CRASHDIR" ] && CRASHDIR=$( cd $(dirname $0);cd ..;pwd)
. "$CRASHDIR"/libs/web_json.sh
. "$CRASHDIR"/libs/set_config.sh
. "$CRASHDIR"/libs/web_get_lite.sh
. "$CRASHDIR"/menus/running_status.sh
. "$CRASHDIR"/configs/gateway.cfg
@@ -155,8 +156,6 @@ download_file(){
else
send_msg "文件格式不匹配,上传失败!"
fi
OFFSET=$((OFFSET + 1))
continue
}
### --- 具体操作函数 --- ###
do_start_fw(){
@@ -231,11 +230,18 @@ polling(){
OFFSET=$(echo "$UPDATES" | grep -o '"update_id":[0-9]*' | tail -n1 | cut -d: -f2)
OFFSET=$((OFFSET + 1))
### --- 校验ChatID --- ###
CHATID=$(echo "$UPDATES" | grep -o '"id":[0-9]*' | tail -n1 | cut -d: -f2)
[ "$CHATID" != "$TG_CHATID" ] && continue
### --- 处理按钮事件 --- ###
CALLBACK=$(echo "$UPDATES" | grep -o '"data":"[^"]*"' | head -n1 | sed 's/.*:"//;s/"$//')
FILE_ID=$(echo "$UPDATES" | sed 's/"callback_query".*//g' | grep -o '"file_id":"[^"]*"' | head -n1 | sed 's/.*:"//;s/"$//')
[ -n "$FILE_ID" ] && download_file
[ -n "$FILE_ID" ] && {
download_file
continue
}
[ -n "$CALLBACK" ] && case "$CALLBACK" in
"start_redir")
if [ "$redir_mod" = '纯净模式' ];then
@@ -303,6 +309,9 @@ polling(){
/crash)
send_menu
;;
/"$my_alias")
send_menu
;;
/help)
send_help
;;

View File

@@ -20,7 +20,7 @@ tg_push_token(){
push_TG="$TOKEN"
setconfig push_TG "$TOKEN"
setconfig chat_ID "$chat_ID"
"$CRASHDIR"/start.sh logger "已完成Telegram日志推送设置" 32
. "$CRASHDIR"/libs/logger.sh && logger "已完成Telegram日志推送设置" 32
}
get_chatid(){
i=1

View File

@@ -2,18 +2,16 @@
. "$CRASHDIR"/libs/set_cron.sh
bot_tg_start(){
bot_tg_stop
. "$CRASHDIR"/starts/start_legacy.sh
start_legacy "$CRASHDIR/menus/bot_tg.sh" 'bot_tg'
bot_tg_cron
}
bot_tg_stop(){
cronset 'TG_BOT守护进程'
[ -f "$TMPDIR/bot_tg.pid" ] && kill -TERM "$(cat "$TMPDIR/bot_tg.pid")"
cronload | grep -q 'TG_BOT' && cronset 'TG_BOT'
[ -f "$TMPDIR/bot_tg.pid" ] && kill -TERM "$(cat "$TMPDIR/bot_tg.pid")" 2>/dev/null
killall bot_tg.sh 2>/dev/null
rm -f "$TMPDIR/bot_tg.pid"
}
bot_tg_cron(){
cronset 'TG_BOT守护进程'
cronset 'TG_BOT守护进程' "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh bot_tg #ShellCrash-TG_BOT守护进程"
}

View File

@@ -59,16 +59,21 @@ set_ddns() {
}
set_ddns_service() {
services_dir=/etc/ddns/"$serv"
[ -s "$services_dir" ] || services_dir=/etc/ddns/services
[ -s "$services_dir" ] || services_dir=/usr/share/ddns/list
[ -s "$services_dir" ] || {
echo -e "\033[33m未找到DDNS列表文件尝试在线获取……\033[0m"
ddns service update >/dev/null || echo -e "\033[31m下载失败请重试\033[0m"
}
echo -----------------------------------------------
echo -e "\033[32m请选择服务提供商\033[0m"
cat "$services_dir" | grep -v '^#' | awk '{print " "NR" " $1}'
nr=$(cat "$services_dir" | grep -v '^#' | wc -l)
cat "$services_dir" | grep -vE '^#|^[[:space:]]*$' | awk '{print " "NR" " $1}'
nr=$(cat "$services_dir" | grep -vE '^#|^[[:space:]]*$' | wc -l)
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
i=
elif [ "$num" -gt 0 -a "$num" -lt $nr ]; then
service_name=$(cat "$services_dir" | grep -v '^#' | awk '{print $1}' | sed -n "$num"p | sed 's/"//g')
service_name=$(cat "$services_dir" | grep -vE '^#|^[[:space:]]*$' | awk '{print $1}' | sed -n "$num"p | sed 's/"//g')
service=$(echo $service_name | sed 's/\./_/g')
set_ddns
else

View File

@@ -14,8 +14,11 @@ task_logger(){
[ "$task_push" = 1 ] && push= || push=off
[ -n "$2" -a "$2" != 0 ] && echo -e "\033[$2m$1\033[0m"
[ "$3" = 'off' ] && push=off
echo "$1" |grep -qE '(每隔|时每)([1-9]|[1-9][0-9])分钟' && push=off
logger "$1" 0 "$push"
echo "$1" |grep -qE '(每隔|时每)([1-9]|[1-9][0-9])分钟' && {
push=off
cover=on
}
logger "$1" 0 "$push" "$cover"
}
#任务命令
@@ -32,7 +35,7 @@ update_core(){ #自动更新内核
task_logger "任务【自动更新内核】中止-未检测到版本更新"
return 0
else
. "$CRASHDIR"/libs/core_webget.sh && core_webget #调用下载工具
. "$CRASHDIR"/libs/core_tools.sh && core_webget #调用下载工具
case "$?" in
0)
task_logger "任务【自动更新内核】下载完成,正在重启服务!"
@@ -58,18 +61,18 @@ update_scripts(){ #自动更新脚本
task_logger "任务【自动更新脚本】中止-未检测到版本更新"
return 0
else
get_bin "$TMPDIR"/clashfm.tar.gz "bin/update.tar.gz"
get_bin "$TMPDIR"/ShellCrash.tar.gz "ShellCrash.tar.gz"
if [ "$?" != "0" ];then
rm -rf "$TMPDIR"/clashfm.tar.gz
rm -rf "$TMPDIR"/ShellCrash.tar.gz
task_logger "任务【自动更新内核】出错-下载失败!"
return 1
else
#停止服务
"$CRASHDIR"/start.sh stop
#解压
tar -zxf "$TMPDIR"/clashfm.tar.gz ${tar_para} -C "$CRASHDIR"/
tar -zxf "$TMPDIR"/ShellCrash.tar.gz ${tar_para} -C "$CRASHDIR"/
if [ $? -ne 0 ];then
rm -rf "$TMPDIR"/clashfm.tar.gz
rm -rf "$TMPDIR"/ShellCrash.tar.gz
task_logger "任务【自动更新内核】出错-解压失败!"
"$CRASHDIR"/start.sh start
return 1
@@ -116,7 +119,7 @@ reset_firewall(){ #重设透明路由防火墙
"$CRASHDIR"/start.sh afstart
}
ntp(){
[ "$crashcore" != singbox ] && ckcmd ntpd && ntpd -n -q -p 203.107.6.88 >/dev/null 2>&1 || exit 0
ckcmd ntpd && ntpd -n -q -p 203.107.6.88 >/dev/null 2>&1 || exit 0
}
web_save_auto(){
. "$CRASHDIR"/libs/web_save.sh && web_save

View File

@@ -37,7 +37,7 @@ case "$1" in
start)
[ -n "$(pidof CrashCore)" ] && $0 stop #禁止多实例
stop_firewall #清理路由策略
rm -f "CRASHDIR"/.start_error #移除自启失败标记
rm -f "$CRASHDIR"/\.start_error #移除自启失败标记
#使用不同方式启动服务
if [ "$firewall_area" = "5" ]; then #主旁转发
. "$CRASHDIR"/starts/fw_start.sh
@@ -47,8 +47,8 @@ start)
/etc/init.d/shellcrash start
elif [ "$USER" = "root" ] && grep -q 'systemd' /proc/1/comm; then
FragmentPath=$(systemctl show -p FragmentPath shellcrash | sed 's/FragmentPath=//')
[ -f $FragmentPath ] && {
setconfig ExecStart "$COMMAND >/dev/null" "$FragmentPath"
[ -f "$FragmentPath" ] && {
sed -i "s#^ExecStart=.*#ExecStart=$COMMAND >/dev/null#" "$FragmentPath"
systemctl daemon-reload
}
systemctl start shellcrash.service || . "$CRASHDIR"/starts/start_error.sh
@@ -67,14 +67,17 @@ start)
stop)
logger ShellCrash服务即将关闭……
[ -n "$(pidof CrashCore)" ] && web_save #保存面板配置
#删除守护进程&面板配置自动保存
cronset '保守模式守护进程'
cronset '运行时每'
cronset '流媒体预解析'
#清理定时任务
cronload | grep -vE '^$|start_legacy_wd.sh|运行时每' > "$TMPDIR"/cron_tmp
cronadd "$TMPDIR"/cron_tmp
rm -f "$TMPDIR"/cron_tmp
#停止tg_bot
. "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_stop
#多种方式结束进程
if [ -f "$TMPDIR/shellcrash.pid" ];then
kill -TERM "$(cat "$TMPDIR/shellcrash.pid")"
kill -TERM "$(cat "$TMPDIR/shellcrash.pid")" 2>/dev/null
rm -f "$TMPDIR/shellcrash.pid"
stop_firewall
elif [ "$USER" = "root" ] && grep -q 'systemd' /proc/1/comm; then
systemctl stop shellcrash.service >/dev/null 2>&1
elif [ -f /etc/rc.common ] && grep -q 'procd' /proc/1/comm; then
@@ -85,7 +88,7 @@ stop)
elif rc-status -r >/dev/null 2>&1; then
rc-service shellcrash stop >/dev/null 2>&1
else
stop_firewall #清理路由策略
stop_firewall
fi
killall CrashCore 2>/dev/null
#清理缓存目录
@@ -115,8 +118,8 @@ debug)
else
sed -i "s/log-level: info/log-level: $2/" "$TMPDIR"/config.yaml
fi
[ "$3" = flash ] && dir=$CRASHDIR || dir=$TMPDIR
$COMMAND >${dir}/debug.log 2>&1 &
[ "$3" = flash ] && dir="$CRASHDIR" || dir="$TMPDIR"
$COMMAND >"$dir"/debug.log 2>&1 &
sleep 2
logger "已运行debug模式!如需停止,请使用重启/停止服务功能!" 33
else

View File

@@ -21,8 +21,6 @@ if [ -n "$test" -o -n "$(pidof CrashCore)" ]; then
[ "$start_old" = "ON" ] && [ ! -L "$TMPDIR"/CrashCore ] && rm -f "$TMPDIR"/CrashCore #删除缓存目录内核文件
. "$CRASHDIR"/starts/fw_start.sh #配置防火墙流量劫持
date +%s >"$TMPDIR"/crash_start_time #标记启动时间
#TG机器人守护进程
[ "$bot_tg_service" = ON ] && . "$CRASHDIR"/menus/bot_tg_service.sh && bot_tg_cron
#后台还原面板配置
[ -s "$CRASHDIR"/configs/web_save ] && {
. "$CRASHDIR"/libs/web_restore.sh
@@ -33,27 +31,26 @@ if [ -n "$test" -o -n "$(pidof CrashCore)" ]; then
sleep 5
logger ShellCrash服务已启动
} &
ckcmd mtd_storage.sh && mtd_storage.sh save >/dev/null 2>&1 & #Padavan保存/etc/storage
ckcmd mtd_storage.sh && mtd_storage.sh save >/dev/null 2>&1 #Padavan保存/etc/storage
#加载定时任务
[ -s "$CRASHDIR"/task/cron ] && croncmd "$CRASHDIR"/task/cron
[ -s "$CRASHDIR"/task/running ] && {
cronset '运行时每'
while read line; do
cronset '2fjdi124dd12s' "$line"
done <"$CRASHDIR"/task/running
}
[ "$start_old" = "ON" ] && cronset '保守模式守护进程' "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh shellcrash #ShellCrash保守模式守护进程"
cronload | grep -v '^$' > "$TMPDIR"/cron_tmp
[ -s "$CRASHDIR"/task/cron ] && cat "$CRASHDIR"/task/cron >> "$TMPDIR"/cron_tmp
[ -s "$CRASHDIR"/task/running ] && cat "$CRASHDIR"/task/running >> "$TMPDIR"/cron_tmp
[ "$bot_tg_service" = ON ] && echo "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh bot_tg #ShellCrash-TG_BOT守护进程" >> "$TMPDIR"/cron_tmp
[ "$start_old" = ON ] && echo "* * * * * /bin/sh $CRASHDIR/starts/start_legacy_wd.sh shellcrash #ShellCrash保守模式守护进程" >> "$TMPDIR"/cron_tmp
awk '!x[$0]++' "$TMPDIR"/cron_tmp > "$TMPDIR"/cron_tmp2 #删除重复行
cronadd "$TMPDIR"/cron_tmp2
rm -f "$TMPDIR"/cron_tmp "$TMPDIR"/cron_tmp2
#加载条件任务
[ -s "$CRASHDIR"/task/afstart ] && { . "$CRASHDIR"/task/afstart; } &
[ -s "$CRASHDIR"/task/affirewall -a -s /etc/init.d/firewall -a ! -f /etc/init.d/firewall.bak ] && {
#注入防火墙
line=$(grep -En "fw.* restart" /etc/init.d/firewall | cut -d ":" -f 1)
sed -i.bak "${line}a\\. "$CRASHDIR"/task/affirewall" /etc/init.d/firewall
sed -i.bak "${line}a\\. $CRASHDIR/task/affirewall" /etc/init.d/firewall
line=$(grep -En "fw.* start" /etc/init.d/firewall | cut -d ":" -f 1)
sed -i "${line}a\\. $CRASHDIR/task/affirewall" /etc/init.d/firewall
} &
exit 0
else
. "$CRASHDIR"/starts/start_error.sh
"$CRASHDIR"/start.sh stop
fi

View File

@@ -8,7 +8,7 @@
[ ! -f "$TMPDIR" ] && mkdir -p "$TMPDIR"
#当上次启动失败时终止自启动
[ -f "CRASHDIR"/.start_error ] && exit 1
[ -f "$CRASHDIR"/.start_error ] && exit 1
#加载工具
. "$CRASHDIR"/libs/check_cmd.sh
. "$CRASHDIR"/libs/check_target.sh

View File

@@ -6,13 +6,12 @@
check_core() { #检查及下载内核文件
[ -n "$(find --help 2>&1 | grep -o size)" ] && find_para=' -size +2000' #find命令兼容
[ -z "$(find "$TMPDIR"/CrashCore $find_para 2>/dev/null)" ] && core_find
[ -z "$(find "$TMPDIR"/CrashCore 2>/dev/null)" ] && {
[ ! -f "$TMPDIR"/CrashCore ] && {
logger "未找到【$crashcore】核心,正在下载!" 33
[ -z "$cpucore" ] && . "$CRASHDIR"/libs/check_cpucore.sh && check_cpucore
[ -z "$cpucore" ] && logger 找不到设备的CPU信息请手动指定处理器架构类型 31 && exit 1
core_webget || logger "核心下载失败,请重新运行或更换安装源!" 31
}
[ ! -x "$TMPDIR"/CrashCore ] && chmod +x "$TMPDIR"/CrashCore 2>/dev/null #自动授权
[ "$start_old" != "ON" -a "$(cat /proc/1/comm)" = "systemd" ] && restorecon -RF "$CRASHDIR" 2>/dev/null #修复SELinux权限问题
[ "$start_old" != "ON" ] && [ "$(cat /proc/1/comm)" = "systemd" ] && restorecon -RF "$CRASHDIR" 2>/dev/null #修复SELinux权限问题
return 0
}

View File

@@ -36,6 +36,7 @@ dns:
use-hosts: true
ipv6: $dns_v6
default-nameserver: [ $dns_resolver ]
direct-nameserver: [ $dns_nameserver ]
enhanced-mode: fake-ip
fake-ip-range: 28.0.0.0/8
fake-ip-range6: fc00::/16

View File

@@ -41,6 +41,8 @@ get_core_config() { #下载内核配置文件
fi
Https="${Server}/sub?target=${target}&${Server_ua}=${user_agent}&insert=true&new_name=true&scv=true&udp=true&${urlencodeUrl}"
url_type=true
else
Https=$(echo $Https | sed 's/\\&/\&/g') #还原转义
fi
#输出
echo "-----------------------------------------------"
@@ -65,7 +67,7 @@ get_core_config() { #下载内核配置文件
exit 1
else
retry=$((retry + 1))
logger "配置文件获取失败!" 31
logger "配置文件获取失败!" 31 off on
if [ "$retry" = 1 ]; then
echo -e "\033[32m尝试更新服务器列表并使用其他服务器获取配置\033[0m"
update_servers

View File

@@ -2,25 +2,36 @@
getlanip() { #获取局域网host地址
i=1
while [ "$i" -le "20" ]; do
host_ipv4=$(ip route show scope link | grep -Ev 'wan|utun|iot|peer|docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | awk '{print $1}' | tr '\n' ' ' | sed 's/ $//') #ipv4局域网网段
host_ipv4=$(ip route show scope link | grep -Ev 'wan|utun|iot|peer|docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | awk '{print $1}') #ipv4局域网网段
[ "$ipv6_redir" = "ON" ] && host_ipv6=$(ip -6 route show default | awk '{print $3}' | tr '\n' ' ' | sed 's/ $//') #ipv6公网地址段
[ -f "$TMPDIR"/ShellCrash.log ] && break
[ -n "$host_ipv4" -a "$ipv6_redir" != "ON" ] && break
[ -n "$host_ipv4" -a -n "$host_ipv6" ] && break
sleep 1 && i=$((i + 1))
done
#Tailscale
[ "$ts_service" = ON ] && {
ts_host_ipv4=' 100.64.0.0/10'
ts_host_ipv6=' fd7a:115c:a1e0::/48'
}
#Wireguard
[ "$wg_service" = ON ] && {
. "$CRASHDIR"/configs/gateway.cfg
wg_host_ipv4=' $wg_ipv4'
[ -n "$wg_ipv6" ] && wg_host_ipv6=' $wg_ipv6'
}
#添加自定义ipv4局域网网段
if [ "$replace_default_host_ipv4" == "ON" ]; then
host_ipv4="$cust_host_ipv4"
else
host_ipv4="$host_ipv4 $cust_host_ipv4"
host_ipv4=$(echo "$host_ipv4 $cust_host_ipv4$ts_host_ipv4$wg_host_ipv4"| tr '\n' ' ' | sed 's/ $//')
fi
#缺省配置
[ -z "$host_ipv4" ] && {
host_ipv4='192.168.0.0/16 10.0.0.0/12 172.16.0.0/12'
logger "无法获取本地LAN-IPV4网段请前往流量过滤设置界面设置自定义网段" 31
}
host_ipv6="fe80::/10 fd00::/8 $host_ipv6"
host_ipv6="fe80::/10 fd00::/8 $host_ipv6$ts_host_ipv6$wg_host_ipv6"
#获取本机出口IP地址
local_ipv4=$(ip route 2>&1 | grep -Ev 'utun|iot|docker|linkdown' | grep -Eo 'src.*' | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u)
[ -z "$local_ipv4" ] && local_ipv4=$(ip route 2>&1 | grep -Eo 'src.*' | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u)

View File

@@ -132,5 +132,5 @@ ckcmd nft && nft delete table inet shellcrash >/dev/null 2>&1
#还原防火墙文件
[ -s /etc/init.d/firewall.bak ] && mv -f /etc/init.d/firewall.bak /etc/init.d/firewall
#others
[ "$systype" != 'container' ] && sed -i '/shellcrash-dns-repair/d' /etc/resolv.conf >/dev/null 2>&1
sed -i '/shellcrash-dns-repair/d' /etc/resolv.conf 2>/dev/null

View File

@@ -23,7 +23,7 @@ fi
#写入环境变量
set_profile "$profile"
#启动进程或删除守护进程
if [ -f "$CRASHDIR"/.dis_startup ];then
if [ -f "$CRASHDIR"/.dis_startup ] || [ -f "$CRASHDIR"/.start_error ];then
cronset "保守模式守护进程"
else
"$CRASHDIR"/start.sh start

View File

@@ -200,7 +200,7 @@ EOF
EOF
#生成add_route.json
#域名嗅探配置
[ "$sniffer" = ON ] && sniffer_set='{ "action": "sniff", "timeout": "500ms" },'
[ "$sniffer" != OFF ] && sniffer_set='{ "action": "sniff", "timeout": "500ms" },'
[ "$ts_service" = ON ] && tailscale_set='{ "inbound": [ "ts-ep" ], "port": 53, "action": "hijack-dns" },'
cat >"$TMPDIR"/jsons/add_route.json <<EOF
{

View File

@@ -1,9 +1,18 @@
#!/bin/sh
# Copyright (C) Juewuy
CRASHDIR="$(uci get firewall.ShellCrash.path | sed 's/\/starts\/snapshot_init.sh//')"
[ -f "$CRASHDIR"/configs/ShellCrash.cfg ] && . "$CRASHDIR"/configs/ShellCrash.cfg
CRASHDIR="$(uci get firewall.ShellCrash.path | sed 's/\/starts.*//')"
#防止提前自启
/etc/init.d/shellcrash disable
crontab -l | grep -v 'start_legacy_wd.sh shellcrash' | crontab -
#防止usb未加载
i=0
while [ ! -f "$CRASHDIR/configs/ShellCrash.cfg" ]; do
[ $i -gt 20 ] && exit 1
i=$((i + 1))
sleep 3
done
. "$CRASHDIR"/configs/ShellCrash.cfg
autoSSH(){
#自动开启SSH
@@ -52,36 +61,40 @@ auto_clean(){
}
auto_start(){
#设置init.d服务
[ ! -x /etc/init.d/shellcrash ] && {
cp -f "$CRASHDIR"/starts/shellcrash.procd /etc/init.d/shellcrash
chmod 755 /etc/init.d/shellcrash
}
#初始化环境变量
. "$CRASHDIR"/libs/set_profile.sh && set_profile '/etc/profile'
grep -q '^export CRASHDIR=' '/etc/profile' || {
. "$CRASHDIR"/libs/set_profile.sh
set_profile '/etc/profile'
}
#启动服务
if [ ! -f "$CRASHDIR"/.dis_startup ]; then
if [ ! -f "$CRASHDIR"/.dis_startup ] && [ ! -f "$CRASHDIR"/.start_error ]; then
#AX6S/AX6000修复tun功能
[ -s "$CRASHDIR"/tools/tun.ko ] && tunfix
#小米7000/小米万兆修复tproxy
[ -f /etc/init.d/qca-nss-ecm ] && [ "$redir_mod" = 'Tproxy' ] && tproxyfix
[ -f /etc/init.d/qca-nss-ecm ] && echo "$redir_mod" | grep -q 'Tproxy' && tproxyfix
#自动覆盖根证书文件
[ -s "$CRASHDIR"/tools/ca-certificates.crt ] && cp -f "$CRASHDIR"/tools/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
#启动服务
"$CRASHDIR"/start.sh start
/etc/init.d/shellcrash enable
"$CRASHDIR"/start.sh stop
/etc/init.d/shellcrash start && /etc/init.d/shellcrash enable
fi
#启动自定义服务
[ -s /data/auto_start.sh ] && /bin/sh /data/auto_start.sh &
#兼容auto_ssh脚本
[ -s /data/auto_ssh/auto_ssh.sh ] && /bin/sh /data/auto_ssh/auto_ssh.sh &
}
init(){
#等待启动完成
while ! ip a| grep -q lan; do
sleep 10
done
sleep 20
autoSSH #软固化功能
auto_clean #自动清理
[ -s "$CRASHDIR"/start.sh ] && auto_start
auto_start
#启动自定义服务
[ -s /data/auto_start.sh ] && /bin/sh /data/auto_start.sh &
#兼容auto_ssh脚本
[ -s /data/auto_ssh/auto_ssh.sh ] && /bin/sh /data/auto_ssh/auto_ssh.sh &
}
case "$1" in

View File

@@ -11,3 +11,4 @@ touch "$CRASHDIR"/.start_error #标记启动失败,防止自启
error=$(cat "$TMPDIR"/core_test.log | grep -iEo 'error.*=.*|.*ERROR.*|.*FATAL.*')
logger "服务启动失败!请查看报错信息!详细信息请查看$TMPDIR/core_test.log" 33
logger "$error" 31
"$CRASHDIR"/start.sh stop

View File

@@ -1,18 +1,28 @@
[ -z "$CRASHDIR" ] && CRASHDIR=$( cd $(dirname $0);cd ..;pwd)
[ -z "$CRASHDIR" ] && CRASHDIR=$(cd "$(dirname "$0")"/.. && pwd)
PIDFILE="/tmp/ShellCrash/$1.pid"
[ -f "$CRASHDIR"/.start_error ] && [ ! -f /tmp/ShellCrash/crash_start_time ] && exit 1 #当启动失败后禁止开机自启动
if [ -f "$PIDFILE" ]; then
PID="$(cat "$PIDFILE")"
if [ -n "$PID" ] && kill -0 "$PID" 2>/dev/null; then
if [ -n "$PID" ] && [ "$PID" -eq "$PID" ] 2>/dev/null; then
if kill -0 "$PID" 2>/dev/null || [ -d "/proc/$PID" ]; then
return 0
fi
fi
#如果没有进程则拉起
if [ "$1" = shellcrash ];then
"$CRASHDIR"/start.sh start
else
. "$CRASHDIR"/starts/start_legacy.sh
start_legacy "$CRASHDIR/menus/bot_tg.sh" "$1"
else
rm -f "$PIDFILE"
fi
fi
#如果没有进程则拉起
LOCKDIR="/tmp/ShellCrash/start_$1.lock"
if mkdir "$LOCKDIR" 2>/dev/null; then
if [ "$1" = "shellcrash" ]; then
"$CRASHDIR"/start.sh start
else
[ -f "$CRASHDIR/starts/start_legacy.sh" ] && . "$CRASHDIR/starts/start_legacy.sh"
start_legacy "$CRASHDIR/menus/bot_tg.sh" "$1"
fi
rm -d "$LOCKDIR" 2>/dev/null
fi

View File

@@ -1 +1 @@
1.9.4beta3.1
1.9.4rc6