-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
120 lines (82 loc) · 2.06 KB
/
Copy pathinstall.sh
File metadata and controls
120 lines (82 loc) · 2.06 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
set -e
REPO="https://github.com/AlKurpiakov/audit"
INSTALL_DIR="$HOME/.audit"
BIN_DIR="/usr/local/bin"
TMP_DIR="/tmp/audite_install"
check_dependency(){
if ! command -v $1 >/dev/null 2>&1; then
echo "Installing dependency: $1"
if [ "$1" == "mailutils" ] && command -v apt >/dev/null 2>&1; then
echo "Configuring postfix for automatic install..."
echo "postfix postfix/main_mailer_type select Internet Site" | sudo debconf-set-selections
echo "postfix postfix/mailname string $(hostname -f)" | sudo debconf-set-selections
fi
if command -v apt >/dev/null 2>&1; then
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt install -y $1
elif command -v yum >/dev/null 2>&1; then
sudo yum install -y $1
elif command -v pacman >/dev/null 2>&1; then
sudo pacman install -y $1
else
echo "Install $1 manually"
exit 1
fi
fi
}
echo "Audit installation:"
echo
echo "Checking dependencies..."
echo
check_dependency git
check_dependency awk
check_dependency ps
check_dependency ss
check_dependency mailutils
echo "Dependencies OK"
echo
echo "Cloning repository..."
echo
rm -rf "$TMP_DIR"
git clone $REPO $TMP_DIR
echo "Installing files"
echo
rm -rf $INSTALL_DIR
mkdir -p $INSTALL_DIR
cp -r "$TMP_DIR/." "$INSTALL_DIR/"
rm -rf $TMP_DIR
chmod +x $INSTALL_DIR/audit
echo "Creating config files"
echo
read -p "Enter your e-mail for alerts: " ALERT_EMAIL </dev/tty
CFG_FILE="$INSTALL_DIR/config"
cat << EOF > "$CFG_FILE"
EMAIL=$ALERT_EMAIL
CPU_ALERT=90
MEM_ALERT=90
DISK_ALERT=90
EOF
echo "Installing audit agent service..."
SERVICE_FILE="/etc/systemd/system/audit.service"
sudo bash -c "cat > $SERVICE_FILE" <<EOF
[Unit]
Description=Audit Agent
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/audit agent
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
echo "Installing CLI"
echo
sudo ln -sf $INSTALL_DIR/audit $BIN_DIR/audit
echo "Installation complete"
echo
echo "RUN:"
echo
echo "audit dashboard"
echo