-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·56 lines (44 loc) · 1.83 KB
/
install.sh
File metadata and controls
executable file
·56 lines (44 loc) · 1.83 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
#!/bin/bash
set -euo pipefail
echo "[+] Checking for required tools..."
for cmd in python3 sudo install systemctl; do
command -v "$cmd" >/dev/null || { echo "$cmd is required but not found"; exit 1; }
done
if ! pidof systemd >/dev/null; then
echo "[-] systemd not running. This script supports only systemd-based Linux systems."
exit 1
fi
if ! command -v pipx >/dev/null; then
echo "[!] pipx not found. Attempting to install..."
if command -v pacman >/dev/null; then
echo "[+] Installing pipx with pacman..."
sudo pacman -Sy --noconfirm python-pipx
elif command -v apt >/dev/null; then
echo "[+] Installing pipx with apt..."
sudo apt update
sudo apt install -y pipx
export PATH="$HOME/.local/bin:$PATH"
elif command -v dnf >/dev/null; then
echo "[+] Installing pipx with dnf..."
sudo dnf install -y pipx
else
echo "❌ Unknown package manager. Please install pipx manually from https://pypa.github.io/pipx/"
exit 1
fi
fi
echo "[+] Installing torrcli via pipx..."
pipx install . --force
echo "[+] Copying config example to /usr/share/torrcli/..."
sudo install -Dm644 torrcli.conf.example /usr/share/torrcli/torrcli.conf.example
echo "[+] Preparing systemd service file..."
USER_NAME=${SUDO_USER:-$(whoami)}
TORRCLI_PYTHON="$HOME/.local/share/pipx/venvs/torrcli/bin/python"
sed "s|__USER__|$USER_NAME|; s|__PYTHON__|$TORRCLI_PYTHON|" torrcli.service > /tmp/torrcli.service.final
echo "[+] Installing systemd service..."
sudo install -Dm644 /tmp/torrcli.service.final /usr/lib/systemd/system/torrcli.service
echo "[+] Enabling and starting systemd service..."
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable torrcli.service
sudo systemctl start torrcli.service
echo "✅ Torrcli installed and running via systemd."