From d1ee72bf548a8ca698e71e97b38199840a14d19d Mon Sep 17 00:00:00 2001 From: jank Date: Thu, 11 Sep 2025 08:48:49 +0000 Subject: [PATCH] feat: Add cronmail --- cronmail.bash | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 cronmail.bash diff --git a/cronmail.bash b/cronmail.bash new file mode 100644 index 0000000..28b3da2 --- /dev/null +++ b/cronmail.bash @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +apt purge postfix +apt-get install msmtp msmtp-mta mailutils + +read -p "Please enter the pass for cron@kjan.email: " pass + +echo "defaults +port 465 +tls on +auth on +syslog on +tls_starttls off + +account default +host box.kjan.email +from cron@kjan.email +user cron@kjan.email +password $pass +" >> /etc/msmtprc + +NEW_CRON_JOB=" +MAILTO="jan@kjan.email" +SHELL=/bin/bash +HOME=/ +" +read -p "Enter usename for cron: " USERNAME # Replace with the actual username + +# Check if the line already exists to avoid duplicates +if ! crontab -u "$USERNAME" -l | grep -Fq "$NEW_CRON_JOB"; then + (crontab -u "$USERNAME" -l; echo "$NEW_CRON_JOB") | crontab -u "$USERNAME" - + echo "Added '$NEW_CRON_JOB' to $USERNAME's crontab." +else + echo "'$NEW_CRON_JOB' already exists in $USERNAME's crontab. Skipping." +fi \ No newline at end of file