もっと自動化

This commit is contained in:
2026-05-20 01:12:56 +09:00
parent 62326874ce
commit f315fa45ef
23 changed files with 406 additions and 141 deletions

View File

@@ -1,15 +1,45 @@
#!/bin/sh
export VER="0.16.0"
export ARC="x86_64"
export OS="openbsd"
OS="$(uname -s)"
case "$OS" in
FreeBSD) OS="freebsd" ;;
OpenBSD) OS="openbsd" ;;
Linux) OS="linux" ;;
Darwin) OS="macos" ;;
*) exit 1;;
esac
wget https://ziglang.org/download/$VER/zig-$ARC-$OS-$VER.tar.xz
xzcat zig-$ARC-$OS-$VER.tar.xz | tar xf -
cd zig-$ARC-$OS-$VER
rm -rf /usr/local/lib/zig
mv lib /usr/local/lib/zig
mv zig /usr/local/bin
cd ..
rm -rf zig-$ARC-$OS-$VER zig-$ARC-$OS-$VER*
zig version
ARC="$(uname -m)"
case "$ARC" in
x86_64|amd64) ARC="x86_64" ;;
aarch64|arm64) ARC="aarch64" ;;
*) exit 1 ;;
esac
IP=$(ifconfig wg0 | awk '/inet / {print $2; exit}')
VER=$(wget -qO- https://ziglang.org/download/index.json |
sed 's/[",:]//g' |
awk '/^[[:space:]]*[0-9]+\.[0-9]+/ {print $1; exit}')
CURVER=$(zig version)
DATE=$(date +"%Y年%m月%d日")
echo "${IP} サーバーZigバージョンが更新されました。${DATE}
---------------
" > /root/zig.txt
if [ "$VER" = "$CURVER" ]; then
echo "最新Zigバージョンが既にインストールされています。" >> /root/zig.txt
else
wget https://ziglang.org/download/$VER/zig-$ARC-$OS-$VER.tar.xz >> /root/zig.txt
xzcat zig-$ARC-$OS-$VER.tar.xz | tar xf - >> /root/zig.txt
cd zig-$ARC-$OS-$VER
rm -rfv /usr/local/lib/zig >> /root/zig.txt
mv -v lib /usr/local/lib/zig >> /root/zig.txt
mv -v zig /usr/local/bin >> /root/zig.txt
rm -rfv zig-$ARC-$OS-$VER zig-$ARC-$OS-$VER.tar.xz >> /root/zig.txt
zig version >> /root/zig.txt
echo "Zigバージョンを更新に成功です。" >> /root/zig.txt
fi
cat /root/zig.txt | mail -s "${IP} Zigバージョン更新 (${DATE})" reports@076.ne.jp
rm -rf /root/zig.txt