Skip to content

Commit

Permalink
update update.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
Eshanchik committed Nov 25, 2024
1 parent 4a4d48e commit 89f3ab9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "airdao-nop-rs"
version = "0.1.3"
version = "0.1.4"
edition = "2021"

[dependencies]
Expand Down
49 changes: 33 additions & 16 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,52 @@ net.ipv6.conf.all.disable_ipv6=1
END
sysctl -p /etc/sysctl.d/10-airdao.conf

cd ~/airdao-nop-rs || return
cd ~/airdao-nop-rs

CURRENT_VERSION=$(./airdao-nop-rs --version | cut -d ' ' -f2)
LATEST_VERSION=$(curl -s https://raw.githubusercontent.com/ambrosus/airdao-nop-rs/main/Cargo.toml | grep '^version' | sed -E 's/version = "(.*)"/\1/')
LATEST_TAG=$(curl -s https://raw.githubusercontent.com/ambrosus/airdao-nop-rs/main/Cargo.toml | grep '^version' | sed -E 's/version = "(.*)"/\1/')
DIR_NAME="airdao-nop-rs"
ZIP_FILE="${DIR_NAME}.zip"

install_airdao() {
cd ~
curl -L -o "$ZIP_FILE" "$FILE_URL"
echo "Распаковка $ZIP_FILE..."
unzip -o "$ZIP_FILE"

curl -L -o "$ZIP_FILE" "$FILE_URL" || { echo "Failed to download file"; exit 1; }

unzip -o "$ZIP_FILE" || { echo "Failed to unzip file"; exit 1; }
rm "$ZIP_FILE"

cd "$DIR_NAME"

if cosign verify-blob --key airdao-nop-rs.pub --signature airdao-nop-rs.sig airdao-nop-rs; then
echo -e "\033[0;32mVerified OK\033[0m"
else
rm -rf ~/airdao-nop-rs
echo -e "\033[0;31mError: Verification failed\033[0m"
exit 1
fi

chmod +x ./airdao-nop-rs

./airdao-nop-rs update
}

if [[ "$CURRENT_VERSION" != "$LATEST_VERSION" ]]; then
DEBIAN_VERSION=$(lsb_release -sr | cut -d '.' -f 1)
UBUNTU_VERSION=$(lsb_release -sr | cut -d '.' -f 1)
if (( DEBIAN_VERSION > 11 )) || (( UBUNTU_VERSION >= 22 )); then
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/v$LATEST_VERSION/airdao-nop-rs-x86-64.zip"
if [[ "$CURRENT_VERSION" != "$LATEST_TAG" ]]; then
DISTRO_NAME=$(lsb_release -i | cut -d ':' -f 2 | xargs)
MAJOR_VERSION=$(lsb_release -sr | cut -d '.' -f 1)
if [[ "$DISTRO_NAME" == "Ubuntu" ]]; then
if (( MAJOR_VERSION >= 22 )); then
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/v$LATEST_TAG/airdao-nop-rs-x86-64.zip"
else
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/v$LATEST_TAG/airdao-nop-rs-x86-64-old.zip"
fi
elif [[ "$DISTRO_NAME" == "Debian" ]]; then
if (( MAJOR_VERSION > 11 )); then
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/v$LATEST_TAG/airdao-nop-rs-x86-64.zip"
else
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/v$LATEST_TAG/airdao-nop-rs-x86-64-old.zip"
fi
else
FILE_URL="https://github.com/ambrosus/airdao-nop-rs/releases/download/v$LATEST_VERSION/airdao-nop-rs-x86-64-old.zip"
exit 1
fi

install_airdao
fi
fi

0 comments on commit 89f3ab9

Please sign in to comment.