#!/bin/sh

if [ -z "$(printenv SUDO_USER)" ]
then
	echo "Please execute script as sudo"
	exit 0
fi

workingDir=$(realpath $0 | sed 's/scripts\/.*//')

cat /etc/letsencrypt/live/mail.mail-ost.ch/cert.pem > /home/rcvijano/dsys-mailserver/data/mail-ost.ch/mail.mail-ost.ch.crt
cat /etc/letsencrypt/live/mail.mail-ost.ch/chain.pem > /home/rcvijano/dsys-mailserver/data/mail-ost.ch/mail.mail-ost.ch.issuer.crt
cat /etc/letsencrypt/live/mail.mail-ost.ch/fullchain.pem > /home/rcvijano/dsys-mailserver/data/mail-ost.ch/mail.mail-ost.ch.pem
cat /etc/letsencrypt/live/mail.mail-ost.ch/privkey.pem > /home/rcvijano/dsys-mailserver/data/mail-ost.ch/mail.mail-ost.ch.key

chown -R $SUDO_USER: ${workingDir}

