@@ -32,10 +32,9 @@ ASCII_LOGO=" ________ .__
3232 \______ /\____/|____(____ /_____ \____/
3333 \/ \/ \/ "
3434
35- # Get the latest release tag or use main
36- VERSION=${1:- main}
3735REPO=" 0xjuanma/golazo"
3836BINARY_NAME=" golazo"
37+ INSTALL_DIR=" ${INSTALL_DIR:-/ usr/ local/ bin} "
3938
4039# Print ASCII art header with cyan color
4140printf " ${BRIGHT_CYAN}${ASCII_LOGO}${NC} \n\n"
@@ -45,48 +44,73 @@ printf "${BRIGHT_GREEN}Installing ${BINARY_NAME}...${NC}\n\n"
4544OS=$( uname -s | tr ' [:upper:]' ' [:lower:]' )
4645ARCH=$( uname -m)
4746
48- case $ARCH in
47+ case " $ARCH " in
4948 x86_64) ARCH=" amd64" ;;
50- arm64| aarch64) ARCH=" arm64" ;;
49+ aarch64|arm64 ) ARCH=" arm64" ;;
5150 * ) printf " ${BRIGHT_RED} Unsupported architecture: ${ARCH}${NC} \n" ; exit 1 ;;
5251esac
5352
54- # Create temp directory
55- TMP_DIR=$( mktemp -d)
56- trap " rm -rf ${TMP_DIR} " EXIT
53+ # Check for supported OS
54+ case " $OS " in
55+ darwin|linux) ;;
56+ * ) printf " ${BRIGHT_RED} Unsupported operating system: ${OS}${NC} \n" ; exit 1 ;;
57+ esac
5758
58- # Clone repository
59- printf " ${CYAN} Cloning repository...${NC} \n"
60- git clone --depth 1 --branch ${VERSION} https://github.com/${REPO} .git ${TMP_DIR} /golazo 2> /dev/null || \
61- git clone --depth 1 https://github.com/${REPO} .git ${TMP_DIR} /golazo
59+ printf " ${CYAN} Detected: ${OS} /${ARCH}${NC} \n"
6260
63- cd ${TMP_DIR} /golazo
61+ # Get the latest release tag
62+ printf " ${CYAN} Fetching latest release...${NC} \n"
63+ LATEST=$( curl -sL " https://api.github.com/repos/$REPO /releases/latest" | grep ' "tag_name"' | cut -d' "' -f4)
6464
65- # Build the binary
66- printf " ${CYAN} Building ${BINARY_NAME} ...${NC} \n"
67- go build -o ${BINARY_NAME} .
65+ if [ -z " $LATEST " ]; then
66+ printf " ${BRIGHT_RED} Failed to fetch latest release${NC} \n"
67+ exit 1
68+ fi
6869
69- # Determine install location
70- if [ -w /usr/local/bin ]; then
71- INSTALL_DIR=" /usr/local/bin"
72- elif [ -w ~ /.local/bin ]; then
73- INSTALL_DIR=" $HOME /.local/bin"
74- mkdir -p ${INSTALL_DIR}
75- else
76- INSTALL_DIR=" $HOME /bin"
77- mkdir -p ${INSTALL_DIR}
70+ printf " ${CYAN} Latest version: ${LATEST}${NC} \n"
71+
72+ # Construct download URL
73+ URL=" https://github.com/$REPO /releases/download/$LATEST /${BINARY_NAME} -${OS} -${ARCH} "
74+
75+ # Download the binary
76+ printf " ${CYAN} Downloading ${BINARY_NAME} ${LATEST} for ${OS} /${ARCH} ...${NC} \n"
77+ if ! curl -sL " $URL " -o " $BINARY_NAME " ; then
78+ printf " ${BRIGHT_RED} Failed to download binary${NC} \n"
79+ exit 1
7880fi
7981
80- # Install the binary
82+ chmod +x " $BINARY_NAME "
83+
84+ # Determine install location and install
8185printf " ${CYAN} Installing to ${INSTALL_DIR} ...${NC} \n"
82- cp ${BINARY_NAME} ${INSTALL_DIR} /${BINARY_NAME}
83- chmod +x ${INSTALL_DIR} /${BINARY_NAME}
8486
85- # Check if the binary is in PATH
86- if ! command -v ${BINARY_NAME} > /dev/null 2>&1 ; then
87- printf " ${YELLOW} Warning: ${BINARY_NAME} may not be in your PATH.${NC} \n"
88- printf " ${YELLOW} Add ${INSTALL_DIR} to your PATH if needed.${NC} \n"
87+ if [ -w " $INSTALL_DIR " ]; then
88+ mv " $BINARY_NAME " " $INSTALL_DIR /$BINARY_NAME "
89+ else
90+ # Try with sudo if we don't have write access
91+ if command -v sudo > /dev/null 2>&1 ; then
92+ sudo mv " $BINARY_NAME " " $INSTALL_DIR /$BINARY_NAME "
93+ else
94+ # Fallback to user's local bin
95+ INSTALL_DIR=" $HOME /.local/bin"
96+ mkdir -p " $INSTALL_DIR "
97+ mv " $BINARY_NAME " " $INSTALL_DIR /$BINARY_NAME "
98+ printf " ${YELLOW} Installed to ${INSTALL_DIR} (no sudo available)${NC} \n"
99+ fi
89100fi
90101
91- printf " \n${BRIGHT_GREEN}${BINARY_NAME} installed successfully!${NC} \n"
92- printf " ${BRIGHT_GREEN} Run '${BINARY_NAME} ' to start.${NC} \n"
102+ # Verify installation
103+ if [ -f " $INSTALL_DIR /$BINARY_NAME " ]; then
104+ # Check if the binary is in PATH
105+ if ! command -v " $BINARY_NAME " > /dev/null 2>&1 ; then
106+ printf " \n${YELLOW} Warning: ${BINARY_NAME} may not be in your PATH.${NC} \n"
107+ printf " ${YELLOW} Add ${INSTALL_DIR} to your PATH if needed:${NC} \n"
108+ printf " ${CYAN} export PATH=\"\$ PATH:${INSTALL_DIR} \" ${NC} \n"
109+ fi
110+
111+ printf " \n${BRIGHT_GREEN} ✓ ${BINARY_NAME} ${LATEST} installed successfully!${NC} \n"
112+ printf " ${BRIGHT_GREEN} Run '${BINARY_NAME} ' to start watching live football matches.${NC} \n"
113+ else
114+ printf " ${BRIGHT_RED} Installation failed${NC} \n"
115+ exit 1
116+ fi
0 commit comments