Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·66 lines (55 loc) · 1.85 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·66 lines (55 loc) · 1.85 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
#!/usr/bin/env bash
#
# DNeyeS installer (Linux & macOS)
# Sets up a virtualenv, installs dependencies, and creates a global `dneyes` command.
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="$SCRIPT_DIR/venv"
ENTRYPOINT="$SCRIPT_DIR/dneyes.py"
# Colors
GREEN="\033[92m"; YELLOW="\033[93m"; RED="\033[91m"; BOLD="\033[1m"; RESET="\033[0m"
info() { echo -e "${BOLD}[*]${RESET} $1"; }
ok() { echo -e "${GREEN}[+]${RESET} $1"; }
warn() { echo -e "${YELLOW}[!]${RESET} $1"; }
fail() { echo -e "${RED}[x]${RESET} $1" >&2; exit 1; }
# ---------
OS="$(uname -s)"
case "$OS" in
Linux|Darwin) ;;
*) fail "Unsupported OS: $OS (this installer targets Linux and macOS only)";;
esac
command -v python3 >/dev/null 2>&1 || fail "python3 is not installed."
[ -f "$ENTRYPOINT" ] || fail "Cannot find dneyes.py next to this script."
info "Creating virtual environment..."
python3 -m venv "$VENV_DIR"
info "Installing dependencies..."
"$VENV_DIR/bin/pip" install --quiet --upgrade pip
if [ -f "$SCRIPT_DIR/requirements.txt" ]; then
"$VENV_DIR/bin/pip" install --quiet -r "$SCRIPT_DIR/requirements.txt"
else
"$VENV_DIR/bin/pip" install --quiet dnspython requests
fi
ok "Dependencies installed."
if [ -w "/usr/local/bin" ]; then
BIN_DIR="/usr/local/bin"
else
BIN_DIR="$HOME/.local/bin"
mkdir -p "$BIN_DIR"
fi
LAUNCHER="$BIN_DIR/dneyes"
info "Creating launcher at $LAUNCHER ..."
cat > "$LAUNCHER" <<EOF
#!/usr/bin/env bash
exec "$VENV_DIR/bin/python" "$ENTRYPOINT" "\$@"
EOF
chmod +x "$LAUNCHER"
ok "Launcher installed."
case ":$PATH:" in
*":$BIN_DIR:"*) ;;
*) warn "$BIN_DIR is not on your PATH. Add this to your shell profile:"
echo -e " ${BOLD}export PATH=\"$BIN_DIR:\$PATH\"${RESET}";;
esac
echo
ok "Done! Run it with: ${BOLD}dneyes${RESET}"
echo -e " Example: ${BOLD}dneyes -qs example.com -ps${RESET}"