-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·139 lines (117 loc) · 3.33 KB
/
install.sh
File metadata and controls
executable file
·139 lines (117 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Configuration
REPO="rickcrawford/tokenomics"
INSTALL_DIR="${1:-.}"
BINARY_NAME="tokenomics"
# Detect OS and architecture
detect_system() {
local os arch
case "$(uname -s)" in
Linux*)
os="linux"
;;
Darwin*)
os="darwin"
;;
MINGW*|MSYS*|CYGWIN*)
os="windows"
;;
*)
echo -e "${RED}Error: Unsupported operating system${NC}"
exit 1
;;
esac
case "$(uname -m)" in
x86_64|amd64)
arch="amd64"
;;
aarch64|arm64)
arch="arm64"
;;
*)
echo -e "${RED}Error: Unsupported architecture: $(uname -m)${NC}"
exit 1
;;
esac
echo "$os" "$arch"
}
main() {
echo -e "${GREEN}Tokenomics Installer${NC}"
echo ""
# Detect system
read -r os arch < <(detect_system)
echo "Detected system: $os/$arch"
# Get latest release
echo "Fetching latest release..."
RELEASE=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4)
if [ -z "$RELEASE" ]; then
echo -e "${RED}Error: Could not fetch latest release${NC}"
exit 1
fi
echo "Latest release: $RELEASE"
# Determine filename
if [ "$os" = "windows" ]; then
FILENAME="tokenomics-windows-$arch.zip"
EXTRACT_CMD="unzip -q"
BINARY_FILE="tokenomics.exe"
else
FILENAME="tokenomics-$os-$arch.tar.gz"
EXTRACT_CMD="tar -xzf"
BINARY_FILE="tokenomics"
fi
# Download
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$RELEASE/$FILENAME"
echo "Downloading from $DOWNLOAD_URL..."
if ! curl -fsSL -o "$FILENAME" "$DOWNLOAD_URL"; then
echo -e "${RED}Error: Failed to download $FILENAME${NC}"
exit 1
fi
# Extract
echo "Extracting..."
if ! $EXTRACT_CMD "$FILENAME"; then
echo -e "${RED}Error: Failed to extract archive${NC}"
rm -f "$FILENAME"
exit 1
fi
# Verify binary exists
if [ ! -f "$BINARY_FILE" ]; then
echo -e "${RED}Error: Binary not found after extraction${NC}"
rm -f "$FILENAME"
exit 1
fi
# Make executable
chmod +x "$BINARY_FILE"
# Move to install directory
if [ "$INSTALL_DIR" != "." ]; then
mkdir -p "$INSTALL_DIR"
mv "$BINARY_FILE" "$INSTALL_DIR/$BINARY_NAME"
INSTALL_PATH="$INSTALL_DIR/$BINARY_NAME"
else
INSTALL_PATH="./$BINARY_FILE"
fi
# Cleanup
rm -f "$FILENAME"
echo ""
echo -e "${GREEN}Installation successful!${NC}"
echo ""
echo "Binary location: $INSTALL_PATH"
echo ""
echo "Next steps:"
if [ "$INSTALL_DIR" = "." ]; then
echo " 1. Make it accessible: sudo cp ./$BINARY_NAME /usr/local/bin/"
echo " 2. Verify: ./$BINARY_NAME --help"
elif echo "$INSTALL_DIR" | grep -q "/usr/local/bin\|/usr/bin\|/bin\|/opt"; then
echo " 1. Verify installation: $BINARY_NAME --help"
echo " 2. Start using: $BINARY_NAME serve"
else
echo " 1. Add to PATH: export PATH=\"$INSTALL_DIR:\$PATH\""
echo " 2. Verify: $BINARY_NAME --help"
fi
}
main "$@"