On Mon, Mar 25, 2019 at 02:49:01PM +0100, Solene Rapenne wrote:
> On Mon, Mar 25, 2019 at 02:27:19PM +0100, Mischa wrote:
> > 
> > 
> > > On 25 Mar 2019, at 01:40, Stuart Henderson <[email protected]> wrote:
> > > 
> > > On 2019-03-23, Mischa <[email protected]> wrote:
> > >> Hi Geir,
> > >> 
> > >> I have solved this with a little script.
> > >> 
> > >> ###
> > >> #!/bin/sh
> > >> OUT=2
> > >> /usr/sbin/acme-client -v www.example.com
> > >> if test  $? -eq 0
> > >> then EXT=$?
> > >> fi
> > >> /usr/sbin/acme-client -v www.example1.com
> > >> if test $? -eq 0
> > >> then EXT=$?
> > >> fi
> > >> if test $EXT -eq 0
> > >> then
> > >>        echo "New certificates installed."
> > >>        rcctl restart httpd
> > >> else echo "No new certificates installed."
> > >> fi
> > >> ###
> > > 
> > > Simpler:
> > > 
> > > for i in www.example.com www.example1.com; do
> > >  acme-client -v $i && reload=y
> > > done
> > > [[ -n $reload ]] && rcctl reload httpd
> > 
> > Nice!! I have a couple of more domains in there, so the 'for' becomes a 
> > little ugly, but I keep forgetting &&.
> > It's indeed not needed to use the actual exit code.
> > 
> > Mischa
> > 
> > 
> 
> One could easily write something like this:
> 
> #!/bin/sh
> 
> UPDATE=0
> for domain in $(awk '/^domain/ { print $2 }' /etc/acme-client.conf)
> do
>       acme-client $domain
>       if [ $? -eq 0 ]; then UPDATE=1 fi
> done
> 
> if [ $UPDATE -ne 0 ]; then
>       rcctl restart httpd dovecot smtpd
> fi
> 
> you could also handle the exit status per domain if you want more
> informations. I did write the script for this mail, it may contains
> errors.
> 
Thanks a lot, everybody, for helping.
Very nice solutions.
/Geir

Reply via email to