-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall-lrm.sh
More file actions
executable file
·211 lines (178 loc) · 6.85 KB
/
install-lrm.sh
File metadata and controls
executable file
·211 lines (178 loc) · 6.85 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
#!/bin/bash
# Installation script for Localization Resource Manager (LRM)
# Usage: curl -sSL https://raw.githubusercontent.com/nickprotop/LocalizationManager/main/install-lrm.sh | bash
# Or: wget -qO- https://raw.githubusercontent.com/nickprotop/LocalizationManager/main/install-lrm.sh | bash
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to install bash completion
install_bash_completion() {
local bash_comp_dir="$HOME/.local/share/bash-completion/completions"
mkdir -p "$bash_comp_dir"
echo -n " • Bash completion... "
# Download from GitHub (use main branch for latest)
if curl -fsSL "https://raw.githubusercontent.com/nickprotop/LocalizationManager/main/lrm-completion.bash" \
-o "$bash_comp_dir/lrm" 2>/dev/null; then
chmod 644 "$bash_comp_dir/lrm"
echo -e "${GREEN}✓${NC}"
# Check if bash-completion is available
if ! type _completion_loader &>/dev/null 2>&1; then
echo -e " ${YELLOW}Note: bash-completion package may not be installed${NC}"
echo " Install with: sudo apt install bash-completion (Debian/Ubuntu)"
echo " or: sudo dnf install bash-completion (Fedora)"
fi
else
echo -e "${YELLOW}⚠ Download failed (skipped)${NC}"
fi
}
# Function to install zsh completion
install_zsh_completion() {
local zsh_comp_dir="$HOME/.zsh/completions"
mkdir -p "$zsh_comp_dir"
echo -n " • Zsh completion... "
# Download from GitHub
if curl -fsSL "https://raw.githubusercontent.com/nickprotop/LocalizationManager/main/_lrm" \
-o "$zsh_comp_dir/_lrm" 2>/dev/null; then
chmod 644 "$zsh_comp_dir/_lrm"
echo -e "${GREEN}✓${NC}"
# Check if fpath is configured
check_zsh_fpath_config
else
echo -e "${YELLOW}⚠ Download failed (skipped)${NC}"
fi
}
# Function to check zsh fpath configuration
check_zsh_fpath_config() {
local zshrc="$HOME/.zshrc"
if [ ! -f "$zshrc" ]; then
echo -e " ${YELLOW}Note: ~/.zshrc not found${NC}"
return
fi
# Check if fpath already includes our completion directory
if grep -q "fpath=.*\.zsh/completions" "$zshrc" 2>/dev/null; then
echo " ✓ fpath already configured"
else
echo
echo -e " ${YELLOW}⚠ Action required: Add this to ~/.zshrc (before compinit):${NC}"
echo
echo " fpath=(~/.zsh/completions \$fpath)"
echo " autoload -Uz compinit && compinit"
echo
echo " Then restart your shell: exec zsh"
fi
}
# Function to install completions for available shells
install_completions() {
local installed_any=false
# Install bash completion if bash is available
if command -v bash &>/dev/null; then
install_bash_completion
installed_any=true
fi
# Install zsh completion if zsh is available
if command -v zsh &>/dev/null; then
install_zsh_completion
installed_any=true
fi
if [ "$installed_any" = false ]; then
echo " No supported shells found (bash/zsh)"
fi
}
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Localization Resource Manager (LRM) Installer ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
echo
# Detect OS and architecture
OS=$(uname -s)
ARCH=$(uname -m)
if [[ "$OS" == "Linux" ]]; then
if [[ "$ARCH" == "x86_64" ]]; then
PLATFORM="linux-x64"
elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
PLATFORM="linux-arm64"
else
echo -e "${RED}Error: Unsupported architecture: $ARCH${NC}"
exit 1
fi
elif [[ "$OS" == "Darwin" ]]; then
echo -e "${RED}Error: macOS is not yet supported. Please download manually from releases.${NC}"
exit 1
else
echo -e "${RED}Error: Unsupported OS: $OS${NC}"
echo "This script is for Linux only. For Windows, download from:"
echo "https://github.com/nickprotop/LocalizationManager/releases"
exit 1
fi
echo -e "${GREEN}✓${NC} Detected platform: $PLATFORM"
# Download URL (using latest release)
FILENAME="lrm-${PLATFORM}.tar.gz"
URL="https://github.com/nickprotop/LocalizationManager/releases/latest/download/${FILENAME}"
echo "Downloading latest LRM..."
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
if ! curl -L -o "$FILENAME" "$URL"; then
echo -e "${RED}Error: Download failed${NC}"
rm -rf "$TEMP_DIR"
exit 1
fi
echo -e "${GREEN}✓${NC} Downloaded successfully"
# Extract
echo "Extracting..."
tar -xzf "$FILENAME"
# Install
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
cp "${PLATFORM}/lrm" "$INSTALL_DIR/lrm"
chmod +x "$INSTALL_DIR/lrm"
echo -e "${GREEN}✓${NC} Installed to $INSTALL_DIR/lrm"
# Cleanup
cd - > /dev/null
rm -rf "$TEMP_DIR"
# Install shell completions
echo
echo "Installing shell completions..."
install_completions
# Check if in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo
echo -e "${BLUE}Note: $INSTALL_DIR is not in your PATH${NC}"
echo "Add this to your ~/.bashrc or ~/.zshrc:"
echo
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo
else
echo -e "${GREEN}✓${NC} $INSTALL_DIR is already in your PATH"
fi
# Verify installation
echo
echo "Verifying installation..."
if "$INSTALL_DIR/lrm" --version > /dev/null 2>&1; then
echo
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN}✓ Installation complete!${NC}"
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo
"$INSTALL_DIR/lrm" --version
echo
echo "Installed components:"
echo " • Binary: ~/.local/bin/lrm"
if [ -f "$HOME/.local/share/bash-completion/completions/lrm" ]; then
echo " • Bash completion: ~/.local/share/bash-completion/completions/lrm"
fi
if [ -f "$HOME/.zsh/completions/_lrm" ]; then
echo " • Zsh completion: ~/.zsh/completions/_lrm"
fi
echo
echo "Quick start:"
echo " lrm --help # Show all commands"
echo " lrm validate --path /path/to/resources # Validate resources"
echo " lrm <TAB> # Test completion"
echo
else
echo -e "${RED}Error: Installation verification failed${NC}"
exit 1
fi