Commit 10a4d86a authored by Michał Woźniak's avatar Michał Woźniak
Browse files

initial import

parent e3e102e1
gitlab-runner ALL=(root) NOPASSWD: ! /usr/local/sbin/install-infra-certs.sh , /usr/local/sbin/install-infra-certs.sh ""
#!/bin/bash
set -e
# loop through YNH domains
for d in `yunohost domain list --output=plain`; do
echo "- $d"
if [ ! -d "live/$d" ]; then
echo " - skip..."
continue
fi
cd "live/$d"
DATE_TAG="$( date -d "`openssl x509 -noout -text -in cert | grep 'Not Before' | cut -d ':' -f 2-`" +"%Y%m%d.%H%M%S" )"
echo " - $DATE_TAG"
# make sure the target directory exists
mkdir -p "/etc/yunohost/certs/${d}-history/${DATE_TAG}-infra-certs/"
# copy cert and key to it
cp fullchain "/etc/yunohost/certs/${d}-history/${DATE_TAG}-infra-certs/crt.pem"
cp privkey "/etc/yunohost/certs/${d}-history/${DATE_TAG}-infra-certs/key.pem"
# fix ownership and permissions
chown -R root:ssl-cert "/etc/yunohost/certs/${d}-history/${DATE_TAG}-infra-certs/"
chmod -R u=rwX,g=rX,o= "/etc/yunohost/certs/${d}-history/${DATE_TAG}-infra-certs/"
# handle the symlink
if [ -e "/etc/yunohost/certs/${d}" ]; then
# it exists! is it a directory? or a symlink?
if [ -h "/etc/yunohost/certs/${d}" ]; then
rm "/etc/yunohost/certs/${d}"
elif [ -d "/etc/yunohost/certs/${d}" ]; then
mv "/etc/yunohost/certs/${d}" "/etc/yunohost/certs/${d}-history/$( date +"%Y%m%d.%H%M%S" )-backup"
else
echo "ERROR: neither a directory nor a symlink: /etc/yunohost/certs/${d}"
exit 1
fi
fi
ln -s "/etc/yunohost/certs/${d}-history/${DATE_TAG}-infra-certs/" "/etc/yunohost/certs/${d}"
cd ../../
done
echo "restarting services..."
yunohost service restart postfix dovecot metronome
echo "restarting nginx..."
yunohost tools regen-conf nginx
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment