source: src/router/rc/init.c

Last change on this file was 21673, checked in by BrainSlayer, 4 weeks ago

startup for opt/mmc and jffs

File size: 16.9 KB
Line 
1
2#include <stdio.h>
3#include <stdlib.h>
4#include <errno.h>
5#include <paths.h>
6#include <signal.h>
7#include <stdarg.h>
8#include <string.h>
9#include <termios.h>
10#include <unistd.h>
11#include <limits.h>
12#include <sys/fcntl.h>
13#include <sys/ioctl.h>
14#include <sys/mount.h>
15#include <sys/reboot.h>
16#include <sys/types.h>
17#include <sys/wait.h>
18#include <sys/time.h>
19
20#include <shutils.h>
21#include <utils.h>
22#include <bcmnvram.h>
23#include "rc.h"
24#include <cyutils.h>
25#include <revision.h>
26
27#define loop_forever() do { sleep(1); } while (1)
28#define SHELL "/bin/login"
29#define _PATH_CONSOLE   "/dev/console"
30
31#define start_service(a) sysprintf("startservice %s",a);
32#define start_service_f(a) sysprintf("startservice_f %s",a);
33#define start_services() system("startservices");
34#define start_single_service() system("start_single_service");
35#define stop_service(a) sysprintf("stopservice %s",a);
36#define stop_services() system("stopservices");
37#define startstop(a) sysprintf("startstop %s",a);
38#define startstop_f(a) sysprintf("startstop_f %s",a);
39
40extern struct nvram_tuple *srouter_defaults;
41
42static void set_term(int fd)
43{
44        struct termios tty;
45
46        tcgetattr(fd, &tty);
47
48        /*
49         * set control chars
50         */
51        tty.c_cc[VINTR] = 3;    /* C-c */
52        tty.c_cc[VQUIT] = 28;   /* C-\ */
53        tty.c_cc[VERASE] = 127; /* C-? */
54        tty.c_cc[VKILL] = 21;   /* C-u */
55        tty.c_cc[VEOF] = 4;     /* C-d */
56        tty.c_cc[VSTART] = 17;  /* C-q */
57        tty.c_cc[VSTOP] = 19;   /* C-s */
58        tty.c_cc[VSUSP] = 26;   /* C-z */
59
60        /*
61         * use line dicipline 0
62         */
63        tty.c_line = 0;
64
65        /*
66         * Make it be sane
67         */
68        tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD;
69        tty.c_cflag |= CREAD | HUPCL | CLOCAL;
70
71        /*
72         * input modes
73         */
74        tty.c_iflag = ICRNL | IXON | IXOFF;
75
76        /*
77         * output modes
78         */
79        tty.c_oflag = OPOST | ONLCR;
80
81        /*
82         * local modes
83         */
84        tty.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN;
85
86        tcsetattr(fd, TCSANOW, &tty);
87}
88
89int console_init()
90{
91        int fd;
92
93        /*
94         * Clean up
95         */
96        ioctl(0, TIOCNOTTY, 0);
97        close(0);
98        close(1);
99        close(2);
100        setsid();
101
102        /*
103         * Reopen console
104         */
105        if ((fd = open(_PATH_CONSOLE, O_RDWR)) < 0) {
106                /*
107                 * Avoid debug messages is redirected to socket packet if no exist a
108                 * UART chip, added by honor, 2003-12-04
109                 */
110                (void)open("/dev/null", O_RDONLY);
111                (void)open("/dev/null", O_WRONLY);
112                (void)open("/dev/null", O_WRONLY);
113                perror(_PATH_CONSOLE);
114                return errno;
115        }
116        dup2(fd, 0);
117        dup2(fd, 1);
118        dup2(fd, 2);
119
120        ioctl(0, TIOCSCTTY, 1);
121        tcsetpgrp(0, getpgrp());
122        set_term(0);
123
124        return 0;
125}
126
127pid_t ddrun_shell(int timeout, int nowait)
128{
129        pid_t pid;
130        char tz[1000];
131        char *envp[] = {
132                "TERM=vt100",
133                "TERMINFO=/etc/terminfo",
134                "HOME=/",
135                "PS1=\\u@\\h:\\w\\$ ",
136                "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin",
137                "LD_LIBRARY_PATH=/usr/lib:/lib:/jffs/usr/lib:/jffs/lib:/opt/lib:/opt/usr/lib",
138                "SHELL=" SHELL,
139                "USER=root",
140                tz,
141                NULL
142        };
143        int sig;
144
145        /*
146         * Wait for user input
147         */
148        // cprintf("Hit enter to continue...");
149        if (waitfor(STDIN_FILENO, timeout) <= 0)
150                return 0;
151
152        switch ((pid = fork())) {
153        case -1:
154                perror("fork");
155                return 0;
156        case 0:
157                /*
158                 * Reset signal handlers set for parent process
159                 */
160                for (sig = 0; sig < (_NSIG - 1); sig++)
161                        signal(sig, SIG_DFL);
162
163                /*
164                 * Reopen console
165                 */
166                console_init();
167                // if (ret) exit(0); //no console running
168                /*
169                 * Pass on TZ
170                 */
171                snprintf(tz, sizeof(tz), "TZ=%s", getenv("TZ"));
172
173                /*
174                 * Now run it.  The new program will take over this PID, so
175                 * nothing further in init.c should be run.
176                 */
177#ifdef HAVE_REGISTER
178                if (isregistered_real())
179#endif
180                {
181                        execve(SHELL, (char *[]) {
182                               "/bin/login", NULL}
183                               , envp);
184                }
185#ifdef HAVE_REGISTER
186                else {
187                        envp[6] = "SHELL=/sbin/regshell";
188                        execve("/sbin/regshell", (char *[]) {
189                               "/sbin/regshell", NULL}, envp);
190                }
191#endif
192
193                /*
194                 * We're still here? Some error happened.
195                 */
196                perror(SHELL);
197                exit(errno);
198        default:
199                if (nowait)
200                        return pid;
201                else {
202                        waitpid(pid, NULL, 0);
203                        return 0;
204                }
205        }
206}
207
208void shutdown_system(void)
209{
210        int sig;
211
212        /*
213         * Disable signal handlers
214         */
215        for (sig = 0; sig < (_NSIG - 1); sig++)
216                signal(sig, SIG_DFL);
217
218        /*
219         * Blink led before reboot
220         */
221        diag_led(DIAG, START_LED);
222        led_control(LED_DIAG, LED_ON);
223        start_service("run_rc_shutdown");
224#ifdef HAVE_LAGUNA
225        start_service("deconfigurewifi");
226#endif
227        fprintf(stderr, "Sending SIGTERM to all processes\n");
228        kill(-1, SIGTERM);
229        sync();
230        sleep(5);
231
232        fprintf(stderr, "Sending SIGKILL to all processes\n");
233        kill(-1, SIGKILL);
234        sync();
235        sleep(1);
236
237}
238
239static int fatal_signals[] = {
240        SIGQUIT,
241        SIGILL,
242#ifndef HAVE_RB500
243        SIGABRT,
244#endif
245        SIGFPE,
246        SIGPIPE,
247        SIGBUS,
248        // SIGSEGV, // Don't shutdown, when Segmentation fault.
249        SIGSYS,
250        SIGTRAP,
251        SIGPWR,
252        SIGTERM,                /* reboot */
253        // SIGUSR1, /* halt */ // We use the for some purpose
254};
255
256void fatal_signal(int sig)
257{
258        char *message = NULL;
259
260        switch (sig) {
261        case SIGQUIT:
262                message = "Quit";
263                break;
264        case SIGILL:
265                message = "Illegal instruction";
266                break;
267        case SIGABRT:
268                message = "Abort";
269                break;
270        case SIGFPE:
271                message = "Floating exception";
272                break;
273        case SIGPIPE:
274                message = "Broken pipe";
275                break;
276        case SIGBUS:
277                message = "Bus error";
278                break;
279        case SIGSEGV:
280                message = "Segmentation fault";
281                break;
282        case SIGSYS:
283                message = "Bad system call";
284                break;
285        case SIGTRAP:
286                message = "Trace trap";
287                break;
288        case SIGPWR:
289                message = "Power failure";
290                break;
291        case SIGTERM:
292                message = "Terminated";
293                break;
294                // case SIGUSR1: message = "User-defined signal 1"; break;
295        }
296
297        if (message)
298                cprintf("%s....................................\n", message);
299        else
300                cprintf("Caught signal %d.......................................\n", sig);
301
302        shutdown_system();
303        sleep(2);
304
305        /*
306         * Halt on SIGUSR1
307         */
308        reboot(sig == SIGUSR1 ? RB_HALT_SYSTEM : RB_AUTOBOOT);
309        loop_forever();
310}
311
312static void reap(int sig)
313{
314        pid_t pid;
315
316        while ((pid = waitpid(-1, NULL, WNOHANG)) > 0)
317                cprintf("Reaped %d\n", pid);
318}
319
320void signal_init(void)
321{
322        int i;
323
324        for (i = 0; i < sizeof(fatal_signals) / sizeof(fatal_signals[0]); i++)
325                signal(fatal_signals[i], fatal_signal);
326
327        signal(SIGCHLD, reap);
328}
329
330/*
331 * States
332 */
333enum {
334        RESTART,
335        STOP,
336        START,
337        TIMER,
338        USER,
339        IDLE,
340};
341
342static int state = START;
343static int signalled = -1;
344
345/*
346 * Signal handling
347 */
348static void rc_signal(int sig)
349{
350        if (state == IDLE) {
351                if (sig == SIGHUP) {
352                        lcdmessage("Signal RESTART");
353                        printf("signalling RESTART\n");
354                        signalled = RESTART;
355                } else if (sig == SIGUSR2) {
356                        lcdmessage("Signal START");
357                        printf("signalling START\n");
358                        signalled = START;
359                } else if (sig == SIGINT) {
360                        lcdmessage("Signal STOP");
361                        printf("signalling STOP\n");
362                        signalled = STOP;
363                } else if (sig == SIGALRM) {
364                        lcdmessage("Signal TIMER");
365                        printf("signalling TIMER\n");
366                        signalled = TIMER;
367                } else if (sig == SIGUSR1) {    // Receive from WEB
368                        lcdmessage("Signal USER");
369                        printf("signalling USER1\n");
370                        signalled = USER;
371                }
372
373        }
374}
375
376/*
377 * Timer procedure
378 */
379int do_timer(void)
380{
381        // do_ntp();
382        return 0;
383}
384
385static int noconsole = 0;
386
387static void set_tcp_params(void)
388{
389        system("/etc/preinit"); // sets default values for ip_conntrack
390
391        FILE *fp = fopen("/proc/sys/net/ipv4/tcp_available_congestion_control", "rb");
392        if (fp == NULL) {
393                char *vegas = "1";
394                char *westwood = "0";
395                char *bic = "0";
396                if (nvram_match("tcp_congestion_control", "westwood")) {
397                        westwood = "1";
398                        vegas = "0";
399                }
400                if (nvram_match("tcp_congestion_control", "bic")) {
401                        bic = "1";
402                        vegas = "0";
403                }
404                writeproc("/proc/sys/net/ipv4/tcp_westwood", westwood);
405                writeproc("/proc/sys/net/ipv4/tcp_vegas_cong_avoid", vegas);
406                writeproc("/proc/sys/net/ipv4/tcp_bic", bic);
407                writeproc("/proc/sys/net/ipv4/tcp_vegas_alpha", "3");
408                writeproc("/proc/sys/net/ipv4/tcp_vegas_beta", "3");
409        } else {
410                fclose(fp);
411                writeproc("/proc/sys/net/ipv4/tcp_congestion_control", nvram_default_get("tcp_congestion_control", "vegas"));
412        }
413
414}
415
416/*
417 * Main loop
418 */
419int main(int argc, char **argv)
420{
421        sigset_t sigset;
422        pid_t shell_pid = 0;
423        uint boardflags;
424
425        /*
426         * Basic initialization
427         */
428#ifdef HAVE_MICRO
429        if (console_init())
430                noconsole = 1;
431#endif
432        cprintf("init lcd\n");
433        initlcd();
434        cprintf("first message\n");
435        lcdmessage("System Start");
436        fprintf(stderr, "start service\n");
437        fprintf(stderr, "starting Architecture code for " ARCHITECTURE "\n");
438        start_service("devinit");       //init /dev /proc etc.
439        start_service("sysinit");
440#ifndef HAVE_MICRO
441        if (console_init())
442                noconsole = 1;
443#endif                          //HAVE_MICRO
444        start_service("drivers");
445        cprintf("setup signals\n");
446        /*
447         * Setup signal handlers
448         */
449        signal_init();
450        signal(SIGHUP, rc_signal);
451        signal(SIGUSR1, rc_signal);     // Start single service from WEB, by
452        // honor
453        signal(SIGUSR2, rc_signal);
454        signal(SIGINT, rc_signal);
455        signal(SIGALRM, rc_signal);
456        sigemptyset(&sigset);
457
458        /*
459         * Give user a chance to run a shell before bringing up the rest of the
460         * system
461         */
462
463        if (!noconsole)
464                ddrun_shell(1, 0);
465        cprintf("setup nvram\n");
466
467        start_service("nvram");
468
469        /*
470         * Restore defaults if necessary
471         */
472        int brand = getRouterBrand();
473
474#ifdef HAVE_SKYTEL
475        nvram_set("vlan0ports", "0 1 2 3 4 5*");
476        nvram_set("vlan1ports", "");
477#else
478
479        if (brand == ROUTER_WRT600N || brand == ROUTER_WRT610N) {
480                nvram_set("vlan2hwname", "et0");
481        }
482#endif
483        start_service("restore_defaults");
484
485        /*
486         * Add vlan
487         */
488        boardflags = strtoul(nvram_safe_get("boardflags"), NULL, 0);
489        nvram_set("wanup", "0");
490
491#ifndef HAVE_RB500
492        switch (brand) {
493        case ROUTER_WRT600N:
494        case ROUTER_WRT610N:
495        case ROUTER_ASUS_WL500GD:
496        case ROUTER_ASUS_WL550GE:
497        case ROUTER_MOTOROLA:
498        case ROUTER_RT480W:
499        case ROUTER_WRT350N:
500        case ROUTER_BUFFALO_WZRG144NH:
501        case ROUTER_DELL_TRUEMOBILE_2300_V2:
502                start_service("config_vlan");
503                break;
504        default:
505                if (check_vlan_support()) {
506                        start_service("config_vlan");
507                }
508                break;
509
510        }
511#endif
512
513        set_ip_forward('1');
514        set_tcp_params();
515#ifdef HAVE_JFFS2
516        start_service("jffs2");
517#endif
518#ifdef HAVE_MMC
519        start_service("mmc");
520#endif
521
522        start_service("mkfiles");
523        char *hostname;
524
525        /*
526         * set hostname to wan_hostname or router_name
527         */
528        if (strlen(nvram_safe_get("wan_hostname")) > 0)
529                hostname = nvram_safe_get("wan_hostname");
530        else if (strlen(nvram_safe_get("router_name")) > 0)
531                hostname = nvram_safe_get("router_name");
532        else
533                hostname = "dd-wrt";
534
535        sethostname(hostname, strlen(hostname));
536        stop_service("httpd");
537
538        // create loginprompt
539        FILE *fp = fopen("/tmp/loginprompt", "wb");
540
541#ifndef HAVE_MAKSAT
542#ifndef HAVE_TRIMAX
543#ifndef HAVE_WIKINGS
544#ifndef HAVE_ESPOD
545#ifndef HAVE_IPR
546#ifndef HAVE_NEXTMEDIA
547#ifndef HAVE_ERC
548#ifndef HAVE_CORENET
549#ifdef HAVE_TMK
550        fprintf(fp, "KMT-WAS %s (c) 2013 KMT GmbH\nRelease: " BUILD_DATE " (SVN revision: %s)\n", DIST, SVN_REVISION);
551#else
552#ifdef DIST
553        if (strlen(DIST) > 0)
554                fprintf(fp, "DD-WRT v24-sp2 %s (c) 2013 NewMedia-NET GmbH\nRelease: " BUILD_DATE " (SVN revision: %s)\n", DIST, SVN_REVISION);
555        else
556                fprintf(fp, "DD-WRT v24-sp2 custom (c) 2013 NewMedia-NET GmbH\nRelease: " BUILD_DATE " (SVN revision: %s)\n", SVN_REVISION);
557#else
558        fprintf(fp, "DD-WRT v24-sp2 custom (c) 2013 NewMedia-NET GmbH\nRelease: " BUILD_DATE " (SVN revision: %s)\n", SVN_REVISION);
559#endif
560#endif
561#endif
562#endif
563#endif
564#endif
565#endif
566#endif
567#endif
568#endif
569
570        fclose(fp);
571
572#ifndef HAVE_MADWIFI
573        int cnt = get_wl_instances();
574#endif
575        int c;
576
577        /*
578         * Loop forever
579         */
580        for (;;) {
581                switch (state) {
582                case USER:      // Restart single service from WEB of tftpd,
583                        // by honor
584                        lcdmessage("RESTART SERVICES");
585                        cprintf("USER1\n");
586                        start_single_service();
587#ifdef HAVE_CHILLI
588                        start_service("chilli");
589#endif
590#ifdef HAVE_WIFIDOG
591                        start_service("wifidog");
592#endif
593
594                        state = IDLE;
595                        break;
596
597                case RESTART:
598                        lcdmessage("RESTART SYSTEM");
599#ifdef HAVE_OVERCLOCKING
600                        start_service("overclocking");
601#endif
602                        cprintf("RESET NVRAM VARS\n");
603                        nvram_set("wl0_lazy_wds", nvram_safe_get("wl_lazy_wds"));
604
605                        cprintf("RESTART\n");
606
607#if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880)
608                        for (c = 0; c < cnt; c++) {
609                                sysprintf("wlconf %s down", get_wl_instance_name(c));
610                                char *next;
611                                char var[80];
612                                char *vifs = nvram_nget("wl%d_vifs", c);
613
614                                if (vifs != NULL)
615                                        foreach(var, vifs, next) {
616                                        sysprintf("ifconfig %s down", var);
617                                        }
618                        }
619#endif
620
621                        /*
622                         * Fall through
623                         */
624                case STOP:
625                        if (state == STOP && check_action() != ACT_IDLE) {
626                                state = IDLE;
627                                break;  //force reboot on upgrade
628                        }
629#ifdef HAVE_REGISTER
630                        if (isregistered_real())
631#endif
632                        {
633                                start_service("run_rc_shutdown");
634                        }
635
636                        if (state == STOP) {
637                                state = IDLE;
638                                break;
639                        }
640
641                        lcdmessage("STOPPING SERVICES");
642                        cprintf("STOP\n");
643                        killall("udhcpc", SIGKILL);
644                        setenv("PATH", "/sbin:/bin:/usr/sbin:/usr/bin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin", 1);
645                        setenv("LD_LIBRARY_PATH", "/lib:/usr/lib:/jffs/lib:/jffs/usr/lib:/mmc/lib:/mmc/usr/lib:/opt/lib:/opt/usr/lib", 1);
646                        cprintf("STOP SERVICES\n");
647
648                        stop_services();
649                        stop_service("radio_timer");
650#if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880)
651                        stop_service("nas");
652#endif
653                        cprintf("STOP WAN\n");
654                        stop_service("ttraff");
655                        stop_service("wan");
656                        cprintf("STOP LAN\n");
657#ifdef HAVE_MADWIFI
658                        stop_service("stabridge");
659#endif
660#ifdef HAVE_RSTP
661                        system("killall rstpd");
662                        unlink("/tmp/.rstp_server");
663#endif
664#ifdef HAVE_VLANTAGGING
665                        stop_service("bridging");
666#endif
667#ifdef HAVE_BONDING
668                        stop_service("bonding");
669#endif
670
671                        stop_service("lan");
672#ifdef HAVE_VLANTAGGING
673                        stop_service("bridgesif");
674                        stop_service("vlantagging");
675#endif
676
677#ifndef HAVE_RB500
678                        stop_service("resetbutton");
679#endif
680#ifdef HAVE_REGISTER
681                        if (isregistered_real())
682#endif
683                        {
684                                start_service("run_rc_shutdown");
685                        }
686                        /*
687                         * Fall through
688                         */
689                case START:
690                        set_tcp_params();
691                        lcdmessage("START SERVICES");
692                        nvram_set("wl0_lazy_wds", nvram_safe_get("wl_lazy_wds"));
693                        cprintf("START\n");
694                        setenv("PATH", "/sbin:/bin:/usr/sbin:/usr/bin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/sbin:/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/sbin", 1);
695                        setenv("LD_LIBRARY_PATH", "/lib:/usr/lib:/jffs/lib:/jffs/usr/lib:/mmc/lib:/mmc/usr/lib:/opt/lib:/opt/usr/lib", 1);
696#ifdef HAVE_IPV6
697                        start_service_f("ipv6");
698#endif
699#ifndef HAVE_RB500
700                        start_service_f("resetbutton");
701#endif
702                        start_service("setup_vlans");
703#if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880)
704                        start_service("wlconf");
705#endif
706#ifdef HAVE_VLANTAGGING
707                        start_service("bridging");
708#endif
709                        start_service("lan");
710#ifdef HAVE_BONDING
711                        start_service("bonding");
712#endif
713#ifdef HAVE_REGISTER
714                        start_service("mkfiles");
715#endif
716#ifdef HAVE_MADWIFI
717                        start_service_f("stabridge");
718#endif
719
720                        cprintf("start services\n");
721                        start_services();
722
723                        cprintf("start wan boot\n");
724#ifdef HAVE_VLANTAGGING
725                        start_service("vlantagging");
726                        start_service("bridgesif");
727#endif
728                        start_service("wan_boot");
729                        start_service_f("ttraff");
730
731                        cprintf("diag STOP LED\n");
732                        diag_led(DIAG, STOP_LED);
733                        cprintf("set led release wan control\n");
734                        SET_LED(RELEASE_WAN_CONTROL);
735
736#ifndef HAVE_ERC
737#ifdef HAVE_RADIOOFF
738                        if (nvram_match("radiooff_button", "1")
739                            && nvram_match("radiooff_boot_off", "1")) {
740                                start_service("radio_off");
741                                led_control(LED_SEC0, LED_OFF);
742                                led_control(LED_SEC1, LED_OFF);
743                        } else
744#endif
745                        {
746                                start_service("radio_on");
747                        }
748#endif
749                        start_service_f("radio_timer");
750
751                        cprintf("run rc file\n");
752#ifdef HAVE_REGISTER
753                        if (isregistered_real())
754#endif
755                        {
756                                start_service_f("run_rc_startup");
757// start init scripts                           
758                                system("/etc/init.d/rcS");     
759                                system("/opt/etc/init.d/rcS"); 
760                                system("/jffs/etc/init.d/rcS");
761                                system("/mmc/etc/init.d/rcS");
762                                // startup script
763                                // (siPath impl)
764                                cprintf("start modules\n");
765                                start_service_f("modules");
766#ifdef HAVE_MILKFISH
767                                start_service_f("milkfish_boot");
768#endif
769                                if (nvram_invmatch("rc_custom", ""))    // create
770                                        // custom
771                                        // script
772                                {
773                                        nvram2file("rc_custom", "/tmp/custom.sh");
774                                        chmod("/tmp/custom.sh", 0700);
775                                }
776                        }
777#ifdef HAVE_CHILLI
778                        start_service("chilli");
779#endif
780#ifdef HAVE_WIFIDOG
781                        start_service("wifidog");
782#endif
783                        cprintf("start syslog\n");
784#ifdef HAVE_SYSLOG
785                        startstop_f("syslog");
786#endif
787#ifdef HAVE_RSTP
788                        // just experimental for playing
789                        system("brctl stp br0 off");
790                        system("rstpd");
791                        system("rstpctl rstp br0 on");
792#endif
793
794                        system("/etc/postinit&");
795                        start_service("httpd");
796                        led_control(LED_DIAG, LED_OFF);
797                        lcdmessage("System Ready");
798#ifndef HAVE_RB500
799                        startstop_f("resetbutton");
800#endif
801                        /*
802                         * Fall through
803                         */
804                case TIMER:
805                        cprintf("TIMER\n");
806                        do_timer();
807                        /*
808                         * Fall through
809                         */
810                case IDLE:
811                        cprintf("IDLE\n");
812                        state = IDLE;
813                        /*
814                         * Wait for user input or state change
815                         */
816                        while (signalled == -1) {
817                                if (!noconsole && (!shell_pid || kill(shell_pid, 0) != 0))
818                                        shell_pid = ddrun_shell(0, 1);
819                                else
820                                        sigsuspend(&sigset);
821
822                        }
823                        state = signalled;
824                        signalled = -1;
825                        break;
826                default:
827                        cprintf("UNKNOWN\n");
828                        return 0;
829                }
830
831        }
832
833}
Note: See TracBrowser for help on using the repository browser.