-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.sh
51 lines (42 loc) · 1.57 KB
/
installer.sh
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
#!/bin/bash
#/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/cbusillo/ebay_pictures_tool/main/installer.sh)"
handle_error() {
echo "Error: $1"
exit 1
}
get_brew_path() {
if command -v /usr/local/bin/brew &> /dev/null; then
echo "/usr/local/bin/brew"
elif command -v /opt/homebrew/bin/brew &> /dev/null; then
echo "/opt/homebrew/bin/brew"
else
echo ""
fi
}
update_zshrc() {
ZSHRC_PATH="$HOME/.zshrc"
# Checking if the path exists in .zshrc
if ! grep -q "export PATH=\"$1:\$PATH\"" "$ZSHRC_PATH"; then
echo "export PATH=\"$1:\$PATH\"" >> "$ZSHRC_PATH"
echo "Updated .zshrc with new PATH"
else
echo ".zshrc already contains the PATH"
fi
}
BREW_PATH=$(get_brew_path)
if [ -z "$BREW_PATH" ]; then
echo "Homebrew not found. Installing..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || handle_error "Failed to install Homebrew"
BREW_PATH=$(get_brew_path)
fi
export PATH="$BREW_PATH:$PATH"
update_zshrc "$BREW_PATH"
$BREW_PATH install [email protected] zbar || handle_error "Failed to install [email protected] or zbar"
$BREW_PATH upgrade [email protected] zbar || handle_error "Failed to upgrade [email protected] or zbar"
PIP_PATH="${BREW_PATH%/brew}/pip3.11"
$PIP_PATH install --upgrade pip || handle_error "Failed to upgrade pip"
$PIP_PATH install -U ebay_pictures_tool || handle_error "Failed to install ebay_pictures_tool"
source "$HOME/.zshrc"
echo "Attempting to run ebay_pictures_tool..."
ebay_pictures_tool
echo "ebay_pictures_tool has finished."