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");
48 printf("\nSelect %sdriver for cards:\n\n", i?"another ":"");
52 printf(" (%d) %s\n", jj+1, cards[jj].name);
57 printf("\nSelect driver number[1-n] (or enter 'done'): "); fflush(stdout);
59 } while (atoi(input) <= 0 && !!strcmp(input, "done"));
60 type[i] = atoi(input);
62 if (!strcmp(input, "done"))
68 printf("\nNo cards defined!\n");
72 printf("\nEnter LAW audio mode. For a-LAW (default), just enter 0. For u-LAW enter 1.\n[0..n | 0xn]: "); fflush(stdout);
74 lawopt = strtoul(input, NULL, 0);
75 printf("\nEnter debugging flags of mISDN core. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
77 coredebug = strtoul(input, NULL, 0);
78 printf("\nEnter debugging flags of cards. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
80 carddebug = strtoul(input, NULL, 0);
81 printf("\nEnter dsp debugging flags of driver. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
83 dspdebug = strtoul(input, NULL, 0);
87 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);
89 if (!strcmp(input, "0"))
91 if (!strcmp(input, "1"))
92 SCPY(input, "/usr/local/lcr/modules");
93 if (input[0]) if (input[strlen(input)-1] != '/')
96 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);
98 if (!(fp=fopen(file, "w")))
100 fprintf(stderr, "\nError: Failed to open '%s', try again.\n", file);
103 fprintf(fp, "# rc script for mISDN driver\n\n");
104 fprintf(fp, "case \"$1\" in\n");
105 fprintf(fp, "\tstart|--start)\n");
106 fprintf(fp, "\t\t%s %smISDN_core%s debug=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, input[0]?".ko":"", coredebug);
107 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);
115 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);
120 fprintf(fp, "\t\tsleep 1\n");
121 fprintf(fp, "\t\t;;\n\n");
122 fprintf(fp, "\tstop|--stop)\n");
130 fprintf(fp, "\t\trmmod %s\n", cards[j].module);
134 fprintf(fp, "\t\trmmod mISDN_dsp\n");
135 fprintf(fp, "\t\trmmod mISDN_core\n");
136 fprintf(fp, "\t\t;;\n\n");
137 fprintf(fp, "\trestart|--restart)\n");
138 fprintf(fp, "\t\tsh $0 stop\n");
139 fprintf(fp, "\t\tsleep 2 # some phones will release tei when layer 1 is down\n");
140 fprintf(fp, "\t\tsh $0 start\n");
141 fprintf(fp, "\t\t;;\n\n");
142 fprintf(fp, "\thelp|--help)\n");
143 fprintf(fp, "\t\techo \"Usage: $0 {start|stop|restart|help}\"\n");
144 fprintf(fp, "\t\texit 0\n");
145 fprintf(fp, "\t\t;;\n\n");
146 fprintf(fp, "\t*)\n");
147 fprintf(fp, "\t\techo \"Usage: $0 {start|stop|restart|help}\"\n");
148 fprintf(fp, "\t\texit 2\n");
149 fprintf(fp, "\t\t;;\n\n");
150 fprintf(fp, "esac\n");
153 printf("\nFile '%s' is written to the current directory.\n", file);