feat: add install script

This commit is contained in:
SunBK201 2023-12-04 22:43:40 +08:00
parent 22f6868965
commit fe6bd6b1e6
2 changed files with 57 additions and 1 deletions

View File

@ -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 <port> -f <UA> -b <bind addr>
/root/ua3f -p <port> -f <UA> -b <bind addr>
```
### 作为后台服务运行

51
install.sh Normal file
View File

@ -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