feat: Add cronmail
This commit is contained in:
parent
23ec9f6fa9
commit
d1ee72bf54
1 changed files with 34 additions and 0 deletions
34
cronmail.bash
Normal file
34
cronmail.bash
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue