~调整Tailscale的缓存目录为安装目录,增加设备名称设置选项

~修复部分设备开机初始化失败的bug
~部分代码细节优化
This commit is contained in:
juewuy
2026-01-01 10:43:25 +08:00
parent abb90eb6f0
commit 5aafe92198
9 changed files with 21 additions and 16 deletions

View File

@@ -17,5 +17,5 @@ routing_mark=$((fwmark + 2))
[ -z "$dns_fallback" ] && dns_fallback="1.1.1.1, 8.8.8.8" [ -z "$dns_fallback" ] && dns_fallback="1.1.1.1, 8.8.8.8"
[ -z "$dns_resolver" ] && { [ -z "$dns_resolver" ] && {
dns_resolver="223.5.5.5, 2400:3200::1" dns_resolver="223.5.5.5, 2400:3200::1"
cat /proc/net/udp | grep -q '0035' && dns_resolver='127.0.0.1' cat /proc/net/udp | grep -q '0035' && dns_resolver='127.0.0.1, ::1'
} }

View File

@@ -4,15 +4,16 @@
[ "$ts_service" = ON ] && { [ "$ts_service" = ON ] && {
[ "$ts_subnet" = true ] && advertise_routes='"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"' [ "$ts_subnet" = true ] && advertise_routes='"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"'
[ -z "$ts_exit_node" ] && ts_exit_node=false [ -z "$ts_exit_node" ] && ts_exit_node=false
[ -z "$ts_hostname" ] && ts_hostname='ShellCrash'
cat >"$TMPDIR"/jsons/tailscale.json <<EOF cat >"$TMPDIR"/jsons/tailscale.json <<EOF
{ {
"endpoints": [ "endpoints": [
{ {
"type": "tailscale", "type": "tailscale",
"tag": "ts-ep", "tag": "ts-ep",
"state_directory": "/tmp/ShellCrash/tailscale", "state_directory": "$CRASHDIR/tailscale",
"auth_key": "$ts_auth_key", "auth_key": "$ts_auth_key",
"hostname": "ShellCrash-ts-ep", "hostname": "$ts_hostname",
"advertise_routes": [$advertise_routes], "advertise_routes": [$advertise_routes],
"advertise_exit_node": $ts_exit_node, "advertise_exit_node": $ts_exit_node,
"udp_timeout": "5m" "udp_timeout": "5m"

View File

@@ -480,6 +480,7 @@ set_tailscale(){
echo -e " 2 设置\033[36m秘钥\033[0m(Auth Key) $ts_auth_key_info" echo -e " 2 设置\033[36m秘钥\033[0m(Auth Key) $ts_auth_key_info"
echo -e " 3 通告路由\033[33m内网地址\033[0m(Subnet) \033[36m$ts_subnet\033[0m" echo -e " 3 通告路由\033[33m内网地址\033[0m(Subnet) \033[36m$ts_subnet\033[0m"
echo -e " 4 通告路由\033[31m全部流量\033[0m(EXIT-NODE) \033[36m$ts_exit_node\033[0m" echo -e " 4 通告路由\033[31m全部流量\033[0m(EXIT-NODE) \033[36m$ts_exit_node\033[0m"
echo -e " 5 设置\033[36m设备名称\033[0m(可选) $ts_hostname"
echo -e " 0 返回上级菜单 \033[0m" echo -e " 0 返回上级菜单 \033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
@@ -515,6 +516,11 @@ set_tailscale(){
setconfig ts_exit_node "$ts_exit_node" "$GT_CFG_PATH" setconfig ts_exit_node "$ts_exit_node" "$GT_CFG_PATH"
set_tailscale set_tailscale
;; ;;
5)
read -p "请输入希望在Tailscale显示的设备名称 > " ts_hostname
setconfig ts_hostname "$ts_hostname" "$GT_CFG_PATH"
set_tailscale
;;
*) errornum ;; *) errornum ;;
esac esac
} }

View File

@@ -121,6 +121,7 @@ checkupdate(){
fi fi
rm -rf "$TMPDIR"/version_new rm -rf "$TMPDIR"/version_new
} }
#更新脚本 #更新脚本
getscripts(){ getscripts(){
get_bin "$TMPDIR"/ShellCrash.tar.gz ShellCrash.tar.gz get_bin "$TMPDIR"/ShellCrash.tar.gz ShellCrash.tar.gz
@@ -162,6 +163,7 @@ setscripts(){
exit; exit;
fi fi
} }
#更新内核 #更新内核
setcpucore(){ #手动设置内核架构 setcpucore(){ #手动设置内核架构
cpucore_list="armv5 armv7 arm64 386 amd64 mipsle-softfloat mipsle-hardfloat mips-softfloat" cpucore_list="armv5 armv7 arm64 386 amd64 mipsle-softfloat mipsle-hardfloat mips-softfloat"
@@ -456,6 +458,7 @@ setcore(){ #内核选择菜单
;; ;;
esac esac
} }
#数据库 #数据库
getgeo(){ #下载Geo文件 getgeo(){ #下载Geo文件
#生成链接 #生成链接
@@ -485,7 +488,6 @@ getgeo(){ #下载Geo文件
fi fi
sleep 1 sleep 1
} }
getcustgeo(){ getcustgeo(){
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo "正在获取数据库文件…………" echo "正在获取数据库文件…………"
@@ -505,7 +507,6 @@ getcustgeo(){
fi fi
sleep 1 sleep 1
} }
checkcustgeo(){ checkcustgeo(){
[ "$api_tag" = "latest" ] && api_url=latest || api_url="tags/$api_tag" [ "$api_tag" = "latest" ] && api_url=latest || api_url="tags/$api_tag"
[ ! -s "$TMPDIR"/geo.list ] && { [ ! -s "$TMPDIR"/geo.list ] && {
@@ -610,7 +611,6 @@ setcustgeo() {
esac esac
done done
} }
setgeo() { setgeo() {
while true; do while true; do
. $CFG_PATH > /dev/null . $CFG_PATH > /dev/null
@@ -839,6 +839,7 @@ setdb(){
;; ;;
esac esac
} }
#根证书 #根证书
getcrt(){ getcrt(){
echo "-----------------------------------------------" echo "-----------------------------------------------"

View File

@@ -2,7 +2,7 @@
# Copyright (C) Juewuy # Copyright (C) Juewuy
#初始化目录 #初始化目录
CRASHDIR=$( [ -z "$CRASHDIR" ] && CRASHDIR=$(
cd $(dirname $0) cd $(dirname $0)
pwd pwd
) )

View File

@@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
# Copyright (C) Juewuy # Copyright (C) Juewuy
#初始化目录
[ -z "$CRASHDIR" ] && CRASHDIR=$( cd $(dirname $0);cd ..;pwd) [ -z "$CRASHDIR" ] && CRASHDIR=$( cd $(dirname $0);cd ..;pwd)
. "$CRASHDIR"/libs/get_config.sh . "$CRASHDIR"/libs/get_config.sh
[ -z "$BINDIR" -o -z "$TMPDIR" -o -z "$COMMAND" ] && . "$CRASHDIR"/init.sh >/dev/null 2>&1 [ -z "$BINDIR" -o -z "$TMPDIR" -o -z "$COMMAND" ] && . "$CRASHDIR"/init.sh >/dev/null 2>&1

View File

@@ -2,11 +2,7 @@
# Copyright (C) Juewuy # Copyright (C) Juewuy
#初始化目录 #初始化目录
CRASHDIR=$( [ -z "$CRASHDIR" ] && CRASHDIR=$( cd $(dirname $0);cd ..;pwd)
cd $(dirname $0)
cd ..
pwd
)
profile=/etc/profile profile=/etc/profile
. "$CRASHDIR"/libs/set_profile.sh . "$CRASHDIR"/libs/set_profile.sh
. "$CRASHDIR"/libs/set_cron.sh . "$CRASHDIR"/libs/set_cron.sh

View File

@@ -6,7 +6,7 @@ description="Custom proxy service for ShellCrash"
#获取目录 #获取目录
CRASHDIR=$(cat /etc/profile | grep CRASHDIR | awk -F "\"" '{print $2}') CRASHDIR=$(cat /etc/profile | grep CRASHDIR | awk -F "\"" '{print $2}')
[ -z "$CRASHDIR" ] && CRASHDIR=$(cat ~/.bashrc | grep CRASHDIR | awk -F "\"" '{print $2}') [ -z "$CRASHDIR" ] && CRASHDIR=$(cat ~/.bashrc | grep CRASHDIR | awk -F "\"" '{print $2}')
source ${CRASHDIR}/configs/command.env #加载启动命令和启动目录 . ${CRASHDIR}/configs/command.env #加载启动命令和启动目录
# PID 文件 # PID 文件
pidfile="/run/shellcrash.pid" pidfile="/run/shellcrash.pid"

View File

@@ -30,9 +30,9 @@ tunfix(){
mkdir -p /tmp/overlay mkdir -p /tmp/overlay
mkdir -p /tmp/overlay/upper mkdir -p /tmp/overlay/upper
mkdir -p /tmp/overlay/work mkdir -p /tmp/overlay/work
mount -o noatime,lowerdir=${ko_dir},upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work -t overlay "overlay_mods_only" ${ko_dir} mount -o noatime,lowerdir="$ko_dir",upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work -t overlay "overlay_mods_only" "$ko_dir"
#将tun.ko链接到lib #将tun.ko链接到lib
ln -sf "$CRASHDIR"/tools/tun.ko ${ko_dir}/tun.ko ln -sf "$CRASHDIR"/tools/tun.ko "$ko_dir"/tun.ko
} }
tproxyfix(){ 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 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
@@ -90,7 +90,7 @@ case "$1" in
auto_clean) auto_clean ;; auto_clean) auto_clean ;;
init) init ;; init) init ;;
*) *)
if [ -z $(pidof CrashCore) ];then if [ -z "$(pidof CrashCore)" ];then
init & init &
fi fi
;; ;;