def init_token(self, user=None): """ Initializes a new SoftHSM token created by the configuration :param user: user to initialize token under :return: """ util.make_or_verify_dir(self.SOFTHSM_DB_DIR, mode=0o755) cmd = 'softhsm --init-token --slot 0 --pin 0000 --so-pin 0000 --label ejbca' if user is None: out, err = util.run_script(cmd.split(' ')) return out, err else: util.chown(self.SOFTHSM_DB_DIR, user, user) cmd_sudo = ['sudo', '-E', '-H', '-u', user, '/bin/bash', '-c', cmd] return util.run_script(cmd_sudo)
def run_script(self, script, host=None): from util import run_script return run_script(self, script, host or self.host)
def main(args=None): """Main entry-point for running this script. This function parses command-line arguments and passes them on to the remove_node() function. """ usage = "usage: %prog [options] node_name" descr = "Remove a node from the tokenserver database" parser = optparse.OptionParser(usage=usage, description=descr) parser.add_option("-v", "--verbose", action="count", dest="verbosity", help="Control verbosity of log messages") opts, args = parser.parse_args(args) if len(args) != 1: parser.print_usage() return 1 util.configure_script_logging(opts) node_name = args[0] remove_node(node_name) return 0 if __name__ == "__main__": util.run_script(main)