pakfire: use correct tree on x86_64.
[ipfire-2.x.git] / src / ppp / dialer
CommitLineData
cd1a2927
MT
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
12use strict;
789047d0 13require '/var/ipfire/general-functions.pl';
cd1a2927
MT
14
15my %pppsettings;
16my %modemsettings;
17
18&General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
19&General::readhash("${General::swroot}/modem/settings", \%modemsettings);
20
21if ($modemsettings{'INIT'} eq '') {
761ef000 22 $modemsettings{'INIT'} = '+++ATZ'; }
cd1a2927 23if ($modemsettings{'HANGUP'} eq '') {
761ef000 24 $modemsettings{'HANGUP'} = 'ATH'; }
cd1a2927
MT
25if ($modemsettings{'SPEAKER_ON'} eq '') {
26 $modemsettings{'SPEAKER_ON'} = 'AT'; }
27if ($modemsettings{'SPEAKER_OFF'} eq '') {
28 $modemsettings{'SPEAKER_OFF'} = 'AT'; }
29if ($modemsettings{'TONE_DIAL'} eq '') {
30 $modemsettings{'TONE_DIAL'} = 'ATD'; }
31if ($modemsettings{'PULSE_DIAL'} eq '') {
32 $modemsettings{'PULSE_DIAL'} = 'ATD'; }
33
34my $telephone = $pppsettings{'TELEPHONE'};
35my $username = $pppsettings{'USERNAME'};
36my $password = $pppsettings{'PASSWORD'};
37
38my ($loginscript, $speaker, $dial, $btfudge);
39
40if ($pppsettings{'AUTH'} eq 'standard-login-script') {
41 $loginscript = 'standardloginscript'; }
42elsif ($pppsettings{'AUTH'} eq 'demon-login-script') {
43 $loginscript = 'demonloginscript'; }
44else {
45 $loginscript = $pppsettings{'LOGINSCRIPT'}; }
46if ($pppsettings{'SPEAKER'} eq 'on') {
47 $speaker = $modemsettings{'SPEAKER_ON'}; }
48else {
49 $speaker = $modemsettings{'SPEAKER_OFF'}; }
50if ($pppsettings{'DIALMODE'} eq 'T') {
51 $dial = $modemsettings{'TONE_DIAL'} }
52else {
53 $dial = $modemsettings{'PULSE_DIAL'} }
54if ($pppsettings{'SENDCR'} eq 'off') {
55 $btfudge = '\\c'; }
56else {
57 $btfudge = ''; }
58
789047d0
AF
59
60my ($add_at1, $add_at2, $add_at3);
61
62if ($pppsettings{'ADD_AT1'} eq '') {
63 $add_at1 = 'AT'; }
64else {
65 $add_at1 = $pppsettings{'ADD_AT1'}; }
66if ($pppsettings{'ADD_AT2'} eq '') {
67 $add_at2 = 'AT'; }
68else {
69 $add_at2 = $pppsettings{'ADD_AT2'}; }
70if ($pppsettings{'ADD_AT3'} eq '') {
71 $add_at3 = 'AT'; }
72else {
73 $add_at3 = $pppsettings{'ADD_AT3'}; }
74
cd1a2927
MT
75unlink('/var/log/connect.log');
76
77my $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'}' \
761ef000
AF
85 '' '$add_at1' \
86 '' '$modemsettings{'INIT'}' \
87 OK '$modemsettings{'HANGUP'}' \
f0f2978f 88 OK '$speaker' \
789047d0 89 OK '$add_at2' \
f0f2978f 90 '' '$add_at3' \
5c237109 91 '' 'sleep 5' \
cd1a2927 92 TIMEOUT '$modemsettings{'TIMEOUT'}' \
5c237109 93 OK '\d${dial}${telephone}' \
cd1a2927
MT
94 CONNECT '${btfudge}' ";
95
96if ($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
110exec $com;