-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·121 lines (95 loc) · 3 KB
/
install.sh
File metadata and controls
executable file
·121 lines (95 loc) · 3 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
#!/bin/bash
# rm-version-switcher installer script
# Detects architecture and downloads the correct binary from latest GitHub release
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# GitHub repository
REPO="rmitchellscott/rm-version-switcher"
BINARY_NAME="rm-version-switcher"
# Function to print colored output
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Detect architecture
detect_arch() {
local arch=$(uname -m)
case $arch in
armv7l)
echo "armv7"
;;
aarch64)
echo "aarch64"
;;
*)
print_error "Unsupported architecture: $arch"
print_error "This script is designed for reMarkable devices (armv7l or aarch64)"
exit 1
;;
esac
}
# Get latest release version from GitHub API
get_latest_version() {
local api_url="https://api.github.com/repos/$REPO/releases/latest"
local version=$(wget -qO- "$api_url" 2>/dev/null | grep -o '"tag_name": "[^"]*' | grep -o '[^"]*$' 2>/dev/null || echo "")
if [ -z "$version" ]; then
print_error "Failed to fetch latest version information"
exit 1
fi
echo "$version"
}
# Download and install binary
install_binary() {
local arch=$1
local version=$2
local binary_name="${BINARY_NAME}-${arch}"
local download_url="https://github.com/$REPO/releases/download/$version/${binary_name}.tar.gz"
print_status "Downloading $binary_name version $version..."
# Download the binary
wget -O "${binary_name}.tar.gz" "$download_url"
# Extract the binary
print_status "Extracting binary..."
tar -xzf "${binary_name}.tar.gz"
# Rename to generic name and make executable
mv "$binary_name" "$BINARY_NAME"
chmod +x "$BINARY_NAME"
# Clean up
rm "${binary_name}.tar.gz"
print_status "Downloaded and extracted $BINARY_NAME"
print_status "You can now run ./$BINARY_NAME"
}
# Main installation process
main() {
print_status "reMarkable Version Switcher Installer"
print_status "======================================"
# Detect architecture
local arch=$(detect_arch)
print_status "Detected architecture: $arch"
# Get latest version
print_status "Fetching latest release information..."
local version=$(get_latest_version)
print_status "Latest version: $version"
# Check if binary already exists
if [ -f "$BINARY_NAME" ]; then
print_warning "rm-version-switcher already exists in current directory"
read -p "Do you want to continue and overwrite? (y/N): " -n 1 -r </dev/tty
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_status "Installation cancelled."
exit 0
fi
fi
# Install the binary
install_binary "$arch" "$version"
}
# Run main function
main "$@"