-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·234 lines (198 loc) · 6.36 KB
/
install.sh
File metadata and controls
executable file
·234 lines (198 loc) · 6.36 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/bin/bash
# install.sh - Easy installer script for Ryzan Wallet
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# GitHub repository
REPO="simplysabir/ryzan"
BINARY_NAME="ryzan"
# Print colored output
print_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Print banner
print_banner() {
echo -e "${BLUE}"
cat << 'EOF'
██████╗ ██╗ ██╗███████╗ █████╗ ███╗ ██╗
██╔══██╗╚██╗ ██╔╝╚══███╔╝██╔══██╗████╗ ██║
██████╔╝ ╚████╔╝ ███╔╝ ███████║██╔██╗ ██║
██╔══██╗ ╚██╔╝ ███╔╝ ██╔══██║██║╚██╗██║
██║ ██║ ██║ ███████╗██║ ██║██║ ╚████║ ⚡
╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝
EOF
echo -e "${NC}"
echo -e "${GREEN}Ultra-Secure Solana Wallet CLI${NC}"
echo
}
# Detect OS and architecture
detect_platform() {
local os
local arch
# Detect OS
case "$(uname -s)" in
Linux*) os="linux";;
Darwin*) os="macos";;
CYGWIN*|MINGW*|MSYS*) os="windows";;
*) print_error "Unsupported OS: $(uname -s)"; exit 1;;
esac
# Detect architecture
case "$(uname -m)" in
x86_64|amd64) arch="x86_64";;
aarch64|arm64) arch="aarch64";;
armv7l) arch="armv7";;
*) print_error "Unsupported architecture: $(uname -m)"; exit 1;;
esac
echo "${os}-${arch}"
}
# Get latest release version
get_latest_version() {
local version
version=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
if [ -z "$version" ]; then
print_error "Failed to get latest version"
exit 1
fi
echo "$version"
}
# Download and install binary
install_binary() {
local platform="$1"
local version="$2"
local install_dir="${3:-/usr/local/bin}"
# Construct download URL
local filename
local url
if [[ "$platform" == *"windows"* ]]; then
filename="${BINARY_NAME}-${platform}.exe.zip"
url="https://github.com/${REPO}/releases/download/${version}/${filename}"
else
filename="${BINARY_NAME}-${platform}.tar.gz"
url="https://github.com/${REPO}/releases/download/${version}/${filename}"
fi
print_info "Downloading ${BINARY_NAME} ${version} for ${platform}..."
print_info "URL: ${url}"
# Create temp directory
local temp_dir
temp_dir=$(mktemp -d)
# Download
if ! curl -L -o "${temp_dir}/${filename}" "$url"; then
print_error "Failed to download ${filename}"
rm -rf "$temp_dir"
exit 1
fi
# Extract
cd "$temp_dir"
if [[ "$platform" == *"windows"* ]]; then
unzip -q "$filename"
binary_path="${BINARY_NAME}.exe"
else
tar -xzf "$filename"
binary_path="${BINARY_NAME}"
fi
# Check if binary exists
if [ ! -f "$binary_path" ]; then
print_error "Binary not found in archive"
rm -rf "$temp_dir"
exit 1
fi
# Make executable
chmod +x "$binary_path"
# Install
if [ -w "$install_dir" ]; then
mv "$binary_path" "${install_dir}/"
print_success "Installed ${BINARY_NAME} to ${install_dir}/"
else
print_info "Installing to ${install_dir}/ (requires sudo)"
sudo mv "$binary_path" "${install_dir}/"
print_success "Installed ${BINARY_NAME} to ${install_dir}/"
fi
# Cleanup
rm -rf "$temp_dir"
}
# Verify installation
verify_installation() {
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
local version
version=$("$BINARY_NAME" --version 2>/dev/null || echo "unknown")
print_success "${BINARY_NAME} installed successfully!"
print_info "Version: $version"
echo
print_info "Quick start:"
echo " ${BINARY_NAME} create --name main"
echo " ${BINARY_NAME} unlock --name main"
echo " ${BINARY_NAME} balance"
echo
print_info "Run '${BINARY_NAME} --help' for full command list"
else
print_warning "${BINARY_NAME} installed but not found in PATH"
print_info "You may need to add the installation directory to your PATH"
fi
}
# Main installation function
main() {
print_banner
print_info "Installing ${BINARY_NAME}..."
# Check for curl
if ! command -v curl >/dev/null 2>&1; then
print_error "curl is required but not installed"
exit 1
fi
# Detect platform
local platform
platform=$(detect_platform)
print_info "Detected platform: $platform"
# Get latest version
local version
version=$(get_latest_version)
print_info "Latest version: $version"
# Custom install directory
local install_dir="/usr/local/bin"
if [ -n "$INSTALL_DIR" ]; then
install_dir="$INSTALL_DIR"
fi
# Install
install_binary "$platform" "$version" "$install_dir"
# Verify
verify_installation
print_success "Installation complete!"
echo
print_warning "SECURITY NOTICE:"
echo " • Ryzan requires TOTP 2FA for all transactions"
echo " • Set up Google Authenticator or similar app"
echo " • Always backup your recovery phrase securely"
echo " • Test with small amounts first"
}
# Handle command line arguments
case "${1:-}" in
-h|--help)
echo "Usage: $0 [options]"
echo
echo "Options:"
echo " -h, --help Show this help message"
echo
echo "Environment variables:"
echo " INSTALL_DIR Custom installation directory (default: /usr/local/bin)"
echo
echo "Examples:"
echo " $0 # Install to /usr/local/bin"
echo " INSTALL_DIR=~/.local/bin $0 # Install to ~/.local/bin"
exit 0
;;
*)
main "$@"
;;
esac