From 43c10c5c43c1cf1d00b21931eeeb77c1609677d2 Mon Sep 17 00:00:00 2001 From: SunBK201 Date: Mon, 4 Dec 2023 22:43:40 +0800 Subject: [PATCH] feat: add install script --- README.md | 7 ++++++- install.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 install.sh diff --git a/README.md b/README.md index 1fff26f..32dc420 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,11 @@ UA3F 是新一代 HTTP User-Agent 修改方法,对外作为一个 SOCK5 服务 [Release](https://github.com/SunBK201/UA3F/releases) 页面已经提供常见架构的编译版本,可以根据自己架构下载并解压到路由器等设备上。 +安装(升级)脚本: +```bash +export url='https://blog.sunbk201.site/cdn' && sh -c "$(curl -kfsSl $url/install.sh)" +``` + ## 使用 参数: @@ -17,7 +22,7 @@ UA3F 是新一代 HTTP User-Agent 修改方法,对外作为一个 SOCK5 服务 ### 手动启动 ```bash -ua3f -p -f -b +/root/ua3f -p -f -b ``` ### 作为后台服务运行 diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..a58f198 --- /dev/null +++ b/install.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +getcpucore() { + cputype=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]') + [ -n "$(echo $cputype | grep -E "linux.*armv.*")" ] && cpucore="armv5" + [ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && [ ! -d /jffs/clash ] && cpucore="armv7" + [ -n "$(echo $cputype | grep -E "linux.*aarch64.*|linux.*armv8.*")" ] && cpucore="armv8" + [ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="386" + [ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="amd64" + if [ -n "$(echo $cputype | grep -E "linux.*mips.*")" ]; then + mipstype=$(echo -n I | hexdump -o 2>/dev/null | awk '{ print substr($2,6,1); exit}') + [ "$mipstype" = "0" ] && cpucore="mips-softfloat" || cpucore="mipsle-softfloat" + fi +} + +cd /root +getcpucore + +version=0.0.4 +ua3f_tar=ua3f-$version-$cpucore.tar.gz + +if [ -f "ua3f" ]; then + rm "ua3f" +fi + +if [ -f "$ua3f_tar" ]; then + rm "$ua3f_tar" +fi + +wget https://fastly.jsdelivr.net/gh/SunBK201/UA3F@master/release/$ua3f_tar +if [ $? -ne 0 ]; then + echo "Download UA3F Failed, Please Retry." + exit 1 +fi +tar zxf $ua3f_tar && rm -f $ua3f_tar +chmod +x ua3f + +if [ -f "ua3f.service" ]; then + rm "ua3f.service" +fi +wget https://fastly.jsdelivr.net/gh/SunBK201/UA3F@master/ua3f.service +if [ $? -ne 0 ]; then + echo "Download ua3f.service Failed, Please Retry." + exit 1 +fi +mv ua3f.service /etc/init.d/ && chmod +x /etc/init.d/ua3f.service +/etc/init.d/ua3f.service enable + +if [ $? -eq 0 ]; then + echo "Install UA3F Success." +fi \ No newline at end of file