Example #1
0
int
main(int argc,  char *argv[])
{
	(void) textdomain(TEXT_DOMAIN);
	(void) setlocale(LC_MESSAGES, "");

	if (getuid() != 0) {
		(void) fprintf(stderr, "\n%s\n\n",
		    gettext("This program MUST be run as root"));
		exit(-1);
	}

	if (argc < 2) {
		ADM_Usage();
		exit(-1);
	}

	ADM_Init();
	ADM_Process_command(argc, argv);

	return (0);
}
Example #2
0
void
ADM_Process_command(int argc, char *argv[])
{
	if (strcasecmp(argv[1], "help") == 0)
		ADM_Process_help();

	else if (strcasecmp(argv[1], "send_event") == 0)
		ADM_Process_send_event(argc, argv);

	else if (strcasecmp(argv[1], "modem_setup") == 0)
		ADM_Process_modem_setup();

	else if (strcasecmp(argv[1], "date") == 0)
		ADM_Process_date(argc, argv);

	else if (strcasecmp(argv[1], "set") == 0)
		ADM_Process_set(argc, argv);

	else if (strcasecmp(argv[1], "show") == 0)
		ADM_Process_show(argc, argv);

	else if (strcasecmp(argv[1], "resetrsc") == 0)
		ADM_Process_reset(argc, argv);

	else if (strcasecmp(argv[1], "download") == 0)
		ADM_Process_download(argc, argv);

	else if (strcasecmp(argv[1], "useradd") == 0)
		ADM_Process_useradd(argc, argv);

	else if (strcasecmp(argv[1], "userdel") == 0)
		ADM_Process_userdel(argc, argv);

	else if (strcasecmp(argv[1], "usershow") == 0)
		ADM_Process_usershow(argc, argv);

	else if (strcasecmp(argv[1], "userpassword") == 0)
		ADM_Process_userpassword(argc, argv);

	else if (strcasecmp(argv[1], "userperm") == 0)
		ADM_Process_userperm(argc, argv);

	else if (strcasecmp(argv[1], "status") == 0)
		ADM_Process_status(0);

	else if (strcasecmp(argv[1], "version") == 0) {
		if (argc == 3) {
			if (strcasecmp(argv[2], "-v") == 0) {
				ADM_Process_status(1);
			} else {
				(void) fprintf(stderr, "\n%s\n\n",
				    gettext("USAGE: scadm version [-v]"));
			}
		} else
			ADM_Process_status(0);

	} else if (strcasecmp(argv[1], "loghistory") == 0 ||
	    strcasecmp(argv[1], "lhist") == 0) {

		if (argc == 2) {
			ADM_Process_event_log(0);
		} else if (argc == 3 && strcmp(argv[2], "-a") == 0) {
			ADM_Process_event_log(1);
		} else {
			(void) fprintf(stderr, "\n%s\n\n",
			    gettext("USAGE: scadm loghistory [-a]"));
			exit(-1);
		}

	} else if (strcasecmp(argv[1], "shownetwork") == 0) {

		if (argc != 2) {
			(void) fprintf(stderr, "\n%s\n\n",
			    gettext("USAGE: scadm shownetwork"));
			exit(-1);
		}
		ADM_Process_show_network();

	} else if (strcasecmp(argv[1], "consolehistory") == 0) {

		if (argc == 2) {
			ADM_Process_console_log(0);
		} else if (argc == 3 && strcmp(argv[2], "-a") == 0) {
			ADM_Process_console_log(1);
		} else {
			(void) fprintf(stderr, "\n%s\n\n",
			    gettext("USAGE: scadm consolehistory [-a]"));
			exit(-1);
		}

	} else if (strcasecmp(argv[1], "fruhistory") == 0) {

		if (argc == 2) {
			ADM_Process_fru_log(0);
		} else if (argc == 3 && strcmp(argv[2], "-a") == 0) {
			ADM_Process_fru_log(1);
		} else {
			(void) fprintf(stderr, "\n%s\n\n",
			    gettext("USAGE: scadm fruhistory [-a]"));
			exit(-1);
		}

	} else {
		(void) fprintf(stderr, "\n%s - \"%s\"\n",
		    gettext("scadm: command unknown"), argv[1]);
		ADM_Usage();
		exit(-1);
	}
}