-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
100 lines (86 loc) · 5.03 KB
/
install.sh
File metadata and controls
100 lines (86 loc) · 5.03 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
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────────────
# redis2github installer – Ubuntu / Debian
# ─────────────────────────────────────────────────────────────────────────────
set -euo pipefail
INSTALL_BIN="/usr/local/bin/redis2github"
INSTALL_PY="/usr/local/lib/redis2github.py"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT_SRC="$SCRIPT_DIR/redis2github.py"
# ── colour helpers ────────────────────────────────────────────────────────────
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; NC='\033[0m'
ok() { echo -e "${GREEN} ✓ $*${NC}"; }
warn() { echo -e "${YELLOW} ⚠ $*${NC}"; }
err() { echo -e "${RED} ✗ $*${NC}"; exit 1; }
echo ""
echo " redis2github installer"
echo " ─────────────────────────────────"
# ── Check OS ─────────────────────────────────────────────────────────────────
if [[ -f /etc/os-release ]]; then
. /etc/os-release
if [[ "$ID" != "ubuntu" && "$ID" != "debian" && "$ID_LIKE" != *"debian"* ]]; then
warn "This installer is designed for Ubuntu/Debian. Continuing anyway…"
fi
fi
# ── Python 3 ──────────────────────────────────────────────────────────────────
if ! command -v python3 &>/dev/null; then
echo " Python 3 not found – installing via apt…"
sudo apt-get update -qq
sudo apt-get install -y python3 python3-pip python3-venv
ok "Python 3 installed"
else
PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
ok "Python ${PY_VER} found"
fi
# ── pip ───────────────────────────────────────────────────────────────────────
if ! python3 -m pip --version &>/dev/null 2>&1; then
echo " pip not found – installing…"
sudo apt-get install -y python3-pip
ok "pip installed"
else
ok "pip available"
fi
# ── pip packages (pre-install for faster first run) ──────────────────────────
echo " Installing Python packages (redis, requests, cryptography)…"
PIP_EXTRA="--break-system-packages"
python3 -m pip install --quiet $PIP_EXTRA redis requests cryptography 2>/dev/null || \
python3 -m pip install --quiet redis requests cryptography 2>/dev/null || \
warn "pip install failed – packages will be installed on first run"
ok "Python packages ready"
# ── Install script ────────────────────────────────────────────────────────────
if [[ ! -f "$SCRIPT_SRC" ]]; then
err "redis2github.py not found in $SCRIPT_DIR"
fi
# Find the absolute path to python3 so the wrapper is immune to PATH issues
PYTHON3_PATH="$(command -v python3)"
ok "Using Python at: $PYTHON3_PATH"
# Install the .py file in /usr/local/lib (not directly executed, wrapper calls it)
sudo cp "$SCRIPT_SRC" "$INSTALL_PY"
sudo chmod 644 "$INSTALL_PY"
# Create a tiny shell wrapper so the command always uses the right python3
sudo tee "$INSTALL_BIN" > /dev/null <<WRAPPER
#!/bin/bash
exec "$PYTHON3_PATH" "$INSTALL_PY" "\$@"
WRAPPER
sudo chmod +x "$INSTALL_BIN"
ok "Installed wrapper to $INSTALL_BIN"
ok "Python script at $INSTALL_PY"
# ── Config directory ──────────────────────────────────────────────────────────
mkdir -p "$HOME/.config/redis2github"
ok "Config directory: ~/.config/redis2github/"
# ── Verify ────────────────────────────────────────────────────────────────────
echo ""
if "$PYTHON3_PATH" "$INSTALL_PY" status &>/dev/null; then
ok "redis2github is ready"
else
ok "redis2github installed (run 'redis2github' to start)"
fi
echo ""
echo -e "${GREEN} Installation complete!${NC}"
echo ""
echo " Next steps:"
echo " redis2github setup # configure Redis + GitHub"
echo " redis2github sync # push IPs now"
echo " redis2github start # start auto-sync daemon"
echo " redis2github install-service # optional: run on boot"
echo ""