From e73cba9713de8f7e4cdbde6ab4a459092e331225 Mon Sep 17 00:00:00 2001 From: SunBK201 Date: Sun, 10 Dec 2023 17:44:21 +0800 Subject: [PATCH] fix: sudo does not exist --- cmd/ua3f.go | 2 +- install.sh | 6 +++++- ua3f.service | 10 +++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/ua3f.go b/cmd/ua3f.go index 68c4d24..316846d 100644 --- a/cmd/ua3f.go +++ b/cmd/ua3f.go @@ -220,7 +220,7 @@ func CopyPileline(dst io.Writer, src io.Reader) { buf[start+i] = payloadByte[i] } } else { - logrus.Debug(fmt.Sprintf("[%s] Not found User-Agent", string(parser.Host()))) + logrus.Debug(fmt.Sprintf("[%s] Not found User-Agent, Add LRU Relay Cache", string(parser.Host()))) dst.Write(buf[0:nr]) io.Copy(dst, src) cache.Add(string(dst.(*net.TCPConn).RemoteAddr().String()), string(dst.(*net.TCPConn).RemoteAddr().String())) diff --git a/install.sh b/install.sh index c88e4ab..d6560b7 100755 --- a/install.sh +++ b/install.sh @@ -21,7 +21,11 @@ ua3f_tar=ua3f-$version-$cpucore.tar.gz if [ -f "ua3f" ]; then rm "ua3f" - killall ua3f >/dev/null 2>&1 + killall ua3f &> /dev/null +fi + +if ! command -v sudo &> /dev/null then + opkg update &> /dev/null && opkg install sudo &> /dev/null fi chmod ugo+w /var/log diff --git a/ua3f.service b/ua3f.service index e1b1a3a..60e3201 100755 --- a/ua3f.service +++ b/ua3f.service @@ -4,12 +4,12 @@ START=99 start() { echo "ua3f is starting" - if id -u shellclash >/dev/null 2>&1; then - sudo -u shellclash /root/ua3f >/dev/null 2>&1 & - elif id -u nobody >/dev/null 2>&1; then - sudo -u nobody /root/ua3f >/dev/null 2>&1 & + if id -u shellclash &> /dev/null; then + sudo -u shellclash /root/ua3f &> /dev/null & + elif id -u nobody &> /dev/null; then + sudo -u nobody /root/ua3f &> /dev/null & else - /root/ua3f >/dev/null 2>&1 & + /root/ua3f &> /dev/null & fi }