示例#1
0
文件: tripplitesu.c 项目: AlexLov/nut
static int instcmd(const char *cmdname, const char *extra)
{
	int i;
	char parm[20];

	if (!strcasecmp(cmdname, "load.off")) {
		for (i = 0; i < ups.outlet_banks; i++) {
			snprintf(parm, sizeof(parm), "%d;1", i + 1);
			do_command(SET, RELAY_OFF, parm, NULL);
		}
		return STAT_INSTCMD_HANDLED;
	}
	if (!strcasecmp(cmdname, "load.on")) {
		for (i = 0; i < ups.outlet_banks; i++) {
			snprintf(parm, sizeof(parm), "%d;1", i + 1);
			do_command(SET, RELAY_ON, parm, NULL);
		}
		return STAT_INSTCMD_HANDLED;
	}
	if (!strcasecmp(cmdname, "shutdown.reboot")) {
		auto_reboot(1);
		do_command(SET, SHUTDOWN_RESTART, "1", NULL);
		do_command(SET, SHUTDOWN_ACTION, "10", NULL);
		return STAT_INSTCMD_HANDLED;
	}
	if (!strcasecmp(cmdname, "shutdown.reboot.graceful")) {
		auto_reboot(1);
		do_command(SET, SHUTDOWN_RESTART, "1", NULL);
		do_command(SET, SHUTDOWN_ACTION, "60", NULL);
		return STAT_INSTCMD_HANDLED;
	}
	if (!strcasecmp(cmdname, "shutdown.return")) {
		auto_reboot(1);
		do_command(SET, SHUTDOWN_RESTART, "1", NULL);
		do_command(SET, SHUTDOWN_ACTION, "10", NULL);
		return STAT_INSTCMD_HANDLED;
	}
#if 0 /* doesn't seem to work */
	if (!strcasecmp(cmdname, "shutdown.stayoff")) {
		auto_reboot(0);
		do_command(SET, SHUTDOWN_ACTION, "10", NULL);
		return STAT_INSTCMD_HANDLED;
	}
#endif
	if (!strcasecmp(cmdname, "shutdown.stop")) {
		do_command(SET, SHUTDOWN_ACTION, "0", NULL);
		return STAT_INSTCMD_HANDLED;
	}
	if (!strcasecmp(cmdname, "test.battery.start")) {
		do_command(SET, TEST, "3", NULL);
		return STAT_INSTCMD_HANDLED;
	}
	if (!strcasecmp(cmdname, "test.battery.stop")) {
		do_command(SET, TEST, "0", NULL);
		return STAT_INSTCMD_HANDLED;
	}
	upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname);
	return STAT_INSTCMD_UNKNOWN;
}
示例#2
0
void
handle_init_to_bsp (void)
{
	if (config.vmm.auto_reboot)
		auto_reboot ();
	panic ("INIT signal to BSP");
}
示例#3
0
文件: tripplitesu.c 项目: AlexLov/nut
void upsdrv_shutdown(void)
{
	char parm[20];

	if (!init_comm())
		printf("Status failed.  Assuming it's on battery and trying a shutdown anyway.\n");
	auto_reboot(1);
	/* in case the power is on, tell it to automatically reboot.  if
	   it is off, this has no effect. */
	snprintf(parm, sizeof(parm), "%d", 1); /* delay before reboot, in minutes */
	do_command(SET, SHUTDOWN_RESTART, parm, NULL);
	snprintf(parm, sizeof(parm), "%d", 5); /* delay before shutdown, in seconds */
	do_command(SET, SHUTDOWN_ACTION, parm, NULL);
}
示例#4
0
void
handle_init_to_bsp (void)
{
	int d;

	if (config.vmm.auto_reboot == 1) {
		d = msgopen ("reboot");
		if (d >= 0) {
			msgsendint (d, 0);
			msgclose (d);
			printf ("Reboot failed.\n");
		} else {
			printf ("reboot not found.\n");
		}
	}
	if (config.vmm.auto_reboot)
		auto_reboot ();
	panic ("INIT signal to BSP");
}
示例#5
0
void create()
{
#ifdef WEATHER
        day_phase = read_table("/adm/etc/nature/day_phase");
        init_day_phase();

        weather = read_table("/adm/etc/nature/weather");
        init_weather();
#endif
#ifdef SEND_MONEY
        send_money();
#endif
        clan();
        init_mail();
        auto_reboot();
	war_start();
	// do_full();
        sp_boss();
        sys_init();
        call_out( "check_heart_beat", 10 );
}