Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·52 lines (47 loc) · 1.75 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·52 lines (47 loc) · 1.75 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
#!/usr/bin/env bash
# MacClean installer — copies macclean + avscan into ~/.local/bin and fixes PATH.
# ./install.sh tools only
# ./install.sh --with-av also install ClamAV (Homebrew) + fetch signatures
set -euo pipefail
SRC="$(cd "$(dirname "$0")" && pwd)"
BIN="$HOME/.local/bin"
WITH_AV=0
[ "${1:-}" = "--with-av" ] && WITH_AV=1
mkdir -p "$BIN"
install -m 0755 "$SRC/bin/macclean" "$BIN/macclean"
install -m 0755 "$SRC/bin/avscan" "$BIN/avscan"
echo ">> installed macclean + avscan -> $BIN"
case ":$PATH:" in
*":$BIN:"*) ;;
*)
added=0
for rc in "$HOME/.zshrc" "$HOME/.bashrc" "$HOME/.bash_profile"; do
[ -e "$rc" ] || continue
grep -q '\.local/bin' "$rc" && continue
printf '\nexport PATH="$HOME/.local/bin:$PATH"\n' >> "$rc"
echo ">> added ~/.local/bin to PATH in $rc"
added=1
done
[ "$added" -eq 0 ] && echo ">> add ~/.local/bin to your PATH manually"
echo ">> open a new shell for PATH to take effect"
;;
esac
if [ "$WITH_AV" -eq 1 ]; then
if ! command -v brew >/dev/null 2>&1; then
echo "!! Homebrew not found — install it first: https://brew.sh" >&2
exit 1
fi
brew list clamav >/dev/null 2>&1 || brew install clamav
CONF="$(brew --prefix)/etc/clamav"
if [ ! -f "$CONF/freshclam.conf" ]; then
sed -e 's/^Example/#Example/' "$CONF/freshclam.conf.sample" > "$CONF/freshclam.conf"
echo ">> wrote $CONF/freshclam.conf"
fi
mkdir -p "$(brew --prefix)/var/log"
echo ">> fetching ClamAV signatures (first run downloads ~1 GB)..."
freshclam || echo "!! freshclam reported an error; re-run 'freshclam' later"
echo ">> ClamAV ready — try: macclean scan ~/Downloads"
else
echo ">> for 'macclean scan', run: ./install.sh --with-av"
fi
echo ">> done. Try: macclean checkup"