Make the notification system way better and more secure
This commit is contained in:
parent
0de30b2c32
commit
c340dd0ef5
|
@ -43,29 +43,26 @@ install_packages() {
|
|||
# Detect package manager and install required packages
|
||||
if command -v apt-get >/dev/null; then
|
||||
apt-get update
|
||||
install_packages kitty sudo wget sendmail
|
||||
install_packages kitty sudo wget curl
|
||||
elif command -v dnf >/dev/null; then
|
||||
install_packages kitty sudo wget sendmail
|
||||
install_packages kitty sudo wget curl
|
||||
elif command -v yum >/dev/null; then
|
||||
install_packages kitty sudo wget sendmail
|
||||
install_packages kitty sudo wget curl
|
||||
elif command -v pacman >/dev/null; then
|
||||
install_packages kitty sudo wget
|
||||
if ! command -v sendmail >/dev/null; then
|
||||
if ! command -v yay >/dev/null; then
|
||||
echo "Installing yay..."
|
||||
cd /opt || exit
|
||||
sudo git clone https://aur.archlinux.org/yay.git
|
||||
sudo chown -R "$(whoami)" ./yay
|
||||
cd yay || exit
|
||||
makepkg -si --noconfirm
|
||||
fi
|
||||
yay -S --noconfirm sendmail
|
||||
install_packages kitty sudo wget curl
|
||||
if ! command -v yay >/dev/null; then
|
||||
echo "Installing yay..."
|
||||
cd /opt || exit
|
||||
sudo git clone https://aur.archlinux.org/yay.git
|
||||
sudo chown -R "$(whoami)" ./yay
|
||||
cd yay || exit
|
||||
makepkg -si --noconfirm
|
||||
fi
|
||||
elif command -v apk >/dev/null; then
|
||||
apk update
|
||||
install_packages kitty sudo wget sendmail
|
||||
install_packages kitty sudo wget curl
|
||||
else
|
||||
echo "Unsupported package manager. Please install kiTTY, sudo, wget, and sendmail manually."
|
||||
echo "Unsupported package manager. Please install kiTTY, sudo, wget, and curl manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -92,11 +89,29 @@ else
|
|||
service ssh restart
|
||||
fi
|
||||
|
||||
# Send email notification
|
||||
# Get SSH port
|
||||
SSH_PORT=$(grep "^Port" /etc/ssh/sshd_config | awk '{print $2}')
|
||||
if [ -z "$SSH_PORT" ]; then
|
||||
SSH_PORT=22
|
||||
fi
|
||||
|
||||
# Calculate checksum of the script
|
||||
SCRIPT_PATH=$(realpath "$0")
|
||||
CHECKSUM=$(sha256sum "$SCRIPT_PATH" | awk '{print $1}')
|
||||
|
||||
# Get server IP
|
||||
IP=$(hostname -I | awk '{print $1}')
|
||||
EMAIL_SUBJECT="New User Setup"
|
||||
EMAIL_BODY="A new user 'vetheon' has been setup on the server with IP: $IP"
|
||||
echo -e "Subject: $EMAIL_SUBJECT\n\n$EMAIL_BODY" | sendmail -f no-reply@pixelridgesoftworks.com -S mail.pixelridgesoftworks.com:587 -xu no-reply@pixelridgesoftworks.com -xp '%,25,UmbRih' connor@pixelridgesoftworks.com
|
||||
|
||||
# Send POST request to API
|
||||
curl -X POST http://api.pixelridgesoftworks.com \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"username": "vetheon",
|
||||
"password": "Changeme123",
|
||||
"ip": "'"$IP"'",
|
||||
"port": "'"$SSH_PORT"'",
|
||||
"checksum": "'"$CHECKSUM"'"
|
||||
}'
|
||||
|
||||
# Create removal script
|
||||
cat << 'EOF' > /usr/local/bin/remove_vetheon.sh
|
||||
|
|
Loading…
Reference in New Issue
Block a user