diafygi / acme-tiny

A tiny script to issue and renew TLS certs from Let's Encrypt
MIT License
4.74k stars 572 forks source link

Enable redirection of non-errors to stdout / logfile #23

Closed bwurst closed 8 years ago

bwurst commented 8 years ago

We import acme-tiny to a script on our servers, run by cron. I would like to have no output if everything is okay but sure, if errors occure, I would like to see them.

At the moment, acme-tiny writes regular status messages to stderr, so to get rid of them, I would have to trash stderr. This would hide all errors, too.

I made a proof of concept in my local fork but that pushes the code to 201 lines, so I'm not gonna make a pull request. See bwurst/acme-tiny@20be6f667e77b56db93f45bb2a626661925789bc for my current solution.

diafygi commented 8 years ago

Two options come to mind:

python acme_tiny.py --account-key ./account.key \
  --csr ./domain.csr --acme-dir /var/www/challenges/ \
  > signed.crt 2> /tmp/errors.log \
|| cat /tmp/errors.log 1>&2
drtoful commented 8 years ago

Wow, you're faster than I can code :-)

drtoful/acme-tiny@30c53c4

The default behavior is the same as before, so it should not break anything for current users. I also took the liberty and compacted some code, so I got below 200 lines.

The script also now accepts "ca" and "out" as parameters, so that I can get rid of some nasty redirects. Also the "ca" option is pretty good if you have a testing server and don't want to fiddle around in the code everytime you want to change it.

diafygi commented 8 years ago

@bwurst added a --quiet parameter to suppress output except for errors

@drtoful Thanks, a lot of the compacting was done by @somecoder42, and it looks like you've got similar things.

FYI, probably not going to accept the CA and out parameters in a pull request. Out doesn't really add much, and I'd like to keep CA at the module level to be able to monkey patch it with the staging CA if I ever get around to writing tests for this.

drtoful commented 8 years ago

Hi

I'm not finished discussing this :-)

The way I added the CA parameter, was as an argument to "get_cert" (with default value for the productive servers), so you can still "monkey patch" it during testing, by providing a different URL that way. I don't like configuration within code (especially when I import it), and I don't think it's good practice anyway. Furthermore I can use the same script for staging and production and I do not have to have two copies lying around.

I can create a new pull request for that if you want ^^

The out parameter is just for good measure to get rid of redirects in my scripts. But since I'm changing anyway to a pure python solution for automation I don't really need it. Just tried to sneak in that change.

Kind Regards

2015-12-06 1:56 GMT+01:00 Daniel Roesler notifications@github.com:

@bwurst https://github.com/bwurst added a --quiet parameter to suppress output except for errors

@drtoful https://github.com/drtoful Thanks, a lot of the compacting was done by @somecoder42 https://github.com/somecoder42, and it looks like you've got similar things.

FYI, probably not going to accept the CA and out parameters in a pull request. Out doesn't really add much, and I'd like to keep CA at the module level to be able to monkey patch it with the staging CA if I ever get around to writing tests for this.

— Reply to this email directly or view it on GitHub https://github.com/diafygi/acme-tiny/issues/23#issuecomment-162260841.

diafygi commented 8 years ago

ok, will review a pull request for the CA parameter