-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-macos.command
More file actions
executable file
·43 lines (39 loc) · 1.82 KB
/
Copy pathstart-macos.command
File metadata and controls
executable file
·43 lines (39 loc) · 1.82 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
#!/bin/bash
# IMAP Synchronizer launcher for macOS. Installs Homebrew + Python 3 if missing.
cd "$(dirname "$0")" || exit 1
# Make Homebrew visible if it is installed but not on PATH (fresh terminals).
# Checked by path because "eval" of an empty substitution reports success,
# which would skip the Intel location on Intel Macs.
[ -x /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)"
[ -x /usr/local/bin/brew ] && eval "$(/usr/local/bin/brew shellenv)"
have_working_python3() {
command -v python3 >/dev/null 2>&1 || return 1
# On a clean macOS, /usr/bin/python3 is only a stub that pops up the
# "install Command Line Tools" dialog. Treat it as missing unless the
# developer tools are actually installed.
if [ "$(command -v python3)" = "/usr/bin/python3" ] && \
! xcode-select -p >/dev/null 2>&1; then
return 1
fi
return 0
}
if ! have_working_python3; then
echo "A working Python 3 was not found on this Mac."
if ! command -v brew >/dev/null 2>&1; then
echo "Installing Homebrew (you may be asked for your macOS password)..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Make brew available in this shell (Apple Silicon and Intel paths)
[ -x /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)"
[ -x /usr/local/bin/brew ] && eval "$(/usr/local/bin/brew shellenv)"
fi
if ! command -v brew >/dev/null 2>&1; then
echo "Homebrew installation failed. Install Python 3 manually from"
echo "https://www.python.org/downloads/ and run this launcher again."
read -r -p "Press Enter to close..."
exit 1
fi
echo "Installing Python 3 with Homebrew..."
brew install python
fi
python3 imapsynchronizer.py
read -r -p "Press Enter to close..."