/[baselayout]/trunk/src/runscript.c
Gentoo

Diff of /trunk/src/runscript.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2571 Revision 2573
443 char *svc2; 443 char *svc2;
444 int i; 444 int i;
445 int j; 445 int j;
446 int depoptions = RC_DEP_TRACE; 446 int depoptions = RC_DEP_TRACE;
447 447
448 rc_plugin_run (rc_hook_service_start_in, applet);
449 hook_out = rc_hook_service_start_out;
450
448 if (rc_is_env ("RC_STRICT_DEPEND", "yes")) 451 if (rc_is_env ("RC_STRICT_DEPEND", "yes"))
449 depoptions |= RC_DEP_STRICT; 452 depoptions |= RC_DEP_STRICT;
450 453
451 if (rc_is_env ("IN_HOTPLUG", "1") || in_background) 454 if (rc_is_env ("IN_HOTPLUG", "1") || in_background)
452 { 455 {
561 rc_strlist_free (svclist); 564 rc_strlist_free (svclist);
562 svclist = rc_strlist_add (NULL, svc); 565 svclist = rc_strlist_add (NULL, svc);
563 rc_strlist_free (providelist); 566 rc_strlist_free (providelist);
564 providelist = rc_get_depends (deptree, types, svclist, 567 providelist = rc_get_depends (deptree, types, svclist,
565 softlevel, depoptions); 568 softlevel, depoptions);
566 STRLIST_FOREACH (providelist, svc2, j) 569 STRLIST_FOREACH (providelist, svc2, j)
567 rc_schedule_start_service (svc2, service); 570 rc_schedule_start_service (svc2, service);
568 571
569 len += strlen (svc) + 2; 572 len += strlen (svc) + 2;
570 n++; 573 n++;
571 } 574 }
596 svclist = NULL; 599 svclist = NULL;
597 } 600 }
598 601
599 if (ibsave) 602 if (ibsave)
600 setenv ("IN_BACKGROUND", ibsave, 1); 603 setenv ("IN_BACKGROUND", ibsave, 1);
601 rc_plugin_run (rc_hook_service_start_in, applet); 604 rc_plugin_run (rc_hook_service_start_now, applet);
602 hook_out = rc_hook_service_start_out;
603 started = svc_exec (service, "start", NULL); 605 started = svc_exec (service, "start", NULL);
604 if (ibsave) 606 if (ibsave)
605 unsetenv ("IN_BACKGROUND"); 607 unsetenv ("IN_BACKGROUND");
606 608
607 if (in_control ()) 609 if (in_control ())
614 { 616 {
615 rc_mark_service (service, rc_service_stopped); 617 rc_mark_service (service, rc_service_stopped);
616 if (rc_runlevel_starting ()) 618 if (rc_runlevel_starting ())
617 rc_mark_service (service, rc_service_failed); 619 rc_mark_service (service, rc_service_failed);
618 } 620 }
621 rc_plugin_run (rc_hook_service_start_done, applet);
619 eerrorx ("ERROR: %s failed to start", applet); 622 eerrorx ("ERROR: %s failed to start", applet);
620 } 623 }
621
622 rc_mark_service (service, rc_service_started); 624 rc_mark_service (service, rc_service_started);
623 unlink_mtime_test (); 625 unlink_mtime_test ();
624
625 hook_out = 0;
626 rc_plugin_run (rc_hook_service_start_out, applet); 626 rc_plugin_run (rc_hook_service_start_done, applet);
627 } 627 }
628 else 628 else
629 { 629 {
630 rc_plugin_run (rc_hook_service_start_done, applet);
630 if (rc_service_state (service, rc_service_inactive)) 631 if (rc_service_state (service, rc_service_inactive))
631 ewarn ("WARNING: %s has started, but is inactive", applet); 632 ewarnx ("WARNING: %s has started, but is inactive", applet);
632 else 633 else
633 ewarn ("WARNING: %s not under our control, aborting", applet); 634 ewarnx ("WARNING: %s not under our control, aborting", applet);
634 } 635 }
635 636
636 /* Now start any scheduled services */ 637 /* Now start any scheduled services */
637 rc_strlist_free (services); 638 rc_strlist_free (services);
638 services = rc_services_scheduled (service); 639 services = rc_services_scheduled (service);
656 services = rc_services_scheduled (svc2); 657 services = rc_services_scheduled (svc2);
657 STRLIST_FOREACH (services, svc, i) 658 STRLIST_FOREACH (services, svc, i)
658 if (rc_service_state (svc, rc_service_stopped)) 659 if (rc_service_state (svc, rc_service_stopped))
659 rc_start_service (svc); 660 rc_start_service (svc);
660 } 661 }
662
663 hook_out = 0;
664 rc_plugin_run (rc_hook_service_start_out, applet);
661} 665}
662 666
663static void svc_stop (const char *service, bool deps) 667static void svc_stop (const char *service, bool deps)
664{ 668{
665 bool stopped; 669 bool stopped;
670
671 hook_out = rc_hook_service_stop_out;
666 672
667 if (rc_runlevel_stopping () && 673 if (rc_runlevel_stopping () &&
668 rc_service_state (service, rc_service_failed)) 674 rc_service_state (service, rc_service_failed))
669 exit (EXIT_FAILURE); 675 exit (EXIT_FAILURE);
670 676
762 types = NULL; 768 types = NULL;
763 } 769 }
764 770
765 if (ibsave) 771 if (ibsave)
766 setenv ("IN_BACKGROUND", ibsave, 1); 772 setenv ("IN_BACKGROUND", ibsave, 1);
767 rc_plugin_run (rc_hook_service_stop_in, applet); 773 rc_plugin_run (rc_hook_service_stop_now, applet);
768 hook_out = rc_hook_service_stop_out;
769 stopped = svc_exec (service, "stop", NULL); 774 stopped = svc_exec (service, "stop", NULL);
770 if (ibsave) 775 if (ibsave)
771 unsetenv ("IN_BACKGROUND"); 776 unsetenv ("IN_BACKGROUND");
772 777
773 if (! in_control ()) 778 if (! in_control ())
779 {
780 rc_plugin_run (rc_hook_service_stop_done, applet);
774 ewarnx ("WARNING: %s not under our control, aborting", applet); 781 ewarnx ("WARNING: %s not under our control, aborting", applet);
782 }
775 783
776 if (! stopped) 784 if (! stopped)
777 { 785 {
778 if (rc_service_state (service, rc_service_wasinactive)) 786 if (rc_service_state (service, rc_service_wasinactive))
779 rc_mark_service (service, rc_service_inactive); 787 rc_mark_service (service, rc_service_inactive);
780 else 788 else
781 rc_mark_service (service, rc_service_started); 789 rc_mark_service (service, rc_service_started);
790 rc_plugin_run (rc_hook_service_stop_done, applet);
782 eerrorx ("ERROR: %s failed to stop", applet); 791 eerrorx ("ERROR: %s failed to stop", applet);
783 } 792 }
784 793
785 if (in_background) 794 if (in_background)
786 rc_mark_service (service, rc_service_inactive); 795 rc_mark_service (service, rc_service_inactive);
787 else 796 else
788 rc_mark_service (service, rc_service_stopped); 797 rc_mark_service (service, rc_service_stopped);
789 798
790 unlink_mtime_test (); 799 unlink_mtime_test ();
800 rc_plugin_run (rc_hook_service_stop_done, applet);
791 hook_out = 0; 801 hook_out = 0;
792 rc_plugin_run (rc_hook_service_stop_out, applet); 802 rc_plugin_run (rc_hook_service_stop_out, applet);
793} 803}
794 804
795static void svc_restart (const char *service, bool deps) 805static void svc_restart (const char *service, bool deps)

Legend:
Removed from v.2571  
changed lines
  Added in v.2573

  ViewVC Help
Powered by ViewVC 1.1.20