diff --git a/bin/clashfm.tar.gz b/bin/clashfm.tar.gz index 70cd90d..cc5bc0e 100644 Binary files a/bin/clashfm.tar.gz and b/bin/clashfm.tar.gz differ diff --git a/bin/version b/bin/version index e640fc7..b1865dd 100644 --- a/bin/version +++ b/bin/version @@ -1,4 +1,4 @@ clash_v=1.2.0 clashpre_v=2020.10.09 GeoIP_v=20201021 -versionsh=1.0.0beta15.1 +versionsh=1.0.0beta15.2 diff --git a/install.sh b/install.sh index 5958784..f0b23f2 100644 --- a/install.sh +++ b/install.sh @@ -11,13 +11,19 @@ echo "** by Juewuy **" echo "***********************************************" #检查root权限 -[ "$USER" != "root" ] && [ "$USER" != "admin" ] && echo 请使用root用户执行安装!&& exit 1 +if [ "$USER" != "root" ];then + echo 当前用户:$USER + $echo "\033[31m请尽量使用root用户执行安装!\033[0m" + echo ----------------------------------------------- + read -p "仍要安装?可能会产生未知错误!(1/0) > " res + [ "$res" != "1" ] && exit +fi #检查更新 url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash" if [ "$test" -gt 0 ];then url="--resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master" - [ "$test" -eq 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi" && echo $url + [ "$test" -eq 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi" [ "$test" -eq 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi" else release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') #检查版本 @@ -43,14 +49,13 @@ gettar(){ mv $clashdir/clashservice /etc/init.d/clash chmod 777 /etc/init.d/clash else - [ -d /etc/systemd/system/ ] && sysdir=/etc/systemd/system/ - [ -d /usr/lib/systemd/system/ ] && sysdir=/usr/lib/systemd/system/ + [ -w /etc/systemd/system ] && sysdir=/etc/systemd/system + [ -w /usr/lib/systemd/system ] && sysdir=/usr/lib/systemd/system if [ -n "$sysdir" ];then #设为systemd方式启动 mv $clashdir/clash.service $sysdir/clash.service sed -i "s%/etc/clash%$clashdir%g" $sysdir/clash.service systemctl daemon-reload - rm -rf /etc/init.d/clash else #设为保守模式启动 sed -i '/start_old=*/'d $clashdir/mark @@ -64,10 +69,12 @@ gettar(){ sed -i '/versionsh_l=*/'d $clashdir/mark sed -i "1i\versionsh_l=$release_new" $clashdir/mark #设置环境变量 - sed -i '/alias clash=*/'d /etc/profile - echo "alias clash=\"$shtype $clashdir/clash.sh\"" >> /etc/profile #设置快捷命令环境变量 - sed -i '/export clashdir=*/'d /etc/profile - echo "export clashdir=\"$clashdir\"" >> /etc/profile #设置clash路径环境变量 + [ -w $HOME/.bashrc ] && profile=$HOME/.bashrc + [ -w /etc/profile ] && profile=/etc/profile + sed -i '/alias clash=*/'d $profile + echo "alias clash=\"$shtype $clashdir/clash.sh\"" >> $profile #设置快捷命令环境变量 + sed -i '/export clashdir=*/'d $profile + echo "export clashdir=\"$clashdir\"" >> $profile #设置clash路径环境变量 #删除临时文件 rm -rf /tmp/clashfm.tar.gz rm -rf $clashdir/clashservice @@ -86,10 +93,13 @@ $echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理!!!\033 echo ----------------------------------------------- } setdir(){ -echo ----------------------------------------------- -$echo "\033[32m 1 在默认目录(/etc)安装" -$echo "\033[33m 2 手动设置安装目录" -$echo "\033[0m 0 退出安装" +echo ----------------------------------------------- +$echo "\033[33m安装ShellClash至少需要预留约10MB的磁盘空间\033[0m" +$echo " 1 在\033[32m/etc目录\033[0m下安装(适合路由设备)" +$echo " 2 在\033[32m/usr/share目录\033[0m下安装(适合大多数设备)" +$echo " 3 在\033[32m当前用户目录\033[0m下安装(适合非root用户)" +$echo " 4 手动设置安装目录" +$echo " 0 退出安装" echo ----------------------------------------------- read -p "请输入相应数字 > " num #设置目录 @@ -99,19 +109,27 @@ if [ -z $num ];then elif [ "$num" = "1" ];then dir=/etc elif [ "$num" = "2" ];then + dir=/usr/share +elif [ "$num" = "3" ];then + dir=$HOME/.local/share + mkdir -p $HOME/.config/systemd/user +elif [ "$num" = "4" ];then echo ----------------------------------------------- echo '可用路径 剩余空间:' - df -h | awk '{print $6,$2}'| sed 1d + df -h | awk '{print $6,$4}'| sed 1d echo '路径是必须带 / 的格式,写入虚拟内存(/tmp,/sys,..)的文件会在重启后消失!!!' read -p "请输入自定义路径 > " dir if [ -z "$dir" ];then - $echo "\033[31m路径错误!已取消安装!\033[0m" - exit; + $echo "\033[31m路径错误!请重新设置!\033[0m" + setdir fi else echo 安装已取消!!! exit; fi +echo 目标目录磁盘剩余:$(df -h $dir | awk '{print $4}' | sed 1d ) +read -p "确认安装?(1/0) > " res +[ "$res" != "1" ] && setdir clashdir=$dir/clash install } @@ -135,6 +153,9 @@ if [ -n "$clashdir" ];then echo ----------------------------------------------- $echo "\033[31m 旧版本文件已卸载!\033[0m" setdir + elif [ "$res" = "9" ];then + echo 测试模式,变更安装位置 + setdir else $echo "\033[31m输入错误!已取消安装!\033[0m" exit; diff --git a/scripts/getdate.sh b/scripts/getdate.sh index 982a46e..72c3923 100644 --- a/scripts/getdate.sh +++ b/scripts/getdate.sh @@ -573,9 +573,11 @@ echo ----------------------------------------------- echo -e " 0 返回上级菜单" read -p "请输入对应数字 > " num if [ "$num" = '1' ]; then - echo 'function FindProxyForURL(url, host) {' > $dir/pac - echo " return \"SOCKS $authentication@$host:$mix_port; PROXY $authentication@$host:$mix_port; DIRECT;\"" >> $dir/pac - echo '}' >> $dir/pac + cat > $dir/pac <