Пример #1
0
static void
ez_action_shutdown(void)
{
    logmessage("watchdog", "Perform ez-button %s...", "shutdown");

    sys_stop();
}
Пример #2
0
/*===========================================================================*
 *				do_reboot				     *
 *===========================================================================*/
int do_reboot()
{
    message m;

    /* Check permission to abort the system. */
    if (mp->mp_effuid != SUPER_USER) return(EPERM);

    /* See how the system should be aborted. */
    abort_flag = m_in.m_lc_pm_reboot.how;

    /* notify readclock (some arm systems power off via RTC alarms) */
    if (abort_flag & RB_POWERDOWN) {
        endpoint_t readclock_ep;
        if (ds_retrieve_label_endpt("readclock.drv", &readclock_ep) == OK) {
            message m; /* no params to set, nothing we can do if it fails */
            _taskcall(readclock_ep, RTCDEV_PWR_OFF, &m);
        }
    }

    /* Order matters here. When VFS is told to reboot, it exits all its
     * processes, and then would be confused if they're exited again by
     * SIGKILL. So first kill, then reboot.
     */

    check_sig(-1, SIGKILL, FALSE /* ksig*/); /* kill all users except init */
    sys_stop(INIT_PROC_NR);		   /* stop init, but keep it around */

    /* Tell VFS to reboot */
    memset(&m, 0, sizeof(m));
    m.m_type = VFS_PM_REBOOT;

    tell_vfs(&mproc[VFS_PROC_NR], &m);

    return(SUSPEND);			/* don't reply to caller */
}
Пример #3
0
int user_stop (void)
{
//	terminate_process (httpd_pidfile, 0);

	sys_stop ();
	net_stop ();
	io_stop ();
	pm_stop ();

	return 0;
}
Пример #4
0
C_failed()
{
	sys_write(STDERR,"read, write, or open failed\n",28);
	sys_stop(S_EXIT);
}
Пример #5
0
int
main(int argc, char **argv)
{
	int ret;
	char *base = strrchr(argv[0], '/');
	const applet_rc_t *app;
	base = base ? base + 1 : argv[0];

	/* init */
	if (!strcmp(base, "init")) {
		if (getpid() != 1 ) {
			dbg("error: %s must be run as PID 1!\n", base);
			return -1;
		}
		init_main_loop();
		return 0;
	}

	/* stub for early kernel hotplug */
	if (!strcmp(base, "hotplug")) {
		return 0;
	}

	if (!strcmp(base, "reboot")) {
		return sys_exit();
	}

	if (!strcmp(base, "shutdown") || !strcmp(base, "halt")) {
		return sys_stop();
	}

	if (!strcmp(base, "rc")) {
		dbg("error: cannot run rc directly!\n");
		return EINVAL;
	}

	/* Set TZ for all rc programs */
	setenv_tz();

	/* Start applets */
	for (app = applets_rc; app->name; app++) {
		if (strcmp(base, app->name) == 0)
			return app->main(argc, argv);
	}

	ret = 0;
	if (!strcmp(base, "reset_to_defaults")) {
		erase_nvram();
		sys_exit();
	}
	else if (!strcmp(base, "run_ftpsamba")) {
#if defined(APP_SMBD)
		restart_smbd();
#else
		;
#endif
#if defined(APP_FTPD)
		restart_ftpd();
#endif
	}
#if defined(APP_SMBD)
	else if (!strcmp(base, "run_samba")) {
		restart_smbd();
	}
#endif
#if defined(APP_FTPD)
	else if (!strcmp(base, "run_ftp")) {
		restart_ftpd();
	}
#endif
#if defined(APP_NFSD)
	else if (!strcmp(base, "run_nfsd")) {
		run_nfsd();
	}
#endif
#if defined(APP_MINIDLNA)
	else if (!strcmp(base, "run_minidlna")) {
		restart_dms(0);
	}
#endif
#if defined(APP_FIREFLY)
	else if (!strcmp(base, "run_firefly")) {
		restart_itunes();
	}
#endif
#if defined(APP_TRMD)
	else if (!strcmp(base, "run_transmission")) {
		restart_torrent();
	}
#endif
#if defined(APP_ARIA)
	else if (!strcmp(base, "run_aria")) {
		restart_aria();
	}
#endif
#if defined(APP_FTPD)
	else if (!strcmp(base, "stop_ftp")) {
		stop_ftp();
	}
#endif
#if defined(APP_SMBD)
	else if (!strcmp(base, "stop_samba")) {
		stop_samba(0);
	}
#endif
	else if (!strcmp(base, "stop_ftpsamba")) {
#if defined(APP_FTPD)
		stop_ftp();
#endif
#if defined(APP_SMBD)
		stop_samba(0);
#else
		;
#endif
	}
#if defined(APP_NFSD)
	else if (!strcmp(base, "stop_nfsd")) {
		stop_nfsd();
	}
#endif
#if defined(APP_MINIDLNA)
	else if (!strcmp(base, "stop_minidlna")) {
		stop_dms();
	}
#endif
#if defined(APP_FIREFLY)
	else if (!strcmp(base, "stop_firefly")) {
		stop_itunes();
	}
#endif
#if defined(APP_TRMD)
	else if (!strcmp(base, "stop_transmission")) {
		stop_torrent();
	}
#endif
#if defined(APP_ARIA)
	else if (!strcmp(base, "stop_aria")) {
		stop_aria();
	}
#endif
	else if (!strcmp(base, "start_ddns")) {
		start_ddns(1);
	}
	else if (!strcmp(base, "stop_wan")) {
		notify_rc("manual_wan_disconnect");
	}
	else if (!strcmp(base, "restart_wan")) {
		notify_rc("manual_wan_reconnect");
	}
	else if (!strcmp(base, "restart_dns")) {
		restart_dns();
	}
	else if (!strcmp(base, "restart_dhcpd")) {
		restart_dhcpd();
	}
	else if (!strcmp(base, "restart_networkmap")) {
		restart_networkmap();
	}
	else if (!strcmp(base, "run_telnetd")) {
		run_telnetd();
	}
	else if (!strcmp(base, "restart_firewall")) {
		restart_firewall();
	}
	else if (!strcmp(base, "radio2_toggle")) {
		manual_toggle_radio_rt(-1);
	}
	else if (!strcmp(base, "radio2_toggle_on")) {
		manual_toggle_radio_rt(1);
	}
	else if (!strcmp(base, "radio2_toggle_off")) {
		manual_toggle_radio_rt(0);
	}
	else if (!strcmp(base, "radio2_enable")) {
		manual_change_radio_rt(1);
	}
	else if (!strcmp(base, "radio2_disable")) {
		manual_change_radio_rt(0);
	}
	else if (!strcmp(base, "radio2_guest_enable")) {
		manual_change_guest_rt(1);
	}
	else if (!strcmp(base, "radio2_guest_disable")) {
		manual_change_guest_rt(0);
	}
	else if (!strcmp(base, "radio2_eeprom_mac")) {
		if (argc > 1 && strlen(argv[1]) == 17)
			ret = set_wireless_mac(0, argv[1]);
		else {
			printf("Usage: %s XX:XX:XX:XX:XX:XX\n\n", base);
			ret = get_wireless_mac(0);
		}
	}
	else if (!strcmp(base, "radio2_restart")) {
		int radio_on = get_enabled_radio_rt();
		if (radio_on)
			radio_on = is_radio_allowed_rt();
		restart_wifi_rt(radio_on, 1);
	}
#if BOARD_HAS_5G_RADIO
	else if (!strcmp(base, "radio5_toggle")) {
		manual_toggle_radio_wl(-1);
	}
	else if (!strcmp(base, "radio5_toggle_on")) {
		manual_toggle_radio_wl(1);
	}
	else if (!strcmp(base, "radio5_toggle_off")) {
		manual_toggle_radio_wl(0);
	}
	else if (!strcmp(base, "radio5_enable")) {
		manual_change_radio_wl(1);
	}
	else if (!strcmp(base, "radio5_disable")) {
		manual_change_radio_wl(0);
	}
	else if (!strcmp(base, "radio5_guest_enable")) {
		manual_change_guest_wl(1);
	}
	else if (!strcmp(base, "radio5_guest_disable")) {
		manual_change_guest_wl(0);
	}
	else if (!strcmp(base, "radio5_eeprom_mac")) {
		if (argc > 1 && strlen(argv[1]) == 17)
			ret = set_wireless_mac(1, argv[1]);
		else {
			printf("Usage: %s XX:XX:XX:XX:XX:XX\n\n", base);
			ret = get_wireless_mac(1);
		}
	}
	else if (!strcmp(base, "radio5_restart")) {
		int radio_on = get_enabled_radio_wl();
		if (radio_on)
			radio_on = is_radio_allowed_wl();
		restart_wifi_wl(radio_on, 1);
	}
#endif
#if (BOARD_NUM_USB_PORTS > 0)
	else if (!strcmp(base, "ejusb")) {
		int port = 0;
		char *devn = NULL;
		if (argc > 1) {
			if (strncmp(argv[1], "sd", 2) == 0)
				devn = argv[1];
			else {
				port = atoi(argv[1]);
				if (argc > 2)
					devn = argv[2];
			}
		}
		ret = safe_remove_usb_device(port, devn, 1);
	}
	else if (!strcmp(base, "ejusb1")) {
		char *devn = (argc > 1) ? argv[1] : NULL;
		ret = safe_remove_usb_device(1, devn, 1);
	}
#if (BOARD_NUM_USB_PORTS > 1)
	else if (!strcmp(base, "ejusb2")) {
		char *devn = (argc > 1) ? argv[1] : NULL;
		ret = safe_remove_usb_device(2, devn, 1);
	}
#endif
#endif
	else if (!strcmp(base, "pids")) {
		if (argc > 1)
			ret = pids_main(argv[1]);
		else
			ret = EINVAL;
	}
	else {
		printf("Unknown applet: %s\n", base);
		ret = EINVAL;
	}

	return ret;
}