Cron

從 cron 執行時讓我們加密 certbot-auto setuptools 版本錯誤

  • September 3, 2017

CentOS 6,證書機器人 0.16.0。當我以 root 身份(而不是 sudo)手動執行它時,一切正常。當我設置 /etc/crontab 自動執行它時,它返回一個錯誤:

Error: couldn't get currently installed version for //.local/share/letsencrypt/bin/letsencrypt: 
//.local/share/letsencrypt/lib64/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the   Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
 DeprecationWarning
An unexpected error occurred:
ContextualVersionConflict: (setuptools 0.9.8 (/.local/share/letsencrypt/lib/python2.6/site-packages), Requirement.parse('setuptools>=1.0'), set(['certbot']))
Please see the logfile '/tmp/tmp5jOtY3' for more details.`

貓 /tmp/tmp5jOtY3

2017-07-31 11:37:02,325:DEBUG:certbot.log:Exiting abnormally:
Traceback (most recent call last):
 File "//.local/share/letsencrypt/bin/letsencrypt", line 11, in <module>
sys.exit(main())
 File "//.local/share/letsencrypt/lib64/python2.6/site-packages/certbot/main.py", line 723, in main
plugins = plugins_disco.PluginsRegistry.find_all()
 File "//.local/share/letsencrypt/lib64/python2.6/site-packages/certbot/plugins/disco.py", line 203, in find_all
plugin_ep = PluginEntryPoint(entry_point)
 File "//.local/share/letsencrypt/lib64/python2.6/site-packages/certbot/plugins/disco.py", line 50, in __init__
self.plugin_cls = entry_point.load()
 File "//.local/share/letsencrypt/lib64/python2.6/site-packages/pkg_resources/__init__.py", line 2201, in load
self.require(*args, **kwargs)
 File "//.local/share/letsencrypt/lib64/python2.6/site-packages/pkg_resources/__init__.py", line 2218, in require
items = working_set.resolve(reqs, env, installer)
 File "//.local/share/letsencrypt/lib64/python2.6/site-packages/pkg_resources/__init__.py", line 835, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
ContextualVersionConflict: (setuptools 0.9.8 (/.local/share/letsencrypt/lib/python2.6/site-packages), Requirement.parse('setuptools>=1.0'), set(['certbot']))

貓 /etc/crontab

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

27  18  *  *  * root /opt/certbot-auto renew --quiet --no-self-upgrade

我嘗試了 Let’s Encrypt 社區,發現有人遇到了這個確切的問題,但提供的唯一幫助是遷移到 bash 腳本。我寧願修復官方腳本。

讓我們加密論壇文章

這是問題:

HOME=/

要修復它,需要將帶有 /root 值的 HOME 變數傳遞給腳本:

env HOME=/root /path/to/certbot-auto

引用自:https://serverfault.com/questions/866010