Adds a new -C, --gen-conf option to generate the configuration file from the content file.

This commit is contained in:
Andrea Mazzoleni 2013-09-21 15:53:46 +02:00
parent c956f55d62
commit c5d0aa01c1
7 changed files with 124 additions and 7 deletions

View file

@ -119,6 +119,7 @@ struct option long_options[] = {
{ "find-by-name", 0, 0, 'N' }, /* deprecated in SnapRAID 4.0 */
{ "audit-only", 0, 0, 'a' },
{ "speed-test", 0, 0, 'T' },
{ "gen-conf", 1, 0, 'C' },
{ "verbose", 0, 0, 'v' },
{ "gui", 0, 0, 'G' }, /* undocumented GUI interface command */
{ "help", 0, 0, 'h' },
@ -181,7 +182,7 @@ struct option long_options[] = {
};
#endif
#define OPTIONS "c:f:d:mep:o:s:t:i:l:ZEUDNaTvhVG"
#define OPTIONS "c:f:d:mep:o:s:t:i:l:ZEUDNaTC:vhVG"
volatile int global_interrupt = 0;
@ -228,8 +229,11 @@ int main(int argc, char* argv[])
const char* import;
const char* log;
int lock;
const char* gen_conf;
os_init();
raid_init();
crc32c_init();
/* defaults */
conf = CONF;
@ -246,6 +250,7 @@ int main(int argc, char* argv[])
import = 0;
log = 0;
lock = 0;
gen_conf = 0;
opterr = 0;
while ((c =
@ -356,6 +361,9 @@ int main(int argc, char* argv[])
case 'T' :
speed();
exit(EXIT_SUCCESS);
case 'C' :
gen_conf = optarg;
break;
case OPT_TEST_KILL_AFTER_SYNC :
opt.kill_after_sync = 1;
break;
@ -419,6 +427,12 @@ int main(int argc, char* argv[])
}
}
if (gen_conf != 0) {
generate_configuration(gen_conf);
os_done();
exit(EXIT_SUCCESS);
}
if (optind + 1 != argc) {
usage();
exit(EXIT_FAILURE);
@ -505,9 +519,6 @@ int main(int argc, char* argv[])
}
}
raid_init();
crc32c_init();
/* open the log file */
if (log == 0)
log = "2";