This repository was archived by the owner on Mar 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·79 lines (67 loc) · 2.07 KB
/
install.sh
File metadata and controls
executable file
·79 lines (67 loc) · 2.07 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
#!/bin/bash
set -e
VENV_PATH="/opt/ldap-watchdog"
if [ ! -d "$VENV_PATH" ]; then
python3 -m venv "$VENV_PATH"
fi
"$VENV_PATH/bin/pip" install --upgrade pip
"$VENV_PATH/bin/pip" install "LDAP-Monitor[slack]"
if [ "$#" -eq 1 ]; then
SLACK_WEBHOOK_URL=$1
fi
# Step 1: Create an environment file for configuration
LDAP_DIFF_ENV_FILE="/etc/ldap-watchdog.env"
if [ ! -f "$LDAP_DIFF_ENV_FILE" ]; then
cat <<EOL > $LDAP_DIFF_ENV_FILE
# LDAP Watchdog Configuration
# See README.md for all available environment variables.
LDAP_WATCHDOG_SERVER=
LDAP_WATCHDOG_BASE_DN=
LDAP_WATCHDOG_USERNAME=
LDAP_WATCHDOG_PASSWORD=
LDAP_WATCHDOG_USE_SSL=true
LDAP_WATCHDOG_REFRESH_RATE=60
SLACK_WEBHOOK_URL=$SLACK_WEBHOOK_URL
EOL
chmod 600 "$LDAP_DIFF_ENV_FILE"
echo "Created $LDAP_DIFF_ENV_FILE - edit this file to configure LDAP Watchdog."
fi
# Step 2: Create a service file and logrotate configuration for ldap-watchdog
LDAP_DIFF_LOG_FILE="/var/log/ldap-watchdog.log"
LDAP_DIFF_ERROR_LOG_FILE="/var/log/ldap-watchdog-error.log"
LDAP_DIFF_SERVICE_FILE="/etc/systemd/system/ldap-watchdog.service"
LDAP_DIFF_LOGROTATE_FILE="/etc/logrotate.d/ldap-watchdog"
cat <<EOL > $LDAP_DIFF_SERVICE_FILE
[Unit]
Description=ldap-watchdog Service
After=network.target
[Service]
Type=simple
ExecStart=$VENV_PATH/bin/ldap-watchdog
Restart=always
DynamicUser=yes
EnvironmentFile=$LDAP_DIFF_ENV_FILE
StandardOutput=append:$LDAP_DIFF_LOG_FILE
StandardError=append:$LDAP_DIFF_ERROR_LOG_FILE
[Install]
WantedBy=multi-user.target
EOL
cat <<EOL > $LDAP_DIFF_LOGROTATE_FILE
$LDAP_DIFF_LOG_FILE $LDAP_DIFF_ERROR_LOG_FILE {
monthly
rotate 12
compress
missingok
notifempty
copytruncate
}
EOL
systemctl daemon-reload
systemctl enable ldap-watchdog
systemctl start ldap-watchdog
echo "ldap-watchdog has been installed, the service is started, and log rotation is set up."
echo " - Configuration: $LDAP_DIFF_ENV_FILE"
echo " - Virtual env: $VENV_PATH"
echo " - Systemd service: $LDAP_DIFF_SERVICE_FILE"
echo " - Logs: $LDAP_DIFF_LOG_FILE and $LDAP_DIFF_ERROR_LOG_FILE"
echo " - Log rotation conf: $LDAP_DIFF_LOGROTATE_FILE"