Fixed memory consumption
This commit is contained in:
parent
c01ddf4940
commit
d0a682f1a3
@ -632,17 +632,21 @@ core_update() {
|
||||
esac
|
||||
url="$MIHOMO_BASE/mihomo-linux-$arch-$MIHOMO_VERSION.gz"
|
||||
log "updating mihomo core ${cur:-none} -> $MIHOMO_VERSION"
|
||||
# a failed download keeps the current core: fix/update still start nikki
|
||||
rm -f /tmp/mihomo.gz /tmp/mihomo
|
||||
if ! curl -fL -o /tmp/mihomo.gz "$url" || ! gunzip -f /tmp/mihomo.gz || ! chmod +x /tmp/mihomo ||
|
||||
[ "$(/tmp/mihomo -v 2>/dev/null | awk '{print $3; exit}')" != "$MIHOMO_VERSION" ]; then
|
||||
rm -f /tmp/mihomo.gz /tmp/mihomo
|
||||
log "warning: core $MIHOMO_VERSION not installed (download or check failed: $url), keeping ${cur:-the current one}"
|
||||
# Streamed straight next to the binary: /tmp is RAM, and the unpacked core
|
||||
# (~56 MB) plus the .gz do not fit on small routers. No .bak copy either (flash
|
||||
# space); an older core comes back with MIHOMO_VERSION in /etc/nikki/kit.env + fix.
|
||||
# A failed download keeps the current core: fix/update still start nikki.
|
||||
bin=$(command -v mihomo || echo /usr/bin/mihomo)
|
||||
new=$bin.new
|
||||
rm -f "$new" "$bin.bak" /tmp/mihomo.gz /tmp/mihomo
|
||||
if ! curl -fsSL "$url" | gunzip > "$new" || ! chmod +x "$new" ||
|
||||
[ "$("$new" -v 2>/dev/null | awk '{print $3; exit}')" != "$MIHOMO_VERSION" ]; then
|
||||
rm -f "$new"
|
||||
log "warning: core $MIHOMO_VERSION not installed (download, unpack or check failed: $url;" \
|
||||
"free space in ${bin%/*}: $(df -h "${bin%/*}" 2>/dev/null | awk 'NR==2 {print $4}')), keeping ${cur:-the current one}"
|
||||
return 1
|
||||
fi
|
||||
bin=$(command -v mihomo || echo /usr/bin/mihomo)
|
||||
[ -f "$bin" ] && cp "$bin" "$bin.bak"
|
||||
mv /tmp/mihomo "$bin"
|
||||
mv "$new" "$bin"
|
||||
log "core: $(mihomo -v | head -n 1)"
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user