Bump vdradmin package version.
[people/pmueller/ipfire-2.x.git] / src / ppp / dialer
1 #!/usr/bin/perl
2 #
3 # SmoothWall CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) The SmoothWall Team
8 #
9 # $Id: dialer,v 1.3.2.2 2005/01/26 12:23:26 riddles Exp $
10 #
11
12 use strict;
13 require '/var/ipfire/general-functions.pl';
14
15 my %pppsettings;
16 my %modemsettings;
17
18 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
19 &General::readhash("${General::swroot}/modem/settings", \%modemsettings);
20
21 if ($modemsettings{'INIT'} eq '') {
22 $modemsettings{'INIT'} = '+++ATZ'; }
23 if ($modemsettings{'HANGUP'} eq '') {
24 $modemsettings{'HANGUP'} = 'ATH'; }
25 if ($modemsettings{'SPEAKER_ON'} eq '') {
26 $modemsettings{'SPEAKER_ON'} = 'AT'; }
27 if ($modemsettings{'SPEAKER_OFF'} eq '') {
28 $modemsettings{'SPEAKER_OFF'} = 'AT'; }
29 if ($modemsettings{'TONE_DIAL'} eq '') {
30 $modemsettings{'TONE_DIAL'} = 'ATD'; }
31 if ($modemsettings{'PULSE_DIAL'} eq '') {
32 $modemsettings{'PULSE_DIAL'} = 'ATD'; }
33
34 my $telephone = $pppsettings{'TELEPHONE'};
35 my $username = $pppsettings{'USERNAME'};
36 my $password = $pppsettings{'PASSWORD'};
37
38 my ($loginscript, $speaker, $dial, $btfudge);
39
40 if ($pppsettings{'AUTH'} eq 'standard-login-script') {
41 $loginscript = 'standardloginscript'; }
42 elsif ($pppsettings{'AUTH'} eq 'demon-login-script') {
43 $loginscript = 'demonloginscript'; }
44 else {
45 $loginscript = $pppsettings{'LOGINSCRIPT'}; }
46 if ($pppsettings{'SPEAKER'} eq 'on') {
47 $speaker = $modemsettings{'SPEAKER_ON'}; }
48 else {
49 $speaker = $modemsettings{'SPEAKER_OFF'}; }
50 if ($pppsettings{'DIALMODE'} eq 'T') {
51 $dial = $modemsettings{'TONE_DIAL'} }
52 else {
53 $dial = $modemsettings{'PULSE_DIAL'} }
54 if ($pppsettings{'SENDCR'} eq 'off') {
55 $btfudge = '\\c'; }
56 else {
57 $btfudge = ''; }
58
59
60 my ($add_at1, $add_at2, $add_at3);
61
62 if ($pppsettings{'ADD_AT1'} eq '') {
63 $add_at1 = 'AT'; }
64 else {
65 $add_at1 = $pppsettings{'ADD_AT1'}; }
66 if ($pppsettings{'ADD_AT2'} eq '') {
67 $add_at2 = 'AT'; }
68 else {
69 $add_at2 = $pppsettings{'ADD_AT2'}; }
70 if ($pppsettings{'ADD_AT3'} eq '') {
71 $add_at3 = 'AT'; }
72 else {
73 $add_at3 = $pppsettings{'ADD_AT3'}; }
74
75 unlink('/var/log/connect.log');
76
77 my $com = "/usr/sbin/chat -v -r /var/log/connect.log \
78 TIMEOUT 3 \
79 REPORT CONNECT \
80 ABORT '\\nBUSY\\r' \
81 ABORT '\\nNO ANSWER\\r' \
82 ABORT '\\nRINGING\\r\\n\\r\\nRINGING\\r' \
83 ABORT '\\nNO CARRIER\\r' \
84 '' '$modemsettings{'INIT'}' \
85 '' '$add_at1' \
86 '' '$modemsettings{'INIT'}' \
87 OK '$modemsettings{'HANGUP'}' \
88 OK '$speaker' \
89 OK '$add_at2' \
90 '' '$add_at3' \
91 '' 'sleep 5' \
92 TIMEOUT '$modemsettings{'TIMEOUT'}' \
93 OK '\d${dial}${telephone}' \
94 CONNECT '${btfudge}' ";
95
96 if ($loginscript)
97 {
98 if (open(FILE, "/etc/ppp/${loginscript}"))
99 {
100 while (<FILE>) {
101 $com = "$com $_ "; }
102 close FILE;
103 }
104 $com =~ s/USERNAME/$username/;
105 $com =~ s/PASSWORD/$password/;
106 }
107
108 $com =~ s/\n//g;
109
110 exec $com;