mirror of
https://github.com/juewuy/ShellCrash.git
synced 2024-11-16 03:32:34 +08:00
v1.5.5
~全面适配ax6s等小米镜像化系统设备 ·支持procd守护进程 ·支持设置开机启动 ·支持自动开启SSH及备份还原SSH秘钥 ~重做小米SSH工具,现在支持各类小米路由设备软件固化SSH(待测试) ~重写自启逻辑,现在支持Padavan、梅林开关开机启动功能 ~同步最新版本数据库文件 ~同步最新版本Dashboard面板
This commit is contained in:
parent
56d1eb3a32
commit
3ee6aebe62
39
install.sh
39
install.sh
|
@ -12,6 +12,10 @@ echo "***********************************************"
|
|||
dir_avail(){
|
||||
df -h $1 |awk '{ for(i=1;i<=NF;i++){ if(NR==1){ arr[i]=$i; }else{ arr[i]=arr[i]" "$i; } } } END{ for(i=1;i<=NF;i++){ print arr[i]; } }' |grep Ava |awk '{print $2}'
|
||||
}
|
||||
setconfig(){
|
||||
configpath=$clashdir/mark
|
||||
[ -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/scripts" ] && systype=asusrouter && initdir='/jffs/scripts/net-start'
|
||||
[ -f "/jffs/.asusrouter" ] && systype=asusrouter && initdir='/jffs/.asusrouter'
|
||||
|
@ -89,8 +93,8 @@ gettar(){
|
|||
#判断系统类型写入不同的启动文件
|
||||
if [ -f /etc/rc.common ];then
|
||||
#设为init.d方式启动
|
||||
mv $clashdir/clashservice /etc/init.d/clash
|
||||
chmod 777 /etc/init.d/clash
|
||||
cp -f $clashdir/clashservice /etc/init.d/clash
|
||||
chmod 755 /etc/init.d/clash
|
||||
else
|
||||
[ -w /etc/systemd/system ] && sysdir=/etc/systemd/system
|
||||
[ -w /usr/lib/systemd/system ] && sysdir=/usr/lib/systemd/system
|
||||
|
@ -101,19 +105,16 @@ gettar(){
|
|||
systemctl daemon-reload
|
||||
else
|
||||
#设为保守模式启动
|
||||
sed -i '/start_old=*/'d $clashdir/mark
|
||||
echo start_old=已开启 >> $clashdir/mark
|
||||
setconfig start_old 已开启
|
||||
fi
|
||||
fi
|
||||
#修饰文件及版本号
|
||||
shtype=sh && [ -n "$(ls -l /bin/sh|grep -oE 'dash|show|bash')" ] && shtype=bash
|
||||
sed -i "s|/bin/sh|/bin/$shtype|" $clashdir/start.sh
|
||||
chmod 777 $clashdir/start.sh
|
||||
sed -i '/versionsh_l=*/'d $clashdir/mark
|
||||
echo versionsh_l=$release_new >> $clashdir/mark
|
||||
chmod 755 $clashdir/start.sh
|
||||
setconfig versionsh_l $release_new
|
||||
#设置更新地址
|
||||
sed -i '/update_url=*/'d $clashdir/mark
|
||||
echo update_url=$url >> $clashdir/mark
|
||||
[ -n "$url" ] && setconfig update_url $url
|
||||
#设置环境变量
|
||||
[ -w /opt/etc/profile ] && profile=/opt/etc/profile
|
||||
[ -w /jffs/configs/profile.add ] && profile=/jffs/configs/profile.add
|
||||
|
@ -129,17 +130,25 @@ gettar(){
|
|||
exit 1
|
||||
fi
|
||||
#华硕/Padavan额外设置
|
||||
[ -n "$initdir" ] && sed -i '/ShellClash初始化/'d $initdir && touch $initdir && echo "$clashdir/start.sh init #ShellClash初始化脚本" >> $initdir
|
||||
[ -n "$initdir" ] && {
|
||||
sed -i '/ShellClash初始化/'d $initdir && touch $initdir && echo "$clashdir/start.sh init #ShellClash初始化脚本" >> $initdir
|
||||
setconfig initdir $initdir
|
||||
}
|
||||
#小米镜像化OpenWrt额外设置
|
||||
if [ "$systype" = "mi_snapshot" ];then
|
||||
echo "*/1 * * * * test -z \"\$(pidof clash)\" && $clashdir/start.sh init #ShellClash初始化及守护进程" >> /data/etc/crontabs/root
|
||||
sed -i '/start_old=*/'d $clashdir/mark
|
||||
echo start_old=已开启 >> $clashdir/mark
|
||||
rm -rf /etc/init.d/clash
|
||||
chmod 755 $clashdir/misnap_init.sh
|
||||
uci set firewall.ShellClash=include
|
||||
uci set firewall.ShellClash.type='script'
|
||||
uci set firewall.ShellClash.path='/data/clash/misnap_init.sh'
|
||||
uci set firewall.ShellClash.enabled='1'
|
||||
uci commit firewall
|
||||
setconfig systype $systype
|
||||
else
|
||||
rm -rf $clashdir/misnap_init.sh
|
||||
rm -rf $clashdir/clashservice
|
||||
fi
|
||||
#删除临时文件
|
||||
rm -rf /tmp/clashfm.tar.gz
|
||||
rm -rf $clashdir/clashservice
|
||||
rm -rf $clashdir/clash.service
|
||||
}
|
||||
#下载及安装
|
||||
|
|
|
@ -894,7 +894,7 @@ init)
|
|||
fi
|
||||
echo "alias clash=\"$clashdir/clash.sh\"" >> $profile
|
||||
echo "export clashdir=\"$clashdir\"" >> $profile
|
||||
[ -f $clashdir/.dis_startup ] || $0 start
|
||||
[ -f $clashdir/.dis_startup ] && cronset "clash保守模式守护进程" || $0 start
|
||||
;;
|
||||
getyaml)
|
||||
getconfig
|
||||
|
|
Loading…
Reference in New Issue
Block a user