Merge pull request #2 from MugoSquero/feature-config

Adds support for configuring variables from a JSON file
This commit is contained in:
Yusuf İpek
2023-10-31 19:06:45 +03:00
committed by GitHub
4 changed files with 68 additions and 39 deletions
+6 -4
View File
@@ -23,8 +23,9 @@ Before using the script, you need to have the following prerequisites in place:
## Configuration
You need to configure the script with your SMTP server settings and email details. Open the script and modify the following variables in the "Configuration" section:
You need to configure the config.json file with your SMTP server settings and email details. Open the config file and modify the following variables:
- `config.json`: JSON configuration file containing the following settings:
- `smtp_host`: SMTP server hostname.
- `smtp_port`: SMTP server port.
- `smtp_user`: Your SMTP server username.
@@ -42,12 +43,12 @@ You need to configure the script with your SMTP server settings and email detail
## Customization
You can customize the email content by modifying the following variables in the script:
You can customize the email content by modifying the following variables in the config:
- `reminder_subject`: Subject for the reminder email.
- `reminder_message`: Message for the reminder email.
- `dead_man_subject`: Subject for the Dead Man's Switch activation email.
- `dead_man_message`: Message for the Dead Man's Switch activation email.
- `dead_man_activation_subject`: Subject for the Dead Man's Switch activation email.
- `dead_man_activation_message`: Message for the Dead Man's Switch activation email.
## Usage
@@ -65,6 +66,7 @@ You can customize the email content by modifying the following variables in the
- [Yusuf İpek](https://github.com/yusufipk)
- [Koray Üstündağ](https://github.com/korayustundag)
- [Mugo Squero](https://github.com/MugoSquero)
## License
This script is provided under the GPL-3.0 License. You are free to use, modify, and distribute it as needed. See the [LICENSE](https://github.com/yusufipk/dead-man-message/blob/master/LICENSE) file for details.
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/bash
# Save the current timestamp to your checkin file
date +%s > ./checkin_file.txt
date +%s > "$(jq -r .checkin_file config.json)"
echo "Checked in"
+25 -20
View File
@@ -4,33 +4,38 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
import json
# Load configuration from JSON file
with open('config.json', 'r') as config_file:
config = json.load(config_file)
# Configuration
smtp_host = 'your_smpt_server' # SMTP server hostname
smtp_port = 587 # SMTP server port
smtp_user = 'username' # SMTP server username
smtp_password = 'password' # SMTP server password
from_email = 'coming_from' # Sender's email address
to_email = 'going_to' # Recipient's email address
checkin_file = "./checkin_file.txt" # File path for check-in timestamp
counter_file = "./counter_file.txt" # File path for email counter
DAYS_REMINDER = 25 # Days for the reminder period
DAYS_DEADMAN = 30 # Days for the dead man's switch
SECONDS_IN_A_DAY = 86400 # Number of seconds in a day
count_sent_mail = 7 # Number of dead man mails to send after activation.
smtp_host = config['smtp_host'] # SMTP server hostname
smtp_port = config['smtp_port'] # SMTP server port
smtp_user = config['smtp_user'] # SMTP server username
smtp_password = config['smtp_password'] # SMTP server password
from_email = config['from_email'] # Sender's email address
to_email = config['to_email'] # Recipient's email address
checkin_file = config['checkin_file'] # File path for check-in timestamp
counter_file = config['counter_file'] # File path for email counter
DAYS_REMINDER = config['DAYS_REMINDER'] # Days for the reminder period
DAYS_DEADMAN = config['DAYS_DEADMAN'] # Days for the dead man's switch
SECONDS_IN_A_DAY = config['SECONDS_IN_A_DAY'] # Number of seconds in a day
count_sent_mail = config['count_sent_mail'] # Number of dead man mails to send after activation.
family_members = ['[email protected]'] # List of family members' email addresses
family_members = config['family_members'] # List of family members' email addresses
# Email content
reminder_subject = "REMINDER" # Subject for the reminder email
reminder_message = "Please check-in" # Message for the reminder email
reminder_subject = config['reminder_subject'] # Subject for the reminder email
reminder_message = config['reminder_message'] # Message for the reminder email
dead_man_activation_subject = "Dead Man's Switch Activated" # Subject for the activation email
dead_man_activation_message = "You forgot to check-in" # Message for the activation email
dead_man_activation_subject = config['dead_man_activation_subject'] # Subject for the activation email
dead_man_activation_message = config['dead_man_activation_message'] # Message for the activation email
dead_man_subject = "I Am Gone" # Subject for the dead man's switch email
dead_man_message = "I'm dead" # Message for the dead man's switch email
files_to_attach = ['file.gpg'] # List of files to attach
dead_man_subject = config['dead_man_subject'] # Subject for the dead man's switch email
dead_man_message = config['dead_man_message'] # Message for the dead man's switch email
files_to_attach = config['files_to_attach'] # List of files to attach
# Function to send an email
def send_email(subject, message, to, attachments=[]):
+22
View File
@@ -0,0 +1,22 @@
{
"smtp_host": "your_smpt_server",
"smtp_port": 587,
"smtp_user": "username",
"smtp_password": "password",
"from_email": "coming_from",
"to_email": "going_to",
"checkin_file": "./checkin_file.txt",
"counter_file": "./counter_file.txt",
"DAYS_REMINDER": 25,
"DAYS_DEADMAN": 30,
"SECONDS_IN_A_DAY": 86400,
"count_sent_mail": 7,
"family_members": ["[email protected]"],
"reminder_subject": "REMINDER",
"reminder_message": "Please check-in",
"dead_man_activation_subject": "Dead Man's Switch Activated",
"dead_man_activation_message": "You forgot to check-in",
"dead_man_subject": "I Am Gone",
"dead_man_message": "I'm dead",
"files_to_attach": ["file.gpg"]
}