1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** generate start/stop script **
10 \*****************************************************************************/
19 int coredebug=0, carddebug=0, dspdebug=0;
26 // { "AVM Fritz PCI (PNP)", "avmfritz"},
27 { "HFC PCI (Cologne Chip)", "hfcpci"},
28 { "HFC-4S / HFC-8S / HFC-E1 (Cologne Chip)", "hfcmulti"},
29 { "HFC-S USB (Cologne Chip)", "hfcsusb"},
30 // { "HFC-S MINI (Cologne Chip)", "hfcsmini"},
31 // { "XHFC (Cologne Chip)", "xhfc"},
32 // { "Sedlbaur FAX", "sedlfax"},
33 // { "Winbond 6692 PCI", "w6692pci"},
41 char input[256], file[256];
43 printf("\n\nThis program generates a script, which is used to start/stop/restart mISDN\n");
44 printf("driver. Please select card only once. Mode and options are given by LCR.\n");
47 printf("\nSelect %sdriver for cards:\n\n", i?"another ":"");
49 while(cards[jj].name) {
50 printf(" (%d) %s\n", jj+1, cards[jj].name);
54 printf("\nSelect driver number[1-n] (or enter 'done'): "); fflush(stdout);
56 } while (atoi(input) <= 0 && !!strcmp(input, "done"));
57 type[i] = atoi(input);
59 if (!strcmp(input, "done"))
64 printf("\nNo cards defined!\n");
68 printf("\nEnter LAW audio mode. For a-LAW (default), just enter 0. For u-LAW enter 1.\n[0..n | 0xn]: "); fflush(stdout);
70 lawopt = strtoul(input, NULL, 0);
71 printf("\nEnter debugging flags of mISDN core. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
73 coredebug = strtoul(input, NULL, 0);
74 printf("\nEnter debugging flags of cards. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
76 carddebug = strtoul(input, NULL, 0);
77 printf("\nEnter dsp debugging flags of driver. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
79 dspdebug = strtoul(input, NULL, 0);
83 printf("\nWhere do you like to load the modules from, enter 0 for default, 1 for\n'/usr/local/lcr/modules/' or the full path.\n[0 | 1 | <path>]: "); fflush(stdout);
85 if (!strcmp(input, "0"))
87 if (!strcmp(input, "1"))
88 SCPY(input, "/usr/local/lcr/modules");
89 if (input[0]) if (input[strlen(input)-1] != '/')
92 printf("\n\nFinally tell me where to write the mISDN rc file.\nEnter the name 'mISDN' for current directory.\nYou may want to say '/usr/local/lcr/mISDN' or '/etc/rc.d/mISDN'\n: "); fflush(stdout);
94 if (!(fp=fopen(file, "w"))) {
95 fprintf(stderr, "\nError: Failed to open '%s', try again.\n", file);
98 fprintf(fp, "# rc script for mISDN driver\n\n");
99 fprintf(fp, "case \"$1\" in\n");
100 fprintf(fp, "\tstart|--start)\n");
101 fprintf(fp, "\t\t%s %smISDN_core%s debug=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, input[0]?".ko":"", coredebug);
102 fprintf(fp, "\t\t%s %smISDN_dsp%s debug=0x%x options=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, input[0]?".ko":"", dspdebug, lawopt);
104 while(cards[j].name) {
108 fprintf(fp, "\t\t%s %s%s%s debug=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, cards[j].module, input[0]?".ko":"", carddebug);
113 fprintf(fp, "\t\tsleep 1\n");
114 fprintf(fp, "\t\t;;\n\n");
115 fprintf(fp, "\tstop|--stop)\n");
121 fprintf(fp, "\t\trmmod %s\n", cards[j].module);
125 fprintf(fp, "\t\trmmod mISDN_dsp\n");
126 fprintf(fp, "\t\trmmod mISDN_core\n");
127 fprintf(fp, "\t\t;;\n\n");
128 fprintf(fp, "\trestart|--restart)\n");
129 fprintf(fp, "\t\tsh $0 stop\n");
130 fprintf(fp, "\t\tsleep 2 # some phones will release tei when layer 1 is down\n");
131 fprintf(fp, "\t\tsh $0 start\n");
132 fprintf(fp, "\t\t;;\n\n");
133 fprintf(fp, "\thelp|--help)\n");
134 fprintf(fp, "\t\techo \"Usage: $0 {start|stop|restart|help}\"\n");
135 fprintf(fp, "\t\texit 0\n");
136 fprintf(fp, "\t\t;;\n\n");
137 fprintf(fp, "\t*)\n");
138 fprintf(fp, "\t\techo \"Usage: $0 {start|stop|restart|help}\"\n");
139 fprintf(fp, "\t\texit 2\n");
140 fprintf(fp, "\t\t;;\n\n");
141 fprintf(fp, "esac\n");
144 printf("\nFile '%s' is written to the current directory.\n", file);