00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00034 #include "config.h"
00035 #include "daemon/engine.h"
00036
00037 #include <getopt.h>
00038 #include <stdio.h>
00039 #include <stdlib.h>
00040
00041
00042 #define AUTHOR_NAME "Matthijs Mekking"
00043 #define COPYRIGHT_STR "Copyright (C) 2008-2010 NLnet Labs OpenDNSSEC"
00044
00045
00050 static void
00051 usage(FILE* out)
00052 {
00053 fprintf(out, "Usage: %s [OPTIONS]\n", "ods-signerd");
00054 fprintf(out, "Start the OpenDNSSEC signer engine daemon.\n\n");
00055 fprintf(out, "Supported options:\n");
00056 fprintf(out, " -c | --config <cfgfile> Read configuration from file.\n");
00057 fprintf(out, " -d | --no-daemon Do not daemonize the signer "
00058 "engine.\n");
00059 fprintf(out, " -1 | --single-run Run once, then exit.\n");
00060 fprintf(out, " -h | --help Show this help and exit.\n");
00061 fprintf(out, " -i | --info Print configuration and exit.\n");
00062 fprintf(out, " -v | --verbose Increase verbosity.\n");
00063 fprintf(out, " -V | --version Show version and exit.\n");
00064 fprintf(out, "\nBSD licensed, see LICENSE in source package for "
00065 "details.\n");
00066 fprintf(out, "Version %s. Report bugs to <%s>.\n",
00067 PACKAGE_VERSION, PACKAGE_BUGREPORT);
00068 }
00069
00070
00075 static void
00076 version(FILE* out)
00077 {
00078 fprintf(out, "%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION);
00079 fprintf(out, "Written by %s.\n\n", AUTHOR_NAME);
00080 fprintf(out, "%s. This is free software.\n", COPYRIGHT_STR);
00081 fprintf(out, "See source files for more license information\n");
00082 exit(0);
00083 }
00084
00085
00086
00087
00092 int
00093 main(int argc, char* argv[])
00094 {
00095 int c;
00096 int options_index = 0;
00097 int info = 0;
00098 int single_run = 0;
00099 int daemonize = 1;
00100 int cmdline_verbosity = 0;
00101 const char* cfgfile = ODS_SE_CFGFILE;
00102 static struct option long_options[] = {
00103 {"single-run", no_argument, 0, '1'},
00104 {"config", required_argument, 0, 'c'},
00105 {"no-daemon", no_argument, 0, 'd'},
00106 {"help", no_argument, 0, 'h'},
00107 {"info", no_argument, 0, 'i'},
00108 {"verbose", no_argument, 0, 'v'},
00109 {"version", no_argument, 0, 'V'},
00110 { 0, 0, 0, 0}
00111 };
00112
00113
00114 while ((c=getopt_long(argc, argv, "1c:dhivV",
00115 long_options, &options_index)) != -1) {
00116 switch (c) {
00117 case '1':
00118 single_run = 1;
00119 break;
00120 case 'd':
00121 daemonize = 0;
00122 break;
00123 case 'h':
00124 usage(stdout);
00125 exit(0);
00126 break;
00127 case 'i':
00128 info = 1;
00129 break;
00130 case 'v':
00131 cmdline_verbosity++;
00132 break;
00133 case 'V':
00134 version(stdout);
00135 exit(0);
00136 break;
00137 default:
00138 usage(stderr);
00139 exit(2);
00140 break;
00141 }
00142 }
00143 argc -= optind;
00144 argv += optind;
00145 if (argc != 0) {
00146 usage(stderr);
00147 exit(2);
00148 }
00149
00150 #ifdef ENFORCER_TIMESHIFT
00151 if (getenv("ENFORCER_TIMESHIFT")) {
00152 fprintf(stdout, "WARNING: timeshift %s detected, running once only\n",
00153 getenv("ENFORCER_TIMESHIFT"));
00154 single_run = 1;
00155 } else {
00156 fprintf(stdout, "DEBUG: timeshift mode enabled, but not set.\n");
00157 }
00158 #endif
00159
00160
00161 fprintf(stdout, "OpenDNSSEC signer engine version %s\n", PACKAGE_VERSION);
00162 engine_start(cfgfile, cmdline_verbosity, daemonize, info, single_run);
00163
00164
00165 return 0;
00166 }