forked from Steven-Marshall/lfm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
187 lines (161 loc) · 4.62 KB
/
Copy pathinstall.sh
File metadata and controls
187 lines (161 loc) · 4.62 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
#!/usr/bin/env bash
# LFM Installation Script for macOS and Linux
# Usage: curl -fsSL https://raw.githubusercontent.com/Steven-Marshall/lfm/master/install.sh | bash
set -e
VERSION="${1:-latest}"
echo ""
echo "========================================"
echo " LFM - Last.fm CLI Tool Installer "
echo "========================================"
echo ""
# Detect OS and architecture
OS="$(uname -s)"
ARCH="$(uname -m)"
case "$OS" in
Darwin*)
if [ "$ARCH" = "arm64" ]; then
PLATFORM="macos-apple-silicon"
ARCHIVE_EXT="zip"
else
PLATFORM="macos-intel"
ARCHIVE_EXT="zip"
fi
;;
Linux*)
PLATFORM="linux-x64"
ARCHIVE_EXT="tar.gz"
;;
*)
echo "✗ Unsupported operating system: $OS"
exit 1
;;
esac
echo "Detected: $OS ($ARCH)"
echo "Platform: $PLATFORM"
echo ""
# Define installation directory
INSTALL_DIR="$HOME/.local/bin"
BINARY_PATH="$INSTALL_DIR/lfm"
# Create installation directory
echo "Creating installation directory..."
mkdir -p "$INSTALL_DIR"
# Determine download URL
if [ "$VERSION" = "latest" ]; then
DOWNLOAD_URL="https://github.com/Steven-Marshall/lfm/releases/latest/download/lfm-${PLATFORM}.${ARCHIVE_EXT}"
else
DOWNLOAD_URL="https://github.com/Steven-Marshall/lfm/releases/download/v${VERSION}/lfm-${PLATFORM}.${ARCHIVE_EXT}"
fi
# Download
echo "Downloading LFM from GitHub..."
TEMP_FILE="/tmp/lfm-download.${ARCHIVE_EXT}"
if command -v curl &> /dev/null; then
curl -fSL "$DOWNLOAD_URL" -o "$TEMP_FILE"
elif command -v wget &> /dev/null; then
wget -q "$DOWNLOAD_URL" -O "$TEMP_FILE"
else
echo "✗ Neither curl nor wget found. Please install one of them."
exit 1
fi
echo "✓ Download complete"
# Extract archive
echo "Extracting files..."
if [ "$ARCHIVE_EXT" = "zip" ]; then
# macOS
unzip -o "$TEMP_FILE" -d "/tmp/lfm-extract" > /dev/null
mv "/tmp/lfm-extract/lfm" "$BINARY_PATH"
rm -rf "/tmp/lfm-extract"
else
# Linux (tar.gz)
tar -xzf "$TEMP_FILE" -C "/tmp"
mv "/tmp/lfm" "$BINARY_PATH"
fi
echo "✓ Extraction complete"
# Make executable
chmod +x "$BINARY_PATH"
echo "✓ Made executable"
# Clean up
rm -f "$TEMP_FILE"
# Add to PATH if not already there
echo ""
echo "Checking PATH configuration..."
# Detect shell
SHELL_NAME="$(basename "$SHELL")"
case "$SHELL_NAME" in
bash)
if [ "$OS" = "Darwin" ]; then
SHELL_RC="$HOME/.bash_profile"
else
SHELL_RC="$HOME/.bashrc"
fi
;;
zsh)
SHELL_RC="$HOME/.zshrc"
;;
fish)
SHELL_RC="$HOME/.config/fish/config.fish"
PATH_CMD='set -gx PATH $HOME/.local/bin $PATH'
;;
*)
SHELL_RC="$HOME/.profile"
;;
esac
# Default PATH command for bash/zsh
if [ -z "$PATH_CMD" ]; then
PATH_CMD='export PATH="$HOME/.local/bin:$PATH"'
fi
# Check if already in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo "Adding LFM to PATH in $SHELL_RC..."
# Create shell RC if it doesn't exist
touch "$SHELL_RC"
# Add to PATH if not already there
if ! grep -q "\.local/bin" "$SHELL_RC"; then
echo "" >> "$SHELL_RC"
echo "# Added by LFM installer" >> "$SHELL_RC"
echo "$PATH_CMD" >> "$SHELL_RC"
echo "✓ Added to PATH"
echo ""
echo "⚠ Important: Run 'source $SHELL_RC' or restart your terminal"
else
echo "✓ PATH entry already exists in $SHELL_RC"
fi
# Update PATH for current session
export PATH="$INSTALL_DIR:$PATH"
else
echo "✓ Already in PATH"
fi
# Verify installation
echo ""
echo "Verifying installation..."
if [ -x "$BINARY_PATH" ]; then
VERSION_OUTPUT=$("$BINARY_PATH" --version 2>&1 || echo "version check failed")
echo "✓ LFM installed successfully: $VERSION_OUTPUT"
else
echo "⚠ Installation complete but verification failed"
echo "You may need to restart your terminal"
fi
# Installation complete
echo ""
echo "========================================"
echo " Installation Complete! "
echo "========================================"
echo ""
# Next steps
echo "Next Steps:"
echo ""
echo "1. Get your Last.fm API key:"
echo " https://www.last.fm/api/account/create"
echo ""
echo "2. Configure LFM:"
echo " lfm config set api-key YOUR_API_KEY"
echo " lfm config set username YOUR_LASTFM_USERNAME"
echo ""
echo "3. Try it out:"
echo " lfm artists --limit 5"
echo ""
echo "4. (Optional) Set up MCP for Claude integration:"
echo " https://github.com/Steven-Marshall/lfm/blob/master/MCP_SETUP.md"
echo ""
echo "For help: lfm --help"
echo "Documentation: https://github.com/Steven-Marshall/lfm"
echo ""