2 # -*- mode: python; coding: utf-8-unix; -*-
5 import argparse, ConfigParser, os, sys, textwrap
9 print ("crypto-install.py GIT-TAG (GIT-REVISION)")
12 def input_string (prompt=""):
13 if sys.version_info[0] == 2:
14 return raw_input(prompt)
18 def parse_arguments ():
19 parser = argparse.ArgumentParser ()
23 action = "store_true",
24 help = "Display version.")
28 action = "store_false",
29 help = "Disable GnuPG setup.")
33 action = "store_false",
34 help = "Disable OpenSSH setup.")
37 dest = "openssh_config",
38 default = "~/.ssh/config",
39 help = "Set path for OpenSSH configuration file.")
40 return parser.parse_args ()
45 print("Default GnuPG key already exists.")
48 print (textwrap.fill (textwrap.dedent("""\
49 No default GnuPG key available. Please enter your information to
50 create a new key."""), width = 80))
52 name = input_string("What is your name? (Max Mustermann) ")
53 email = input_string("What is your email address? (max@example.de) ")
54 motto = input_string("What is your motto phrase, if any? (Schlüssel für 2014) ")
57 def openssh_setup (arguments):
58 if not os.path.exists(arguments.openssh_config):
59 with open(arguments.openssh_config, "w") as ssh_config:
60 ssh_config.write(textwrap.dedent("""\
65 if os.path.exists (os.path.expanduser ("~/.ssh/id_rsa")) \
66 or os.path.exists (os.path.expanduser ("~/.ssh/id_dsa")):
67 print("OpenSSH key already exists.")
70 print (textwrap.fill (textwrap.dedent("""\
71 No OpenSSH key available. Generating new key."""), width = 80))
73 os.system ("ssh-keygen")
77 args = parse_arguments ()
90 if __name__ == "__main__":