feat: rework entire repo structure

This commit is contained in:
2026-02-28 21:31:18 +01:00
parent 98ae07ae88
commit fcbfd3a838
12 changed files with 214 additions and 254 deletions

40
sshd-login.sh Normal file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
PROJECT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
readonly PROJECT_DIR 2>/dev/null
source $PROJECT_DIR/utils.sh
INSTALLED=$1
if [[ "--install" == $INSTALLED ]]; then
log_info "sshd-login Installation"
login="session optional pam_exec.so $PROJECT_DIR/sshd-login.sh"
file='/etc/pam.d/common-session'
if [[ ! -f "$file" ]]; then
log_error "$file doesn't found."
exit 1
fi
if ! grep -Fxq "$login" "$file"; then
echo "$login" >>"$file"
log_success "login command added to $file."
else
log_warn "login command already added to $file." $WARN_FLAG
fi
exit 0
fi
case "$PAM_TYPE" in
open_session)
PAYLOAD=$(printf "<b>🚨 Login Event 🚨</b>\nUser <code>%s</code> logged in from <code>%s</code> at <i>%s</i>." "$PAM_USER" "$PAM_RHOST" "$(date)")
;;
close_session)
PAYLOAD=$(printf "<b>🚨 Logout Event 🚨</b>\nUser <code>%s</code> logged out from <code>%s</code> at <i>%s</i>." "$PAM_USER" "$PAM_RHOST" "$(date)")
;;
esac
if [ -n "$PAYLOAD" ]; then
send_notification "$PAYLOAD"
fi