From 475a4d9b8b6231098f16df671da5cac33c3f6c83 Mon Sep 17 00:00:00 2001 From: 0xOzgur <29779769+0xOzgur@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:58:06 +0300 Subject: [PATCH] update.sh --- update/update.sh | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/update/update.sh b/update/update.sh index 4046bf6..1ea7a45 100644 --- a/update/update.sh +++ b/update/update.sh @@ -61,27 +61,56 @@ get_os_arch() { echo "${os}-${arch}" } +get_os_arch() { + local os=$(uname -s | tr '[:upper:]' '[:lower:]') + local arch=$(uname -m) + + case "$os" in + linux|darwin) ;; + *) echo "Unsupported operating system: $os" >&2; return 1 ;; + esac + + case "$arch" in + x86_64|amd64) arch="amd64" ;; + arm64|aarch64) arch="arm64" ;; + *) echo "Unsupported architecture: $arch" >&2; return 1 ;; + esac + + echo "${os}-${arch}" +} + +# Base URL for the Quilibrium releases +RELEASE_FILES_URL="https://releases.quilibrium.com/release" + +cd ~/ceremonyclient/node + # Get the current OS and architecture OS_ARCH=$(get_os_arch) -# Base URL for the Quilibrium releases -BASE_URL="https://releases.quilibrium.com/release" - # Fetch the list of files from the release page -FILES=$(curl -s $BASE_URL | grep -oE "node-[0-9]+\.[0-9]+\.[0-9]+-${OS_ARCH}(\.dgst)?(\.sig\.[0-9]+)?") - +RELEASE_FILES=$(curl -s $RELEASE_FILES_URL | grep -oE "node-[0-9]+\.[0-9]+\.[0-9]+-${OS_ARCH}(\.dgst)?(\.sig\.[0-9]+)?") # Change to the download directory cd ~/ceremonyclient/node # Download each file -for file in $FILES; do +for file in $RELEASE_FILES; do echo "Downloading $file..." wget "https://releases.quilibrium.com/$file" # Check if the download was successful if [ $? -eq 0 ]; then echo "Successfully downloaded $file" + # Check if the file is the base binary (without .dgst or .sig suffix) + if [[ $file =~ ^node-[0-9]+\.[0-9]+\.[0-9]+-${OS_ARCH}$ ]]; then + echo "Making $file executable..." + chmod +x "$file" + if [ $? -eq 0 ]; then + echo "Successfully made $file executable" + else + echo "Failed to make $file executable" + fi + fi else echo "Failed to download $file" fi @@ -89,6 +118,8 @@ for file in $FILES; do echo "------------------------" done +echo "Download process completed." + # Determine the ExecStart line based on the architecture