| … | |
… | |
| 822 | { "debug", 0, NULL, 'd'}, |
822 | { "debug", 0, NULL, 'd'}, |
| 823 | { "help", 0, NULL, 'h'}, |
823 | { "help", 0, NULL, 'h'}, |
| 824 | { "nocolor", 0, NULL, 'C'}, |
824 | { "nocolor", 0, NULL, 'C'}, |
| 825 | { "nocolour", 0, NULL, 'C'}, |
825 | { "nocolour", 0, NULL, 'C'}, |
| 826 | { "nodeps", 0, NULL, 'D'}, |
826 | { "nodeps", 0, NULL, 'D'}, |
|
|
827 | { "quiet", 0, NULL, 'q'}, |
| 827 | { "verbose", 0, NULL, 'v'}, |
828 | { "verbose", 0, NULL, 'v'}, |
| 828 | { NULL, 0, NULL, 0} |
829 | { NULL, 0, NULL, 0} |
| 829 | }; |
830 | }; |
| 830 | |
|
|
| 831 | applet = strdup (basename (service)); |
|
|
| 832 | atexit (cleanup); |
|
|
| 833 | |
831 | |
| 834 | /* Show help if insufficient args */ |
832 | /* Show help if insufficient args */ |
| 835 | if (argc < 3) { |
833 | if (argc < 3) { |
| 836 | execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL); |
834 | execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL); |
| 837 | eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", |
835 | eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", |
| 838 | applet, strerror (errno)); |
836 | applet, strerror (errno)); |
| 839 | } |
837 | } |
|
|
838 | |
|
|
839 | applet = strdup (basename (service)); |
|
|
840 | atexit (cleanup); |
| 840 | |
841 | |
| 841 | #ifdef __linux__ |
842 | #ifdef __linux__ |
| 842 | /* coldplug events can trigger init scripts, but we don't want to run them |
843 | /* coldplug events can trigger init scripts, but we don't want to run them |
| 843 | until after rc sysinit has completed so we punt them to the boot runlevel */ |
844 | until after rc sysinit has completed so we punt them to the boot runlevel */ |
| 844 | if (rc_exists ("/dev/.rcsysinit")) { |
845 | if (rc_exists ("/dev/.rcsysinit")) { |
| … | |
… | |
| 909 | eb = rc_strcatpaths (RC_SVCDIR "ebuffer", ebname, (char *) NULL); |
910 | eb = rc_strcatpaths (RC_SVCDIR "ebuffer", ebname, (char *) NULL); |
| 910 | setenv ("RC_EBUFFER", eb, 1); |
911 | setenv ("RC_EBUFFER", eb, 1); |
| 911 | free (eb); |
912 | free (eb); |
| 912 | } |
913 | } |
| 913 | |
914 | |
| 914 | /* Save the IN_BACKGROUND env flag so it's ONLY passed to the service |
|
|
| 915 | that is being called and not any dependents */ |
|
|
| 916 | if (getenv ("IN_BACKGROUND")) { |
|
|
| 917 | in_background = rc_is_env ("IN_BACKGROUND", "true"); |
|
|
| 918 | ibsave = strdup (getenv ("IN_BACKGROUND")); |
|
|
| 919 | unsetenv ("IN_BACKGROUND"); |
|
|
| 920 | } |
|
|
| 921 | |
|
|
| 922 | #ifdef __linux__ |
915 | #ifdef __linux__ |
| 923 | /* Ok, we are ready to go, so setup selinux if applicable */ |
916 | /* Ok, we are ready to go, so setup selinux if applicable */ |
| 924 | setup_selinux (argc, argv); |
917 | setup_selinux (argc, argv); |
| 925 | #endif |
918 | #endif |
|
|
919 | |
|
|
920 | /* Punt the first arg as it's our service name */ |
|
|
921 | argc--; |
|
|
922 | argv++; |
| 926 | |
923 | |
| 927 | /* Right then, parse any options there may be */ |
924 | /* Right then, parse any options there may be */ |
| 928 | while ((c = getopt_long (argc, argv, "dhCDNqv", |
925 | while ((c = getopt_long (argc, argv, "dhCDNqv", |
| 929 | longopts, (int *) 0)) != -1) |
926 | longopts, (int *) 0)) != -1) |
| 930 | switch (c) { |
927 | switch (c) { |
| … | |
… | |
| 949 | break; |
946 | break; |
| 950 | default: |
947 | default: |
| 951 | exit (EXIT_FAILURE); |
948 | exit (EXIT_FAILURE); |
| 952 | } |
949 | } |
| 953 | |
950 | |
|
|
951 | /* Save the IN_BACKGROUND env flag so it's ONLY passed to the service |
|
|
952 | that is being called and not any dependents */ |
|
|
953 | if (getenv ("IN_BACKGROUND")) { |
|
|
954 | in_background = rc_is_env ("IN_BACKGROUND", "true"); |
|
|
955 | ibsave = strdup (getenv ("IN_BACKGROUND")); |
|
|
956 | unsetenv ("IN_BACKGROUND"); |
|
|
957 | } |
|
|
958 | |
| 954 | if (rc_is_env ("IN_HOTPLUG", "1")) { |
959 | if (rc_is_env ("IN_HOTPLUG", "1")) { |
| 955 | if (! rc_is_env ("RC_HOTPLUG", "yes") || ! rc_allow_plug (applet)) |
960 | if (! rc_is_env ("RC_HOTPLUG", "yes") || ! rc_allow_plug (applet)) |
| 956 | eerrorx ("%s: not allowed to be hotplugged", applet); |
961 | eerrorx ("%s: not allowed to be hotplugged", applet); |
| 957 | } |
962 | } |
| 958 | |
963 | |