#!/bin/bash

if [ -f "%%le_ssl_cert" ]; then
    cp -f "%%le_ssl_cert" "%%server_cert"
    chown root: %%server_cert
    chmod 644 %%server_cert
fi
if [ -f "%%le_ssl_key" ]; then
    cp -f "%%le_ssl_key" "%%server_key"
    chown root: %%server_key
    chmod 600 %%server_key
fi
if [ -f "%%le_ssl_cert" ] && [ -f "%%le_ssl_key" ]; then
    cat "%%le_ssl_cert" "%%le_ssl_key" > "%%server_pem"
    chown root: %%server_pem
    chmod 600 %%server_pem
fi
if [ -f "%%le_ssl_pem" ]; then
    cp -f "%%le_ssl_pem" "%%server_full_chain_pem"
    chown root: %%server_full_chain_pem
    chmod 600 %%server_full_chain_pem
fi

exit 0
