1+ #! /bin/bash
2+ latest_version=$( curl -s https://api.github.com/repos/cirnum/loadtester/releases/latest | grep ' "tag_name":' | cut -d' "' -f4)
3+
4+
5+ # Replace these values with your Go binary details
6+ APP_NAME=" loadster"
7+ GITHUB_USER=" cirnum"
8+ GITHUB_REPO=" loadtester"
9+ INSTALL_DIR=" /usr/local/bin"
10+
11+
12+ # Detect the OS and architecture
13+ OS=$( uname | tr ' [:upper:]' ' [:lower:]' )
14+ ARCH=$( uname -m)
15+
16+ # Adjust the OS and ARCH values for macOS (darwin) and x86_64
17+ if [[ " $OS " == " darwin" ]]; then
18+ OS=" darwin"
19+ elif [[ " $OS " == " linux" ]]; then
20+ OS=" linux"
21+ fi
22+ if [[ " $ARCH " == " amd64" ]]; then
23+ ARCH=" amd64"
24+ elif [[ " $ARCH " == " arm64" ]]; then
25+ ARCH=" arm64"
26+ elif [[ " $ARCH " == " x86_64" ]]; then
27+ ARCH=" amd64"
28+ fi
29+
30+ echo " Getting latest build for os: ${OS} and arch: ${ARCH} "
31+ # Create the download URL
32+ URL=" https://github.com/${GITHUB_USER} /${GITHUB_REPO} /releases/download/${latest_version} /${GITHUB_REPO} -${latest_version} -${OS} -${ARCH} .tar.gz"
33+
34+ # Define the installation directory
35+ NAMET=" loadtester.tar.gz"
36+ RMDIR=${GITHUB_REPO} -${latest_version} -${OS} -${ARCH}
37+
38+ # Step 1: Download the tarball
39+ echo " Step 1 of 4: Downloading $URL ..."
40+ response_code=$( curl -sL -o " loadtester.tar.gz" -w " %{http_code}" $URL )
41+ if [ " $response_code " -eq 200 ]; then
42+ echo " GitHub page found!"
43+ else
44+ echo " Seems build not found, you can create issue here: https://github.com/cirnum/loadtester/issues"
45+ exit 1;
46+ fi
47+
48+ curl -sL -o " loadtester.tar.gz" " $URL "
49+
50+ # Step 2: Extract the tarball
51+ echo " Step 2 of 4: Extracting $NAMET ..."
52+ tar -xzf $NAMET
53+
54+ # Step 3: Move the extracted files to the "bin" folder
55+ echo " Step 3 of 4: Moving files to $INSTALL_DIR ..."
56+ mv " $RMDIR /$APP_NAME " " $INSTALL_DIR "
57+
58+ # Step 4: Cleanup - delete the downloaded tarball and empty folder
59+ echo " Step 4 of 4: Cleaning up..."
60+ rm -r " $NAMET " " $RMDIR "
61+
62+ # Verify installation
63+ if command -v " $APP_NAME " & > /dev/null; then
64+ echo " ${APP_NAME} installed successfully!"
65+ else
66+ echo " Failed to install ${APP_NAME} . Please check for errors."
67+ fi
0 commit comments