Files
server/scripts/dkim.sh
StephanandStefan d596670f6b Add mail functionality into the development branch (#12)
* Added basic code for sending emails
+ Added tests for emails
+ Modified README.md to reflect changes to .env file

* [create-pull-request] push formatted files

* Added dkim

* Fixed mistake in docker-compose.yml

Co-authored-by: Stefan <[email protected]>
2021-11-03 11:01:37 +01:00

33 lines
886 B
Bash
Executable File

#! /bin/bash
#load .env file
[[ -f .env ]] || { echo "`tput setaf 1`✗`tput sgr0` Could not find .env file are you in the correct directory (you should be in the server directory)"; exit 1;}
set -o allexport
[[ -f .env ]] && source .env
set +o allexport
#static variables
NC='tput sgr0' #No Color
GREEN='tput setaf 2'
RED='tput setaf 1'
#check dependencies
command -v opendkim-genkey >/dev/null 2>&1 || { echo >&2 "`$RED`✗`$NC` Opendkim not installed install with your favorite package manager (opendkim-tools | opendkim-utils)"; exit 1;}
#generate dkim keys
mkdir -p ./host/keys
echo "`$GREEN`✓`$NC` Created folder"
cd ./host/keys
opendkim-genkey -b 2048 -h rsa-sha256 -r -v --subdomains -s mail -d mail.$DOMAIN
sed -i 's/h=rsa-sha256/sha256/' mail.txt
mv mail.private mail.$DOMAIN.private
mv mail.txt mail.$DOMAIN.txt
echo "`$GREEN`✓`$NC` Generated dkim keys"
exit 0