-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-linux.sh
More file actions
executable file
·49 lines (45 loc) · 1.9 KB
/
Copy pathstart-linux.sh
File metadata and controls
executable file
·49 lines (45 loc) · 1.9 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
#!/bin/bash
# IMAP Synchronizer launcher for Linux. Installs Python 3 via the distro package manager if missing.
cd "$(dirname "$0")" || exit 1
# Package installs need root: use sudo when available, nothing when already
# root (containers/minimal systems often have no sudo at all).
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
elif command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
else
SUDO="__none__"
fi
if ! command -v python3 >/dev/null 2>&1; then
if [ "$SUDO" = "__none__" ]; then
echo "Python 3 was not found and neither root nor sudo is available."
echo "Please install Python 3 manually and run this launcher again."
exit 1
fi
echo "Python 3 was not found on this system. Trying to install it..."
if command -v apt-get >/dev/null 2>&1; then
$SUDO apt-get update && $SUDO apt-get install -y python3 python3-pip
elif command -v dnf >/dev/null 2>&1; then
$SUDO dnf install -y python3 python3-pip
elif command -v pacman >/dev/null 2>&1; then
$SUDO pacman -Sy --noconfirm python python-pip
elif command -v zypper >/dev/null 2>&1; then
$SUDO zypper install -y python3 python3-pip
else
echo "Could not detect your package manager. Please install Python 3"
echo "manually and run this launcher again."
exit 1
fi
fi
# The tool's only dependency ('rich') installs itself via pip on first run,
# but on Debian/Ubuntu the distro package avoids PEP 668 restrictions.
if ! python3 -c "import rich" >/dev/null 2>&1 && [ "$SUDO" != "__none__" ]; then
if command -v apt-get >/dev/null 2>&1; then
$SUDO apt-get install -y python3-rich 2>/dev/null || true
elif command -v dnf >/dev/null 2>&1; then
$SUDO dnf install -y python3-rich 2>/dev/null || true
elif command -v pacman >/dev/null 2>&1; then
$SUDO pacman -S --noconfirm python-rich 2>/dev/null || true
fi
fi
python3 imapsynchronizer.py