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) 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 || { pidof transmission-daemon >/dev/null || {
logger -t btcheck "Transmission stopped? Starting..." logger -t btcheck "Transmission stopped? Starting..."
service bittorrent restart service bittorrent restart

@ -26,7 +26,7 @@ case "$1" in
} }
;; ;;
check) 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 || { pidof mysqld >/dev/null || {
logger -t mycheck "MySQL stopped? Starting..." logger -t mycheck "MySQL stopped? Starting..."
service mysql restart service mysql restart

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

@ -208,7 +208,7 @@ static void ovpn_setup_watchdog(ovpn_type_t type, const int unit)
if ((fp = fopen(buffer, "w"))) { if ((fp = fopen(buffer, "w"))) {
fprintf(fp, "#!/bin/sh\n" 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" " service vpn%s%d restart\n"
"}\n", "}\n",
instanceType, unit, instanceType, unit,

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

@ -36,7 +36,7 @@ static void tinc_setup_watchdog(void)
if ((fp = fopen(buffer, "w"))) { if ((fp = fopen(buffer, "w"))) {
fprintf(fp, "#!/bin/sh\n" 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" " service tinc restart\n"
"}\n"); "}\n");
fclose(fp); fclose(fp);

Loading…
Cancel
Save