Merge pull request #197 from ThomasWaldmann/help-no-sudo

check late for root, so letsencrypt --help also works without being root
This commit is contained in:
James Kasten 2015-01-25 19:19:27 -08:00
commit 248407c70e

View file

@ -19,11 +19,6 @@ from letsencrypt.client.apache import configurator
def main(): # pylint: disable=too-many-statements
"""Command line argument parsing and main script execution."""
if not os.geteuid() == 0:
sys.exit(
"{0}Root is required to run letsencrypt. Please use sudo.{0}"
.format(os.linesep))
parser = argparse.ArgumentParser(
description="An ACME client that can update Apache configurations.")
@ -63,8 +58,15 @@ def main(): # pylint: disable=too-many-statements
parser.add_argument("--test", dest="test", action="store_true",
help="Run in test mode.")
# note: arg parser internally handles --help (and exits afterwards)
args = parser.parse_args()
# note: check is done after arg parsing as --help should work w/o root also.
if not os.geteuid() == 0:
sys.exit(
"{0}Root is required to run letsencrypt. Please use sudo.{0}"
.format(os.linesep))
# Set up logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)