v1.6.4
~适配华硕官方固件(自启需插入任意USB设备) ~优化梅林固件自启逻辑 ~优化小米设备安装目录选择 ~增加安装到外置存储选项 ~修复部分设备时间显示异常的bug ~修复部分设备环境变量配置重复的bug
This commit is contained in:
Binary file not shown.
@@ -2,5 +2,5 @@ clashnet_v=v1.7.6
|
|||||||
clashpre_v=2021.09.15
|
clashpre_v=2021.09.15
|
||||||
clash_v=v1.7.1
|
clash_v=v1.7.1
|
||||||
meta_v=v1.12.0
|
meta_v=v1.12.0
|
||||||
versionsh=1.6.3
|
|
||||||
GeoIP_v=20220920
|
GeoIP_v=20220920
|
||||||
|
versionsh=1.6.4
|
||||||
|
|||||||
95
install.sh
95
install.sh
@@ -16,13 +16,17 @@ setconfig(){
|
|||||||
configpath=$clashdir/mark
|
configpath=$clashdir/mark
|
||||||
[ -n "$(grep ${1} $configpath)" ] && sed -i "s#${1}=.*#${1}=${2}#g" $configpath || echo "${1}=${2}" >> $configpath
|
[ -n "$(grep ${1} $configpath)" ] && sed -i "s#${1}=.*#${1}=${2}#g" $configpath || echo "${1}=${2}" >> $configpath
|
||||||
}
|
}
|
||||||
[ -f "/etc/storage/started_script.sh" ] && systype=Padavan && initdir='/etc/storage/started_script.sh'
|
#特殊固件识别及标记
|
||||||
[ -d "/jffs" ] && systype=asusrouter && {
|
[ -f "/etc/storage/started_script.sh" ] && {
|
||||||
|
systype=Padavan #老毛子固件
|
||||||
|
initdir='/etc/storage/started_script.sh'
|
||||||
|
}
|
||||||
|
[ -d "/jffs" ] && {
|
||||||
|
systype=asusrouter #华硕固件
|
||||||
[ -f "/jffs/.asusrouter" ] && initdir='/jffs/.asusrouter'
|
[ -f "/jffs/.asusrouter" ] && initdir='/jffs/.asusrouter'
|
||||||
[ -d "/jffs/scripts" ] && initdir='/jffs/scripts/nat-start'
|
[ -d "/jffs/scripts" ] && initdir='/jffs/scripts/nat-start'
|
||||||
[ -z "$initdir" ] && initdir='/jffs/scripts/nat-start' && mkdir -p '/jffs/scripts'
|
|
||||||
}
|
}
|
||||||
[ -f "/data/etc/crontabs/root" -a "$(dir_avail /etc)" = 0 ] && systype=mi_snapshot
|
[ -f "/data/etc/crontabs/root" ] && systype=mi_wifi #小米设备
|
||||||
#检查root权限
|
#检查root权限
|
||||||
if [ "$USER" != "root" -a -z "$systype" ];then
|
if [ "$USER" != "root" -a -z "$systype" ];then
|
||||||
echo 当前用户:$USER
|
echo 当前用户:$USER
|
||||||
@@ -132,13 +136,15 @@ gettar(){
|
|||||||
echo 无法写入环境变量!请检查安装权限!
|
echo 无法写入环境变量!请检查安装权限!
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
#华硕/Padavan额外设置
|
#梅林/Padavan额外设置
|
||||||
[ -n "$initdir" ] && {
|
[ -n "$initdir" ] && {
|
||||||
sed -i '/ShellClash初始化/'d $initdir && touch $initdir && echo "$clashdir/start.sh init #ShellClash初始化脚本" >> $initdir
|
sed -i '/ShellClash初始化/'d $initdir
|
||||||
|
touch $initdir
|
||||||
|
echo "$clashdir/start.sh init #ShellClash初始化脚本" >> $initdir
|
||||||
setconfig initdir $initdir
|
setconfig initdir $initdir
|
||||||
}
|
}
|
||||||
#小米镜像化OpenWrt额外设置
|
#小米镜像化OpenWrt额外设置
|
||||||
if [ "$systype" = "mi_snapshot" ];then
|
if [ "$systype" = "mi_wifi" ];then
|
||||||
chmod 755 $clashdir/misnap_init.sh
|
chmod 755 $clashdir/misnap_init.sh
|
||||||
uci set firewall.ShellClash=include
|
uci set firewall.ShellClash=include
|
||||||
uci set firewall.ShellClash.type='script'
|
uci set firewall.ShellClash.type='script'
|
||||||
@@ -150,6 +156,12 @@ gettar(){
|
|||||||
rm -rf $clashdir/misnap_init.sh
|
rm -rf $clashdir/misnap_init.sh
|
||||||
rm -rf $clashdir/clashservice
|
rm -rf $clashdir/clashservice
|
||||||
fi
|
fi
|
||||||
|
#华硕USB启动额外设置
|
||||||
|
[ "$usb_status" = "1" ] && {
|
||||||
|
echo "$clashdir/start.sh init #ShellClash初始化脚本" > $clashdir/asus_usb_mount.sh
|
||||||
|
nvram set script_usbmount="$clashdir/asus_usb_mount.sh"
|
||||||
|
nvram commit
|
||||||
|
}
|
||||||
#删除临时文件
|
#删除临时文件
|
||||||
rm -rf /tmp/clashfm.tar.gz
|
rm -rf /tmp/clashfm.tar.gz
|
||||||
rm -rf $clashdir/clash.service
|
rm -rf $clashdir/clash.service
|
||||||
@@ -168,17 +180,74 @@ $echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理!!!\033
|
|||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
}
|
}
|
||||||
setdir(){
|
setdir(){
|
||||||
|
set_usb_dir(){
|
||||||
|
$echo "请选择安装目录"
|
||||||
|
du -hL /mnt | awk '{print " "NR" "$2" "$1}'
|
||||||
|
read -p "请输入相应数字 > " num
|
||||||
|
dir=$(du -hL /mnt | awk '{print $2}' | sed -n "$num"p)
|
||||||
|
if [ -z "$dir" ];then
|
||||||
|
$echo "\033[31m输入错误!请重新设置!\033[0m"
|
||||||
|
set_usb_dir
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo -----------------------------------------------
|
||||||
if [ -n "$systype" ];then
|
if [ -n "$systype" ];then
|
||||||
[ "$systype" = "Padavan" ] && dir=/etc/storage
|
[ "$systype" = "Padavan" ] && dir=/etc/storage
|
||||||
[ "$systype" = "asusrouter" ] && dir=/jffs
|
[ "$systype" = "mi_wifi" ] && {
|
||||||
[ "$systype" = "mi_snapshot" ] && dir=/data
|
$echo "\033[33m检测到当前设备为小米官方系统,请选择安装位置\033[0m"
|
||||||
else
|
$echo " 1 安装到/data目录(推荐,支持软固化功能)"
|
||||||
|
$echo " 2 安装到USB设备(支持软固化功能)"
|
||||||
|
[ "$(dir_avail /etc)" != 0 ] && $echo " 3 安装到/etc目录(不推荐)"
|
||||||
|
$echo " 0 退出安装"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
|
read -p "请输入相应数字 > " num
|
||||||
|
case "$num" in
|
||||||
|
1)
|
||||||
|
dir=/data
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
set_usb_dir ;;
|
||||||
|
3)
|
||||||
|
if [ "$(dir_avail /etc)" != 0 ];then
|
||||||
|
dir=/etc
|
||||||
|
systype=""
|
||||||
|
else
|
||||||
|
$echo "\033[31m你的设备不支持安装到/etc目录,已改为安装到/data\033[0m"
|
||||||
|
dir=data
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
exit 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
[ "$systype" = "asusrouter" ] && {
|
||||||
|
$echo "\033[33m检测到当前设备为华硕固件,请选择安装方式\033[0m"
|
||||||
|
$echo " 1 基于USB设备安装(通用,须插入\033[31m任意\033[0mUSB设备)"
|
||||||
|
$echo " 2 基于自启脚本安装(仅支持梅林及部分官改固件)"
|
||||||
|
$echo " 0 退出安装"
|
||||||
|
echo -----------------------------------------------
|
||||||
|
read -p "请输入相应数字 > " num
|
||||||
|
case "$num" in
|
||||||
|
1)
|
||||||
|
read -p "将脚本安装到USB存储/系统闪存?(1/0) > " res
|
||||||
|
[ "$res" = "1" ] && set_usb_dir || dir=/jffs
|
||||||
|
usb_status=1
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
$echo "如无法正常开机启动,请重新使用USB方式安装!"
|
||||||
|
sleep 2
|
||||||
|
dir=/jffs ;;
|
||||||
|
*)
|
||||||
|
exit 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
else
|
||||||
$echo "\033[33m安装ShellClash至少需要预留约1MB的磁盘空间\033[0m"
|
$echo "\033[33m安装ShellClash至少需要预留约1MB的磁盘空间\033[0m"
|
||||||
$echo " 1 在\033[32m/etc目录\033[0m下安装(适合root用户)"
|
$echo " 1 在\033[32m/etc目录\033[0m下安装(适合root用户)"
|
||||||
$echo " 2 在\033[32m/usr/share目录\033[0m下安装(适合Linux设备)"
|
$echo " 2 在\033[32m/usr/share目录\033[0m下安装(适合Linux系统)"
|
||||||
$echo " 3 在\033[32m当前用户目录\033[0m下安装(适合非root用户)"
|
$echo " 3 在\033[32m当前用户目录\033[0m下安装(适合非root用户)"
|
||||||
$echo " 4 手动设置安装目录"
|
$echo " 4 在\033[32m外置存储\033[0m中安装"
|
||||||
|
$echo " 5 手动设置安装目录"
|
||||||
$echo " 0 退出安装"
|
$echo " 0 退出安装"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
read -p "请输入相应数字 > " num
|
read -p "请输入相应数字 > " num
|
||||||
@@ -194,6 +263,8 @@ else
|
|||||||
dir=~/.local/share
|
dir=~/.local/share
|
||||||
mkdir -p ~/.config/systemd/user
|
mkdir -p ~/.config/systemd/user
|
||||||
elif [ "$num" = "4" ];then
|
elif [ "$num" = "4" ];then
|
||||||
|
set_usb_dir
|
||||||
|
elif [ "$num" = "5" ];then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo '可用路径 剩余空间:'
|
echo '可用路径 剩余空间:'
|
||||||
df -h | awk '{print $6,$4}'| sed 1d
|
df -h | awk '{print $6,$4}'| sed 1d
|
||||||
|
|||||||
@@ -1630,6 +1630,8 @@ case "$1" in
|
|||||||
rm -rf /tmp/clash_$USER
|
rm -rf /tmp/clash_$USER
|
||||||
sed -Ei s/0:7890/7890:7890/g /etc/passwd
|
sed -Ei s/0:7890/7890:7890/g /etc/passwd
|
||||||
userdel -r shellclash 2>/dev/null
|
userdel -r shellclash 2>/dev/null
|
||||||
|
nvram set script_usbmount="" 2>/dev/null
|
||||||
|
nvram commit 2>/dev/null
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[36m已卸载ShellClash相关文件!有缘再会!\033[0m"
|
echo -e "\033[36m已卸载ShellClash相关文件!有缘再会!\033[0m"
|
||||||
echo -e "\033[33m请手动关闭当前窗口以重置环境变量!\033[0m"
|
echo -e "\033[33m请手动关闭当前窗口以重置环境变量!\033[0m"
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ clashdir=/data/clash
|
|||||||
profile=/etc/profile
|
profile=/etc/profile
|
||||||
|
|
||||||
#h初始化环境变量
|
#h初始化环境变量
|
||||||
if [ `type -t clash` != "alias" ];then
|
sed -i "/alias clash/d" $profile
|
||||||
|
sed -i "/export clashdir/d" $profile
|
||||||
echo "alias clash=\"$clashdir/clash.sh\"" >> $profile
|
echo "alias clash=\"$clashdir/clash.sh\"" >> $profile
|
||||||
fi
|
|
||||||
if [ -z $clashdir ];then
|
|
||||||
echo "export clashdir=\"$clashdir\"" >> $profile
|
echo "export clashdir=\"$clashdir\"" >> $profile
|
||||||
fi
|
|
||||||
#设置init.d服务并启动clash服务
|
#设置init.d服务并启动clash服务
|
||||||
ln -sf $clashdir/clashservice /etc/init.d/clash
|
ln -sf $clashdir/clashservice /etc/init.d/clash
|
||||||
chmod 755 /etc/init.d/clash
|
chmod 755 /etc/init.d/clash
|
||||||
|
|||||||
@@ -986,21 +986,28 @@ restart)
|
|||||||
$0 start
|
$0 start
|
||||||
;;
|
;;
|
||||||
init)
|
init)
|
||||||
|
sleep 30
|
||||||
if [ -d "/etc/storage/clash" ];then
|
if [ -d "/etc/storage/clash" ];then
|
||||||
clashdir=/etc/storage/clash
|
clashdir=/etc/storage/clash
|
||||||
i=1
|
i=1
|
||||||
while [ ! -w "/etc/profile" -a "$i" -lt 60 ];do
|
while [ ! -w "/etc/profile" -a "$i" -lt 7 ];do
|
||||||
sleep 1 && i=$((i+1))
|
sleep 5 && i=$((i+1))
|
||||||
done
|
done
|
||||||
profile=/etc/profile
|
profile=/etc/profile
|
||||||
sed -i '' $profile #将软链接转化为一般文件
|
sed -i '' $profile #将软链接转化为一般文件
|
||||||
elif [ -d "/jffs/clash" ];then
|
elif [ -d "/jffs/clash" ];then
|
||||||
clashdir=/jffs/clash
|
clashdir=/jffs/clash
|
||||||
profile=/jffs/configs/profile.add
|
if [ -w /etc/profile ];then
|
||||||
|
profile=/etc/profile
|
||||||
|
else
|
||||||
|
profile=$(cat /etc/profile | grep -oE '\-f.*jffs.*profile' | awk '{print $2}')
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
clashdir=$(cd $(dirname $0);pwd)
|
clashdir=$(cd $(dirname $0);pwd)
|
||||||
profile=/etc/profile
|
profile=/etc/profile
|
||||||
fi
|
fi
|
||||||
|
sed -i "/alias clash/d" $profile
|
||||||
|
sed -i "/export clashdir/d" $profile
|
||||||
echo "alias clash=\"$clashdir/clash.sh\"" >> $profile
|
echo "alias clash=\"$clashdir/clash.sh\"" >> $profile
|
||||||
echo "export clashdir=\"$clashdir\"" >> $profile
|
echo "export clashdir=\"$clashdir\"" >> $profile
|
||||||
[ -f $clashdir/.dis_startup ] && cronset "clash保守模式守护进程" || $0 start
|
[ -f $clashdir/.dis_startup ] && cronset "clash保守模式守护进程" || $0 start
|
||||||
|
|||||||
Reference in New Issue
Block a user