Changed behavior to only prompt for config creation when --makeconf is supplied - stops crontab from spawning indefinately

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@402 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
prozacx
2005-07-01 18:52:58 +00:00
parent 9db44ab1fe
commit 878c5d5a2b
2 changed files with 66 additions and 19 deletions
+19 -7
View File
@@ -9,6 +9,7 @@
static struct option g_LongOpts[] = {
{ "help", 0, NULL, 0 },
{ "version", 0, NULL, 0 },
{ "makeconf", 0, NULL, 0 },
{ "makepass", 0, NULL, 0 },
#ifdef HAVE_LIBSSL
{ "makepem", 0, NULL, 0 },
@@ -20,12 +21,13 @@ static struct option g_LongOpts[] = {
void GenerateHelp(const char *appname) {
CUtils::PrintMessage("USAGE: " + CString(appname) + " [options] [config]");
CUtils::PrintMessage("Options are:");
CUtils::PrintMessage("\t--help");
CUtils::PrintMessage("\t--version Output version information and exit");
CUtils::PrintMessage("\t--makepass Generates a password for use in config");
CUtils::PrintMessage("\t--help)");
CUtils::PrintMessage("\t--version Output version information and exit");
CUtils::PrintMessage("\t--makeconf Interactively create a new config");
CUtils::PrintMessage("\t--makepass Generates a password for use in config");
#ifdef HAVE_LIBSSL
CUtils::PrintMessage("\t--makepem Generates a pemfile for use with SSL");
CUtils::PrintMessage("\t--encrypt-pem Encrypts the pemfile");
CUtils::PrintMessage("\t--makepem Generates a pemfile for use with SSL");
CUtils::PrintMessage("\t--encrypt-pem Encrypts the pemfile");
#endif /* HAVE_LIBSSL */
}
@@ -54,12 +56,13 @@ int main(int argc, char** argv) {
#endif /* HAVE_LIBSSL */
int iArg, iOptIndex = -1;
bool bMakeConf = false;
bool bMakePass = false;
#ifdef HAVE_LIBSSL
bool bMakePem = false;
bool bEncPem = false;
#endif /* HAVE_LIBSSL */
bool bMakePass = false;
while ((iArg = getopt_long(argc, argv, "h", g_LongOpts, &iOptIndex) != -1)) {
while ((iArg = getopt_long(argc, argv, "c|h", g_LongOpts, &iOptIndex) != -1)) {
switch (iArg) {
case 1: { // long options
if (iOptIndex >= 0) {
@@ -67,6 +70,8 @@ int main(int argc, char** argv) {
if (sOption == "version") {
cout << CZNC::GetTag() << endl;
return 0;
} else if (sOption == "makeconf") {
bMakeConf = true;
} else if (sOption == "makepass") {
bMakePass = true;
#ifdef HAVE_LIBSSL
@@ -99,6 +104,13 @@ int main(int argc, char** argv) {
sConfig = argv[optind];
}
if (bMakeConf) {
CZNC* pZNC = CZNC::New();
pZNC->InitDirs("");
pZNC->WriteNewConfig(sConfig);
return 0;
}
#ifdef HAVE_LIBSSL
if (bMakePem) {
CZNC* pZNC = CZNC::New();