source: src/router/rc/rc.c @ 9823

Last change on this file since 9823 was 9823, checked in by BrainSlayer, 5 years ago

lets try this

File size: 17.7 KB
Line 
1
2#include <stdio.h>
3#include <stdlib.h>
4#include <limits.h>
5#include <time.h>
6#include <unistd.h>
7#include <errno.h>
8#include <syslog.h>
9#include <signal.h>
10#include <string.h>
11#include <sys/klog.h>
12#include <sys/types.h>
13#include <sys/mount.h>
14#include <sys/reboot.h>
15#include <sys/stat.h>
16#include <sys/sysmacros.h>
17#include <sys/time.h>
18#include <sys/utsname.h>
19#include <sys/wait.h>
20#include <dirent.h>
21
22#include <epivers.h>
23#include <bcmnvram.h>
24#include <mtd.h>
25#include <shutils.h>
26#include <rc.h>
27#include <netconf.h>
28#include <nvparse.h>
29#include <bcmdevs.h>
30
31#include <wlutils.h>
32#include <utils.h>
33#include <cyutils.h>
34#include <code_pattern.h>
35#include <cy_conf.h>
36#include <typedefs.h>
37#include <bcmnvram.h>
38#include <bcmutils.h>
39#include <shutils.h>
40#include <wlutils.h>
41#include <cy_conf.h>
42
43#include <revision.h>
44
45
46
47/* States */
48enum
49{
50  RESTART,
51  STOP,
52  START,
53  TIMER,
54  USER,
55  IDLE,
56#ifdef HAVE_X86
57  REBOOT,
58#endif
59};
60static int state = START;
61static int signalled = -1;
62
63/* Signal handling */
64static void
65rc_signal (int sig)
66{
67  if (state == IDLE)
68    {
69      if (sig == SIGHUP)
70        {
71          lcdmessage ("Signal RESTART");
72          printf ("signalling RESTART\n");
73          signalled = RESTART;
74        }
75      else if (sig == SIGUSR2)
76        {
77          lcdmessage ("Signal START");
78          printf ("signalling START\n");
79          signalled = START;
80        }
81      else if (sig == SIGINT)
82        {
83          lcdmessage ("Signal STOP");
84          printf ("signalling STOP\n");
85          signalled = STOP;
86        }
87      else if (sig == SIGALRM)
88        {
89          lcdmessage ("Signal TIMER");
90          printf ("signalling TIMER\n");
91          signalled = TIMER;
92        }
93#ifdef HAVE_X86
94      else if (sig == SIGTERM)
95        {
96          lcdmessage ("Signal Reboot");
97          printf ("signalling REBOOT\n");
98          signalled = REBOOT;
99        }
100#endif
101      else if (sig == SIGUSR1)
102        {                       // Receive from WEB
103          lcdmessage ("Signal USER");
104          printf ("signalling USER1\n");
105          signalled = USER;
106        }
107
108    }
109}
110
111/* Timer procedure */
112int
113do_timer (void)
114{
115  //do_ntp();
116  return 0;
117}
118static int noconsole = 0;
119
120/* Main loop */
121int
122main_loop (int argc, char **argv)
123{
124  sigset_t sigset;
125  pid_t shell_pid = 0;
126  uint boardflags;
127  //setenv("PATH", "/sbin:/bin:/usr/sbin:/usr/bin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin", 1);
128  //system("/etc/nvram/nvram");
129  /* Basic initialization */
130  cprintf ("console init\n");
131  if (console_init ())
132    noconsole = 1;
133  cprintf ("init lcd\n");
134  initlcd ();
135  cprintf ("first message\n");
136  lcdmessage ("System Start");
137  cprintf ("start service\n");
138  start_service ("sysinit");
139  cprintf ("setup signals\n");
140  /* Setup signal handlers */
141  signal_init ();
142  signal (SIGHUP, rc_signal);
143  signal (SIGUSR1, rc_signal);  // Start single service from WEB, by honor
144  signal (SIGUSR2, rc_signal);
145  signal (SIGINT, rc_signal);
146  signal (SIGALRM, rc_signal);
147#ifdef HAVE_X86
148  signal (SIGTERM, rc_signal);
149#endif
150  sigemptyset (&sigset);
151
152  /* Give user a chance to run a shell before bringing up the rest of the system */
153
154  if (!noconsole)
155    ddrun_shell (1, 0);
156  cprintf ("setup nvram\n");
157
158  start_service ("nvram");
159
160  /* Restore defaults if necessary */
161  int brand = getRouterBrand ();
162
163#ifdef HAVE_SKYTEL
164  nvram_set ("vlan0ports", "0 1 2 3 4 5*");
165  nvram_set ("vlan1ports", "");
166#else
167
168  if (brand == ROUTER_WRT600N)
169    {
170      nvram_set ("vlan2hwname", "et0");
171    }
172
173
174#endif
175  start_service ("restore_defaults");
176
177
178  /* Add vlan */
179  boardflags = strtoul (nvram_safe_get ("boardflags"), NULL, 0);
180  nvram_set ("wanup", "0");
181
182
183#ifndef HAVE_RB500
184  switch (brand)
185    {
186    case ROUTER_WRT600N:
187    case ROUTER_ASUS_WL500GD:
188    case ROUTER_ASUS_WL550GE:
189    case ROUTER_MOTOROLA:
190    case ROUTER_RT480W:
191    case ROUTER_WRT350N:
192    case ROUTER_BUFFALO_WZRG144NH:
193    case ROUTER_DELL_TRUEMOBILE_2300_V2:
194      start_service ("config_vlan");
195      break;
196    default:
197      if (check_vlan_support ())
198        {
199          start_service ("config_vlan");
200        }
201      break;
202
203    }
204#endif
205
206  set_ip_forward ('1');
207  system ("/etc/preinit");      //sets default values for ip_conntrack
208  system ("/bin/echo 0 > /proc/sys/net/ipv4/tcp_westwood");
209  system ("/bin/echo 1 > /proc/sys/net/ipv4/tcp_vegas_cong_avoid");
210  system ("/bin/echo 3 > /proc/sys/net/ipv4/tcp_vegas_alpha");
211  system ("/bin/echo 3 > /proc/sys/net/ipv4/tcp_vegas_beta");
212
213#ifdef HAVE_JFFS2
214  start_service ("jffs2");
215#endif
216#ifdef HAVE_MMC
217  start_service ("mmc");
218#endif
219
220  start_service ("mkfiles");
221  char *hostname;
222
223  /* set hostname to wan_hostname or router_name */
224  if (strlen (nvram_safe_get ("wan_hostname")) > 0)
225    hostname = nvram_safe_get ("wan_hostname");
226  else if (strlen (nvram_safe_get ("router_name")) > 0)
227    hostname = nvram_safe_get ("router_name");
228  else
229    hostname = "dd-wrt";
230
231  sethostname (hostname, strlen (hostname));
232  stop_service ("httpd");
233
234//create loginprompt
235  FILE *fp = fopen ("/tmp/loginprompt", "wb");
236
237#ifndef HAVE_MAKSAT
238#ifndef HAVE_MSSID
239#ifdef DIST
240  if (strlen (DIST) > 0)
241    fprintf (fp,
242             "DD-WRT v23 SP3 %s (c) 2008 NewMedia-NET GmbH\nRelease: "
243             BUILD_DATE " (SVN revision: %s)\n", DIST, SVN_REVISION);
244  else
245    fprintf (fp,
246             "DD-WRT v23 SP3 custom (c) 2008 NewMedia-NET GmbH\nRelease: "
247             BUILD_DATE " (SVN revision: %s)\n", SVN_REVISION);
248#else
249  fprintf (fp,
250           "DD-WRT v23 SP3 custom (c) 2008 NewMedia-NET GmbH\nRelease: "
251           BUILD_DATE " (SVN revision: %s)\n", SVN_REVISION);
252#endif
253#else
254#ifdef DIST
255  if (strlen (DIST) > 0)
256    fprintf (fp,
257             "DD-WRT v24 %s (c) 2008 NewMedia-NET GmbH\nRelease: " BUILD_DATE
258             " (SVN revision: %s)\n", DIST, SVN_REVISION);
259  else
260    fprintf (fp,
261             "DD-WRT v24 custom (c) 2008 NewMedia-NET GmbH\nRelease: "
262             BUILD_DATE " (SVN revision: %s)\n", SVN_REVISION);
263#else
264  fprintf (fp,
265           "DD-WRT v24 custom (c) 2008 NewMedia-NET GmbH\nRelease: "
266           BUILD_DATE " (SVN revision: %s)\n", SVN_REVISION);
267#endif
268#endif
269#endif
270
271  fclose (fp);
272  /* Loop forever */
273  for (;;)
274    {
275      switch (state)
276        {
277        case USER:              // Restart single service from WEB of tftpd, by honor
278          lcdmessage ("RESTART SERVICES");
279          cprintf ("USER1\n");
280          start_single_service ();
281#ifdef HAVE_CHILLI
282          start_service ("chilli");
283#endif
284#ifdef HAVE_WIFIDOG
285          start_service ("wifidog");
286#endif
287
288          state = IDLE;
289          break;
290
291        case RESTART:
292          lcdmessage ("RESTART SYSTEM");
293#ifdef HAVE_OVERCLOCKING
294          start_service ("overclocking");
295#endif
296          cprintf ("RESET NVRAM VARS\n");
297          nvram_set ("wl0_lazy_wds", nvram_safe_get ("wl_lazy_wds"));
298#ifndef HAVE_MSSID
299          nvram_set ("wl0_akm", nvram_safe_get ("wl_akm"));
300          if (nvram_match ("wl_wep", "tkip"))
301            {
302              nvram_set ("wl_crypto", "tkip");
303            }
304          else if (nvram_match ("wl_wep", "aes"))
305            {
306              nvram_set ("wl_crypto", "aes");
307            }
308          else if (nvram_match ("wl_wep", "tkip+aes"))
309            {
310              nvram_set ("wl_crypto", "tkip+aes");
311            }
312          if (nvram_match ("wl_wep", "restricted"))
313            nvram_set ("wl_wep", "enabled");    // the nas need this value, the "restricted" is no longer need. (20040624 by honor)
314#endif
315
316          cprintf ("RESTART\n");
317
318#ifndef HAVE_MADWIFI
319          eval ("wlconf", nvram_safe_get ("wl0_ifname"), "down");
320#ifdef HAVE_MSSID
321          char *next;
322          char var[80];
323          char *vifs = nvram_safe_get ("wl0_vifs");
324          if (vifs != NULL)
325            foreach (var, vifs, next)
326            {
327              eval ("ifconfig", var, "down");
328            }
329#endif
330#endif
331
332          /* Fall through */
333        case STOP:
334          lcdmessage ("STOPPING SERVICES");
335          cprintf ("STOP\n");
336          killall ("udhcpc", SIGKILL);
337          setenv ("PATH",
338                  "/sbin:/bin:/usr/sbin:/usr/bin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin",
339                  1);
340          setenv ("LD_LIBRARY_PATH",
341                  "/lib:/usr/lib:/jffs/lib:/jffs/usr/lib:/mmc/lib:/mmc/usr/lib:",
342                  1);
343          cprintf ("STOP SERVICES\n");
344
345          stop_services ();
346          stop_service ("radio_timer");
347#ifndef HAVE_MADWIFI
348          stop_service ("nas");
349#endif
350          cprintf ("STOP WAN\n");
351          stop_service ("ttraff");
352          stop_service ("wan");
353          cprintf ("STOP LAN\n");
354#ifdef HAVE_MADWIFI
355          stop_service ("stabridge");
356#endif
357#ifdef HAVE_RSTP
358          eval ("killall", "rstpd");
359          unlink ("/tmp/.rstp_server");
360#endif
361#ifdef HAVE_VLANTAGGING
362          stop_service ("bridging");
363#endif
364#ifdef HAVE_BONDING
365          stop_service ("bonding");
366#endif
367
368          stop_service ("lan");
369#ifdef HAVE_VLANTAGGING
370          stop_service ("bridgesif");
371          stop_service ("vlantagging");
372#endif
373
374#ifndef HAVE_RB500
375          stop_service ("resetbutton");
376#endif
377          start_service ("create_rc_shutdown");
378          system ("/tmp/.rc_shutdown");
379          if (state == STOP)
380            {
381              state = IDLE;
382              break;
383            }
384          /* Fall through */
385        case START:
386          lcdmessage ("START SERVICES");
387          nvram_set ("wl0_lazy_wds", nvram_safe_get ("wl_lazy_wds"));
388#ifndef HAVE_MSSID
389          nvram_set ("wl0_akm", nvram_safe_get ("wl_akm"));
390#endif
391          cprintf ("START\n");
392          setenv ("PATH",
393                  "/sbin:/bin:/usr/sbin:/usr/bin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin",
394                  1);
395          setenv ("LD_LIBRARY_PATH",
396                  "/lib:/usr/lib:/jffs/lib:/jffs/usr/lib:/mmc/lib:/mmc/usr/lib:",
397                  1);
398#ifdef HAVE_IPV6
399          start_service ("ipv6");
400#endif
401#ifndef HAVE_RB500
402          start_service ("resetbutton");
403#endif
404          start_service ("setup_vlans");
405#ifndef HAVE_MADWIFI
406          if (nvram_match ("wl0_mode", "apstawet"))     //temporary fix for repeater-bridge mode init problem
407            {
408              nvram_set ("wl0_mode", "wet");
409              start_service ("wlconf");
410              eval ("wlconf", nvram_safe_get ("wl0_ifname"), "down");
411              nvram_set ("wl0_mode", "apstawet");
412            }
413          start_service ("wlconf");
414#endif
415
416#ifdef HAVE_VLANTAGGING
417          start_service ("bridging");
418#endif
419          start_service ("lan");
420#ifdef HAVE_BONDING
421          start_service ("bonding");
422#endif
423#ifdef HAVE_REGISTER
424          start_service ("mkfiles");
425#endif
426#ifdef HAVE_MADWIFI
427          start_service ("stabridge");
428#endif
429
430
431          cprintf ("start services\n");
432          start_services ();
433
434          cprintf ("start wan boot\n");
435          start_service ("wan_boot");
436          start_service ("ttraff");
437
438          cprintf ("diag STOP LED\n");
439          diag_led (DIAG, STOP_LED);
440          cprintf ("set led release wan control\n");
441          SET_LED (RELEASE_WAN_CONTROL);
442
443          if (nvram_match ("wl0_mode", "sta")
444              || nvram_match ("wl0_mode", "wet")
445              || nvram_match ("wl0_mode", "apsta")
446              || nvram_match ("wl0_mode", "apstawet"))
447            {
448              //fix for client mode
449              cprintf ("ifconfig wl up\n");
450              eval ("/sbin/ifconfig", get_wdev (), "up");
451            }
452
453#ifndef HAVE_MADWIFI
454#ifdef HAVE_RADIOOFF
455          if (nvram_match ("radiooff_button", "1")
456              && nvram_match ("radiooff_boot_off", "1"))
457            {
458              eval ("wl", "-i", get_wl_instance_name (0), "radio", "off");
459            }
460          else
461#endif
462            start_service ("nas");
463#ifdef HAVE_MSSID
464          start_service ("guest_nas");
465#endif
466#endif
467
468          start_service ("radio_timer");
469#ifdef HAVE_VLANTAGGING
470          start_service ("vlantagging");
471          start_service ("bridgesif");
472#endif
473
474
475          cprintf ("create rc file\n");
476#ifdef HAVE_REGISTER
477          if (isregistered ())
478#endif
479            {
480              start_service ("create_rc_startup");
481              chmod ("/tmp/.rc_startup", 0700);
482              system ("/tmp/.rc_startup");
483              system ("/etc/init.d/rcS");       // start openwrt startup script (siPath impl)
484              cprintf ("start modules\n");
485              start_service ("modules");
486#ifdef HAVE_MILKFISH
487              start_service ("milkfish_boot");
488#endif
489              if (nvram_invmatch ("rc_custom", ""))     //create custom script
490                {
491                  nvram2file ("rc_custom", "/tmp/custom.sh");
492                  chmod ("/tmp/custom.sh", 0700);
493                }
494            }
495
496#ifdef HAVE_CHILLI
497          start_service ("chilli");
498#endif
499#ifdef HAVE_WIFIDOG
500          start_service ("wifidog");
501#endif
502          cprintf ("start syslog\n");
503#ifndef HAVE_WRK54G
504          startstop ("syslog");
505#endif
506#ifdef HAVE_RSTP
507//just experimental for playing
508          eval ("brctl", "stp", "br0", "off");
509          eval ("rstpd");
510          eval ("rstpctl", "rstp", "br0", "on");
511#endif
512
513          system ("/etc/postinit");
514
515          led_control (LED_DIAG, LED_OFF);
516          lcdmessage ("System Ready");
517          /* Fall through */
518        case TIMER:
519          cprintf ("TIMER\n");
520          do_timer ();
521          /* Fall through */
522        case IDLE:
523          cprintf ("IDLE\n");
524          state = IDLE;
525          /* Wait for user input or state change */
526          while (signalled == -1)
527            {
528              if (!noconsole && (!shell_pid || kill (shell_pid, 0) != 0))
529                shell_pid = ddrun_shell (0, 1);
530              else
531                sigsuspend (&sigset);
532
533            }
534          state = signalled;
535          signalled = -1;
536          break;
537#ifdef HAVE_X86
538        case REBOOT:
539          lcdmessage ("System Reboots!");
540          system ("reboot");
541          break;
542#endif
543        default:
544          cprintf ("UNKNOWN\n");
545          return 0;
546        }
547
548    }
549
550}
551
552int
553get_wanface (int argc, char **argv)
554{
555  fprintf (stdout, "%s", get_wan_face ());
556  return 0;
557}
558
559struct MAIN
560{
561  char *callname;
562  char *execname;
563  int (*exec) (int argc, char **argv);
564};
565
566static struct MAIN maincalls[] = {
567  {"init", NULL, &main_loop},
568  {"ip-up", "ipup", NULL},
569  {"ip-down", "ipdown", NULL},
570  {"ipdown", "disconnected_pppoe", NULL},
571  {"udhcpc", "udhcpc", NULL},
572#ifdef HAVE_PPTPD
573  {"poptop", NULL, &pptpd_main},
574#endif
575  {"redial", NULL, &redial_main},
576#ifndef HAVE_RB500
577  {"resetbutton", NULL, &resetbutton_main},
578#endif
579  {"wland", "wland", NULL},
580  {"hb_connect", "hb_connect", NULL},
581  {"hb_disconnect", "hb_disconnect", NULL},
582  {"gpio", "gpio", NULL},
583  {"beep", "beep", NULL},
584  {"listen", NULL, &listen_main},
585  {"check_ps", NULL, &check_ps_main},
586  {"ddns_success", "ddns_success", NULL},
587  {"process_monitor", NULL, &process_monitor_main},
588  {"radio_timer", NULL, &radio_timer_main},
589  {"ttraf", NULL, &ttraff_main},
590#ifdef HAVE_WIVIZ
591  {"run_wiviz", NULL, &run_wiviz_main},
592  {"autokill_wiviz", NULL, &autokill_wiviz_main},
593#endif
594  {"site_survey", "site_survey", NULL},
595#ifdef HAVE_WOL
596  {"wol", NULL, &wol_main},
597#endif
598  {"event", NULL, &event_main},
599  {"switch", "switch", NULL},
600//#ifdef HAVE_MICRO
601//  {"brctl", "brctl", NULL},
602//#endif
603  {"getbridgeprio", "getbridgeprio", NULL},
604  {"setuserpasswd", "setuserpasswd", NULL},
605  {"getbridge", "getbridge", NULL},
606  {"watchdog", NULL, &watchdog_main},
607  {"nvram", NULL, &nvram_main},
608#ifdef HAVE_ROAMING
609  {"roaming_daemon", NULL, &roaming_daemon_main},
610  {"supplicant", "supplicant", NULL},
611#endif
612  {"get_wanface", NULL, &get_wanface},
613#ifndef HAVE_XSCALE
614  {"ledtool", NULL, &ledtool_main},
615#endif
616#ifdef HAVE_REGISTER
617  {"regshell", NULL, &reg_main}
618#endif
619};
620
621int
622main (int argc, char **argv)
623{
624  char *base = strrchr (argv[0], '/');
625
626  base = base ? base + 1 : argv[0];
627  int i;
628  for (i = 0; i < sizeof (maincalls) / sizeof (struct MAIN); i++)
629    {
630      if (strstr (base, maincalls[i].callname))
631        {
632          if (maincalls[i].execname)
633            return start_main (maincalls[i].execname, argc, argv);
634          if (maincalls[i].exec)
635            return maincalls[i].exec (argc, argv);
636        }
637    }
638
639
640
641  if (strstr (base, "startservice"))
642    {
643      if (argc < 2)
644        {
645          puts ("try to be professional\n");
646          return 0;
647        }
648      return start_service (argv[1]);
649    }
650  if (strstr (base, "stopservice"))
651    {
652      if (argc < 2)
653        {
654          puts ("try to be professional\n");
655          return 0;
656        }
657      return stop_service (argv[1]);
658    }
659
660#ifndef HAVE_RB500
661#ifndef HAVE_X86
662  /* erase [device] */
663  if (strstr (base, "erase"))
664    {
665      int brand = getRouterBrand ();
666      if (brand == ROUTER_MOTOROLA || brand == ROUTER_MOTOROLA_V1 || brand == ROUTER_MOTOROLA_WE800G || brand == ROUTER_RT210W || brand == ROUTER_BUFFALO_WZRRSG54)     //these routers have problem erasing nvram, so we only software restore defaults
667        {
668          if (argv[1] && strcmp (argv[1], "nvram"))
669            {
670              fprintf (stderr,
671                       "Sorry, erasing nvram will get this router unuseable\n");
672              return 0;
673            }
674        }
675      else
676        {
677          if (argv[1])
678            return mtd_erase (argv[1]);
679          else
680            {
681              fprintf (stderr, "usage: erase [device]\n");
682              return EINVAL;
683            }
684        }
685      return 0;
686    }
687
688  /* write [path] [device] */
689  if (strstr (base, "write"))
690    {
691      if (argc >= 3)
692        return mtd_write (argv[1], argv[2]);
693      else
694        {
695          fprintf (stderr, "usage: write [path] [device]\n");
696          return EINVAL;
697        }
698    }
699#else
700  if (strstr (base, "erase"))
701    {
702      if (argv[1] && strcmp (argv[1], "nvram"))
703        {
704          fprintf (stderr, "Erasing configuration data...\n");
705          eval ("mount", "/usr/local", "-o", "remount,rw");
706          eval ("rm", "-f", "/tmp/nvram/*");    // delete nvram database
707          eval ("rm", "-f", "/tmp/nvram/.lock");        // delete nvram database
708          eval ("rm", "-f", "/etc/nvram/*");    // delete nvram database
709          eval ("mount", "/usr/local", "-o", "remount,ro");
710        }
711      return 0;
712    }
713#endif
714#endif
715  /* hotplug [event] */
716  if (strstr (base, "hotplug"))
717    {
718      if (argc >= 2)
719        {
720          fprintf (stderr, "hotplug %s\n", argv[1]);
721          if (!strcmp (argv[1], "net"))
722            return start_service ("hotplug_net");
723#ifdef HAVE_USBHOTPLUG
724          if (!strcmp (argv[1], "usb"))
725            return start_service ("hotplug_usb");
726#endif
727#ifdef HAVE_XSCALE
728          if (!strcmp (argv[1], "firmware"))
729            return eval ("/etc/upload", argv[1]);
730#endif
731        }
732      else
733        {
734          fprintf (stderr, "usage: hotplug [event]\n");
735          return EINVAL;
736        }
737      return 0;
738    }
739  //////////////////////////////////////////////////////
740  //
741  if (strstr (base, "filtersync"))
742    return start_service ("filtersync");
743  /* filter [add|del] number */
744  if (strstr (base, "filter"))
745    {
746      if (argv[1] && argv[2])
747        {
748          int num = 0;
749          if ((num = atoi (argv[2])) > 0)
750            {
751              if (strcmp (argv[1], "add") == 0)
752                return start_servicei ("filter_add", num);
753              else if (strcmp (argv[1], "del") == 0)
754                return start_servicei ("filter_del", num);
755            }
756        }
757      else
758        {
759          fprintf (stderr, "usage: filter [add|del] number\n");
760          return EINVAL;
761        }
762      return 0;
763    }
764
765  if (strstr (base, "restart_dns"))
766    {
767      stop_service ("dnsmasq");
768      stop_service ("udhcpd");
769      start_service ("udhcpd");
770      start_service ("dnsmasq");
771      return 0;
772    }
773  if (strstr (base, "setpasswd"))
774    {
775      start_service ("mkfiles");
776      return 0;
777    }
778  /* rc [stop|start|restart ] */
779  else if (strstr (base, "rc"))
780    {
781      if (argv[1])
782        {
783          if (strncmp (argv[1], "start", 5) == 0)
784            return kill (1, SIGUSR2);
785          else if (strncmp (argv[1], "stop", 4) == 0)
786            return kill (1, SIGINT);
787          else if (strncmp (argv[1], "restart", 7) == 0)
788            return kill (1, SIGHUP);
789        }
790      else
791        {
792          fprintf (stderr, "usage: rc [start|stop|restart]\n");
793          return EINVAL;
794        }
795    }
796  return 1;
797}
Note: See TracBrowser for help on using the repository browser.