rc: do not (re)start services during upgrade/reboot

arm-sdk7
pedro 3 years ago
parent 308559fd3b
commit 5115473d24

@ -26,7 +26,7 @@ case "$1" in
}
;;
check)
[ "$BTON" -eq 1 -a "$BTCH" -eq 1 ] && {
[ "$BTON" -eq 1 -a "$BTCH" -eq 1 -a "$(nvram get g_upgrade)" != "1" -a "$(nvram get g_reboot)" != "1" ] && {
pidof transmission-daemon >/dev/null || {
logger -t btcheck "Transmission stopped? Starting..."
service bittorrent restart

@ -26,7 +26,7 @@ case "$1" in
}
;;
check)
[ "$MYON" -eq 1 -a "$MYCH" -eq 1 ] && {
[ "$MYON" -eq 1 -a "$MYCH" -eq 1 -a "$(nvram get g_upgrade)" != "1" -a "$(nvram get g_reboot)" != "1" ] && {
pidof mysqld >/dev/null || {
logger -t mycheck "MySQL stopped? Starting..."
service mysql restart

@ -9850,9 +9850,8 @@ int init_main(int argc, char *argv[])
unlink("/var/notice/sysup");
nvram_set("g_reboot", "1");
if (nvram_match("webmon_bkp", "1")) {
if (nvram_get_int("webmon_bkp"))
xstart("/usr/sbin/webmon_bkp", "hourly"); /* make a copy before halt/reboot router */
}
run_nvscript("script_shut", NULL, 10);
@ -9865,8 +9864,17 @@ int init_main(int argc, char *argv[])
if ((state == SIGTERM /* REBOOT */) ||
(state == SIGQUIT /* HALT */)) {
stop_syslog();
killall("buttons", SIGTERM);
killall("udhcpc", SIGTERM);
#ifdef TCONFIG_USB
remove_storage_main(1);
stop_usb();
#ifndef TCONFIG_USBAP
remove_usb_module();
#endif
#endif /* TCONFIG_USB */
remove_conntrack();
stop_jffs2();
shutdn(state == SIGTERM /* REBOOT */);
sync(); sync(); sync();

@ -208,7 +208,7 @@ static void ovpn_setup_watchdog(ovpn_type_t type, const int unit)
if ((fp = fopen(buffer, "w"))) {
fprintf(fp, "#!/bin/sh\n"
"[ -z \"$(pidof vpn%s%d)\" ] && {\n"
"[ -z \"$(pidof vpn%s%d)\" -a \"$(nvram get g_upgrade)\" != \"1\" -a \"$(nvram get g_reboot)\" != \"1\" ] && {\n"
" service vpn%s%d restart\n"
"}\n",
instanceType, unit,

@ -972,7 +972,7 @@ void generate_mdns_config(void)
void start_mdns(void)
{
if (nvram_get_int("g_upgrade"))
if (nvram_get_int("g_upgrade") || nvram_get_int("g_reboot"))
return;
if (!nvram_get_int("mdns_enable"))
@ -2754,7 +2754,7 @@ static void stop_media_server(void)
#ifdef TCONFIG_USB
static void start_nas_services(void)
{
if (nvram_get_int("g_upgrade"))
if (nvram_get_int("g_upgrade") || nvram_get_int("g_reboot"))
return;
if (getpid() != 1) {
@ -2797,7 +2797,7 @@ void restart_nas_services(int stop, int start)
/* restart all NAS applications */
if (stop)
stop_nas_services();
if (start && !nvram_get_int("g_upgrade"))
if (start)
start_nas_services();
file_unlock(fd);
@ -2831,8 +2831,8 @@ void check_services(void)
/* periodically reap any zombies */
setitimer(ITIMER_REAL, &zombie_tv, NULL);
/* do not restart if upgrading */
if (!nvram_get_int("g_upgrade")) {
/* do not restart if upgrading/rebooting */
if (!nvram_get_int("g_upgrade") && !nvram_get_int("g_reboot")) {
_check(pid_hotplug2, "hotplug2", start_hotplug2);
_check(pid_dnsmasq, "dnsmasq", start_dnsmasq);
_check(pid_crond, "crond", start_cron);
@ -2919,6 +2919,7 @@ void start_services(void)
#ifdef TCONFIG_IRQBALANCE
start_irqbalance();
#endif
start_upnp();
}
void stop_services(void)
@ -2980,6 +2981,7 @@ void stop_services(void)
#ifdef TCONFIG_IRQBALANCE
stop_irqbalance();
#endif
stop_upnp();
}
/* nvram "action_service" is: "service-action[-modifier]"
@ -3284,11 +3286,14 @@ TOP:
if (strcmp(service, "upgrade") == 0) {
if (act_start) {
if (nvram_get_int("webmon_bkp"))
xstart("/usr/sbin/webmon_bkp", "hourly"); /* make a copy before upgrade */
nvram_set("g_upgrade", "1");
stop_sched();
stop_cron();
#ifdef TCONFIG_USB
stop_nas_services(); /* Samba, FTP and Media Server */
restart_nas_services(1, 0); /* Samba, FTP and Media Server */
#endif
#ifdef TCONFIG_ZEBRA
stop_zebra();
@ -3317,10 +3322,8 @@ TOP:
killall("udhcpc", SIGTERM);
stop_wan();
}
else {
else
stop_ntpd();
stop_upnp();
}
#ifdef TCONFIG_MDNS
stop_mdns();
#endif

@ -36,7 +36,7 @@ static void tinc_setup_watchdog(void)
if ((fp = fopen(buffer, "w"))) {
fprintf(fp, "#!/bin/sh\n"
"[ -z $(pidof tincd) ] && {\n"
"[ -z \"$(pidof tincd)\" -a \"$(nvram get g_upgrade)\" != \"1\" -a \"$(nvram get g_reboot)\" != \"1\" ] && {\n"
" service tinc restart\n"
"}\n");
fclose(fp);

Loading…
Cancel
Save