summaryrefslogtreecommitdiffstats
path: root/perl-install/network/isdn.pm
blob: 89161e78efdddb60769abdb48a7254689b57a8c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
package network::isdn; # $Id$

use strict;
use network::isdn_consts;
use common;
use any;
use modules;
use run_program;
use log;
use network::tools;
use vars qw(@ISA @EXPORT);
use MDK::Common::Globals "network", qw($in $prefix);
use MDK::Common::File;


@ISA = qw(Exporter);
@EXPORT = qw(isdn_write_config isdn_write_config_backend get_info_providers_backend isdn_ask_info isdn_ask_protocol isdn_ask isdn_detect isdn_detect_backend isdn_get_list isdn_get_info);

sub configure {
    my ($netcnx, $netc, $_isdn) = @_;
  isdn_step_1:
    defined $netc->{autodetect}{isdn}{id} and goto intern_pci;

    my $e = $in->ask_from_list_(N("Network Configuration Wizard"),
				N("What kind is your ISDN connection?"), [ N_("Internal ISDN card"), N_("External ISDN modem") ]
			       ) or return;
    
    if ($e =~ /card/) {
      intern_pci:
	$netc->{isdntype} = 'isdn_internal';
	$netcnx->{isdn_internal}{$_} = $netc->{autodetect}{isdn}{$_} foreach 'description', 'vendor', 'id', 'driver', 'card_type', 'type';
	$netcnx->{isdn_internal} = isdn_read_config($netcnx->{isdn_internal});
	isdn_detect($netcnx->{isdn_internal}, $netc) or goto isdn_step_1;
    } else {
	$netc->{isdntype} = 'isdn_external';
	$netcnx->{isdn_external}{device} = $netc->{autodetect}{modem};
	$netcnx->{isdn_external} = isdn_read_config($netcnx->{isdn_external});
	$netcnx->{isdn_external}{special_command} = 'AT&F&O2B40';
	require network::modem;
	network::modem::ppp_choose($in, $netc, $netcnx->{isdn_external}) or goto isdn_step_1;
    }
    1;
}

sub isdn_write_config {
    my ($isdn, $netc) = @_;
    $in->do_pkgs->install('isdn4net', if_($isdn->{speed} =~ /128/, 'ibod'), 'isdn4k-utils');
    isdn_write_config_backend($isdn, $netc);
    1;
}

sub isdn_write_config_backend {
    my ($isdn, $netc, $o_netcnx) = @_;
    defined $o_netcnx and $netc->{isdntype} = $o_netcnx->{type};

    output_with_perm("$prefix/etc/isdn/profile/link/myisp", 0600,
	  qq(
I4L_USERNAME="$isdn->{login}"
I4L_SYSNAME=""
I4L_LOCALMSN="$isdn->{phone_in}"
I4L_REMOTE_OUT="$isdn->{phone_out}"
I4L_DIALMODE="$isdn->{dialing_mode}"
) . if_($isdn->{speed} =~ /128/, 'SLAVE="ippp1"
'));
	output "$prefix/etc/isdn/profile/card/mycard",
	  qq(
I4L_MODULE="$isdn->{driver}"
I4L_TYPE="$isdn->{type}"
I4L_IRQ="$isdn->{irq}"
I4L_MEMBASE="$isdn->{mem}"
I4L_PORT="$isdn->{io}"
I4L_IO0="$isdn->{io0}"
I4L_IO1="$isdn->{io1}"
I4L_ID="HiSax"
I4L_FIRMWARE="$isdn->{firmware}"
);

	output "$prefix/etc/ppp/ioptions",
	  "lock
usepeerdns
defaultroute
";
	system "$prefix/etc/rc.d/init.d/isdn4linux restart";

    substInFile { s/^FIRMWARE.*\n//; $_ .= qq(FIRMWARE="$isdn->{firmware}"\n) if eof  } "$prefix/etc/sysconfig/network-scripts/ifcfg-ippp0";

    # we start the virtual interface at boot (we dial only on demand.
    substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=yes\n) if eof  } "$prefix/etc/sysconfig/network-scripts/ifcfg-ippp0";

    write_secret_backend($isdn->{login}, $isdn->{passwd});

    write_cnx_script($netc, "isdn",
"#/sbin/route del default
#/sbin/ifup ippp0
/usr/sbin/isdnctrl dial ippp0
" . if_($isdn->{speed} =~ /128/, "service ibod restart
"),
"/usr/sbin/isdnctrl hangup ippp0
#/sbin/ifdown ippp0
"  . if_($isdn->{speed} =~ /128/, "service ibod stop
"), $netc->{isdntype});
    1;
}

sub isdn_read_config {
    my ($isdn) = @_;
    
    my %match = (I4L_USERNAME => 'login',
		 I4L_LOCALMSN => 'phone_in',
		 I4L_REMOTE_OUT => 'phone_out',
		 I4L_DIALMODE => 'dialing_mode',
		 I4L_MODULE => 'driver',
		 I4L_TYPE => 'type',
		 I4L_IRQ => 'irq',
		 I4L_MEMBASE => 'mem',
		 I4L_PORT => 'io',
		 I4L_IO0 => 'io0',
		 I4L_IO1 => 'io1',
		 I4L_FIRMWARE => 'firmware');
    foreach ('link/myisp', 'card/mycard') {
	my %conf = getVarsFromSh("$prefix/etc/isdn/profile/$_");
	foreach (keys %conf) {	 
	    $isdn->{$match{$_}} = $conf{$_} if $match{$_};
	}
    }

    $isdn->{passwd} = network::tools::passwd_by_login($isdn->{login});
    #$isdn->{description} = '';
    #$isdn->{vendor} = '';
    #$isdn->{passwd2} = '';
    $isdn;
}

sub get_info_providers_backend {
    my ($isdn, $_netc, $name, $file) = @_;
    $name eq 'Unlisted - edit manually' and return;
    foreach (catMaybeCompressed($file)) {
	chop;
	my ($name_, $phone, $real, $dns1, $dns2) = split '=>';
	if ($name eq $name_) {
	    @$isdn{qw(user_name phone_out DOMAINNAME2 dnsServer3 dnsServer2)} =
	               ((split(/\|/, $name_))[2], $phone, $real, $dns1, $dns2);
	}
    }
}

sub isdn_ask_info {
    my ($isdn, $netc) = @_;
    my $f = "$ENV{SHARE_PATH}/ldetect-lst/isdn.db";
    $f = "$prefix$f" if !-e $f;
  isdn_ask_info_step1:
    my $str = $in->ask_from_treelist(N("ISDN Configuration"), N("Select your provider.\nIf it isn't listed, choose Unlisted."),
				     '|', ['Unlisted - edit manually',
					   read_providers_backend($f)], 'Unlisted - edit manually')
      or return;
    get_info_providers_backend($isdn, $netc, $str || 'Unlisted - edit manually', $f);
    $isdn->{huptimeout} = 180;
    $isdn->{$_} ||= '' foreach qw(phone_in phone_out dialing_mode login passwd passwd2 idl speed);
    add2hash($netc, { dnsServer2 => '', dnsServer3 => '', DOMAINNAME2 => '' });
    ask_info2($isdn, $netc) or goto isdn_ask_info_step1;
}

sub isdn_ask_protocol() {
    my @toto = (
	      { description => $::expert ? N("European protocol (EDSS1)") : N("European protocol"),
		protokol => 2 },
	      { description => $::expert ? N("Protocol for the rest of the world\nNo D-Channel (leased lines)") : N("Protocol for the rest of the world"),
		protokol => 3 }
	     );
    my $e = $in->ask_from_listf(N("ISDN Configuration"),
				N("Which protocol do you want to use?"),
				sub { $_[0]{description} },
				\@toto) or return 0;
    $e->{protokol};
}

sub isdn_ask {
    my ($isdn, $netc, $label) = @_;
    
    #- ISDN card already detected
    if (!$::expert && defined $netc->{autodetect}{isdn}{card_type}) {
	$in->ask_yesorno(N("ISDN Configuration"), N("Found \"%s\" interface do you want to use it ?", $netc->{autodetect}{isdn}{description}), 1) or return;
	$isdn->{$_} = $netc->{autodetect}{isdn}{$_} foreach qw(description vendor id card_type driver type mem io io0 io1 irq firmware);
	goto isdn_ask_step_3;
    }

 isdn_ask_step_1:
    my $e = $in->ask_from_list_(N("ISDN Configuration"),
				$label . "\n" . N("What kind of card do you have?"),
				[ N_("ISA / PCMCIA"), N_("PCI"), N_("USB"), N_("I don't know") ]
			       ) or return;
 isdn_ask_step_1b:
    if ($e =~ /PCI/) {
	$isdn->{card_type} = 'pci';
    } elsif ($e =~ /USB/) {
	$isdn->{card_type} = 'usb';
    } else {
	$in->ask_from_list_(N("ISDN Configuration"),
			    N("
If you have an ISA card, the values on the next screen should be right.\n
If you have a PCMCIA card, you have to know the \"irq\" and \"io\" of your card.
"),
			    [ N_("Continue"), N_("Abort") ]) eq 'Continue' or goto isdn_ask_step_1;
	$isdn->{card_type} = 'isa';
    }

  isdn_ask_step_2:
    $e = $in->ask_from_listf(N("ISDN Configuration"),
			     N("Which of the following is your ISDN card?"),
			     sub { $_[0]{description} },
			     [ grep { $_->{card} eq $isdn->{card_type} } @isdndata ]) or goto($isdn->{card_type} =~ /usb|pci/ ? 'isdn_ask_step_1' : 'isdn_ask_step_1b');
    $e->{$_} and $isdn->{$_} = $e->{$_} foreach qw(driver type mem io io0 io1 irq firmware);

  isdn_ask_step_3:
    $isdn->{protocol} = isdn_ask_protocol() or goto isdn_ask_step_2;
  isdn_ask_step_4:
    isdn_ask_info($isdn, $netc) or goto isdn_ask_step_3;
    isdn_write_config($isdn, $netc) or goto isdn_ask_step_4;
    1;
}

sub isdn_detect {
    my ($isdn, $netc) = @_;
    if ($isdn->{id}) {
  	log::explanations("found isdn card : $isdn->{description}; vendor : $isdn->{vendor}; id : $isdn->{id}; driver : $isdn->{driver}\n");
	$isdn->{description} =~ s/\|/ -- /;
	
   isdn_detect_step_0:
	defined $isdn->{type} and my $new = $in->ask_yesorno(N("ISDN Configuration"), N("Do you want to start a new configuration ?"), 1);
	
	if ($isdn->{type} eq '' || $new) {
	    isdn_ask($isdn, $netc, N("I have detected an ISDN PCI card, but I don't know its type. Please select a PCI card on the next screen.")) or goto isdn_detect_step_0;
	} else {
	  isdn_detect_step_1:
	    $isdn->{protocol} = isdn_ask_protocol() or goto isdn_detect_step_0;
	  isdn_detect_step_2:
	    isdn_ask_info($isdn, $netc) or goto isdn_detect_step_1;
	    isdn_write_config($isdn, $netc) or goto isdn_detect_step_2;
	}
    } else {
	isdn_ask($isdn, $netc, N("No ISDN PCI card found. Please select one on the next screen.")) or return;
    }
    $netc->{$_} = 'ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
    1;
}

sub isdn_detect_backend() {
    my $isdn = { };
    if (my ($c) = modules::probe_category('network/isdn')) {
	$isdn = { map { $_ => $c->{$_} } qw(description vendor id driver card_type type) };
	$isdn->{$_} = sprintf("%0x", $isdn->{$_}) foreach 'vendor', 'id';
	$isdn->{card_type} = $c->{bus} eq 'USB' ? 'usb' : 'pci';
	($isdn->{type}) = $isdn->{options} =~ /type=(\d+)/;
#	$c->{options} !~ /id=HiSax/ && $isdn->{driver} eq "hisax" and $c->{options} .= " id=HiSax";
	if ($c->{options} !~ /protocol=/ && $isdn->{protocol} =~ /\d/) {
	    modules::set_options($c->{driver}, $c->{options} . " protocol=" . $isdn->{protocol});
	}
	$c->{options} =~ /protocol=(\d)/ and $isdn->{protocol} = $1;
    }
    $isdn;
}

sub isdn_get_list() {
    map { $_->{description} } @isdndata;
}

sub isdn_get_info {
    my ($desc) = @_;
    find { $_->{description} eq $desc } @isdndata;
}

1;
s="hl opt">), configureX => __("X (for X Window System) is the heart of the GNU/Linux graphical interface on which all the graphical environments (KDE, GNOME, AfterStep, WindowMaker, etc.) bundled with Mandrake Linux rely. In this section, DrakX will try to configure X automatically. It is extremely rare for it to fail, unless the hardware is very old (or very new). If it succeeds, it will start X automatically with the best resolution possible, depending on the size of the monitor. A window will then appear and ask you if you can see it. If you are doing an \"Expert\" installation, you will enter the X configuration wizard. See the corresponding section of the manual for more information about this wizard. If you can see the message during the test, and answer \"Yes\", then DrakX will proceed to the next step. If you cannot see the message, it simply means that the configuration was wrong and the test will automatically end after 10 seconds, restoring the screen."), configureXmain => __("The first time you try the X configuration, you may not be very satisfied with its display (screen is too small, shifted left or right...). Hence, even if X starts up correctly, DrakX then asks you if the configuration suits you. It will also propose to change it by displaying a list of valid modes it could find, asking you to select one. As a last resort, if you still cannot get X to work, choose \"Change graphics card\", select \"Unlisted card\", and when prompted on which server, choose \"FBDev\". This is a failsafe option which works with any modern graphics card. Then choose \"Test again\" to be sure."), configureXxdm => __("Finally, you will be asked whether you want to see the graphical interface at boot. Note this question will be asked even if you chose not to test the configuration. Obviously, you want to answer \"No\" if your machine is to act as a server, or if you were not successful in getting the display configured."), createBootdisk => __("The Mandrake Linux CD-ROM has a built-in rescue mode. You can access it by booting from the CD-ROM, press the >>F1<< key at boot and type >>rescue<< at the prompt. But in case your computer cannot boot from the CD-ROM, you should come back to this step for help in at least two situations: * when installing the bootloader, DrakX will rewrite the boot sector (MBR) of your main disk (unless you are using another boot manager), to allow you to start up with either Windows or GNU/Linux (assuming you have Windows in your system). If you need to reinstall Windows, the Microsoft install process will rewrite the boot sector, and then you will not be able to start GNU/Linux! * if a problem arises and you cannot start up GNU/Linux from the hard disk, this floppy disk will be the only means of starting up GNU/Linux. It contains a fair number of system tools for restoring a system, which has crashed due to a power failure, an unfortunate typing error, a typo in a password, or any other reason. When you click on this step, you will be asked to enter a disk inside the drive. The floppy disk you will insert must be empty or contain data which you do not need. You will not have to format it since DrakX will rewrite the whole disk."), doPartitionDisks => __("At this point, you need to choose where you want to install the Mandrake Linux operating system on your hard drive. If your hard drive is empty or if an existing operating system is using all the available space, you will need to partition it. Basically, partitioning a hard drive consists of logically dividing it to create space to install your new Mandrake Linux system. Because the partitioning process' effects are usually irreversible, partitioning can be intimidating and stressful if you are an inexperienced user. Fortunately, there is a wizard which simplifies this process. Before beginning, please consult the manual and take your time. If you are running the installation in Expert mode, you will enter DiskDrake, the Mandrake Linux partitioning tool, which allows you to fine-tune your partitions. See the DiskDrake section in the ``User Guide''. From the installation interface, you can use the wizards as described here by clicking the dialog's \"Wizard\" button. If partitions have already been defined, either from a previous installation or from another partitioning tool, simply select those to install your Linux system. If partitions are not defined, you will need to create them using the wizard. Depending on your hard drive configuration, several options are available: * \"Use free space\": this option will simply lead to an automatic partitioning of your blank drive(s). You will not be prompted further; * \"Use existing partition\": the wizard has detected one or more existing Linux partitions on your hard drive. If you want to use them, choose this option; * \"Use the free space on the Windows; partition\": if Microsoft Windows is installed on your hard drive and takes all the space available on it, you have to create free space for Linux data. To do so, you can delete your Microsoft Windows partition and data (see ``Erase entire disk'' or ``Expert mode'' solutions) or resize your Microsoft Windows partition. Resizing can be performed without the loss of any data, provided you previously defragment the Windows partition. Backing up your data won't hurt either.. This solution is recommended if you want to use both Mandrake Linux and Microsoft Windows on the same computer. Before choosing this option, please understand that after this procedure, the size of your Microsoft Windows partition will be smaller than at the present time. You will have less free space under Microsoft Windows to store your data or to install new software; * \"Erase entire disk\": if you want to delete all data and all partitions present on your hard drive and replace them with your new Mandrake Linux system, choose this option. Be careful with this solution because you will not be able to revert your choice after you confirm; !! If you choose this option, all data on your disk will be lost. !! * \"Remove Windows\": this will simply erase everything on the drive and begin fresh, partitioning everything from scratch. All data on your disk will be lost; !! If you choose this option, all data on your disk will be lost. !! * \"Expert mode\": choose this option if you want to manually partition your hard drive. Be careful - it is a powerful but dangerous choice. You can very easily lose all your data. Hence, do not choose this unless you know what you are doing."), exitInstall => __("There you are. Installation is now complete and your GNU/Linux system is ready to use. Just click \"OK\" to reboot the system. You can start GNU/Linux or Windows, whichever you prefer (if you are dual-booting), as soon as the computer has booted up again. The \"Advanced\" button (in Expert mode only) shows two more buttons to: * \"generate auto-install floppy\": to create an installation floppy disk which will automatically perform a whole installation without the help of an operator, similar to the installation you just configured. Note that two different options are available after clicking the button: * \"Replay\". This is a partially automated installation as the partitioning step (and only this one) remains interactive; * \"Automated\". Fully automated installation: the hard disk is completely rewritten, all data is lost. This feature is very handy when installing a great number of similar machines. See the Auto install section on our web site; * \"Save packages selection\"(*): saves the package selection as done previously. Then, when doing another installation, insert the floppy inside the drive and run the installation going to the help screen by pressing on the [F1] key, and by issuing >>linux defcfg=\"floppy\"<<. (*) You need a FAT-formatted floppy (to create one under GNU/Linux, type \"mformat a:\")"), formatPartitions => __("Any partitions that have been newly defined must be formatted for use (formatting means creating a filesystem). At this time, you may wish to reformat some already existing partitions to erase any data they contain. If you wish to do that, please select those partitions as well. Please note that it is not necessary to reformat all pre-existing partitions. You must reformat the partitions containing the operating system (such as \"/\", \"/usr\" or \"/var\") but you do not have to reformat partitions containing data that you wish to keep (typically \"/home\"). Please be careful when selecting partitions. After formatting, all data on the selected partitions will be deleted and you will not be able to recover any of it. Click on \"OK\" when you are ready to format partitions. Click on \"Cancel\" if you want to choose another partition for your new Mandrake Linux operating system installation. Click on \"Advanced\" if you wish to select partitions that will be checked for bad blocks on the disk."), installPackages => __("Your new Mandrake Linux operating system is currently being installed. Depending on the number of packages you will be installing and the speed of your computer, this operation could take from a few minutes to a significant amount of time. Please be patient."), installUpdates => __("At the time you are installing Mandrake Linux, it is likely that some packages have been updated since the initial release. Some bugs may have been fixed, and security issues solved. To allow you to benefit from these updates, you are now proposed to download them from the Internet. Choose \"Yes\" if you have a working Internet connection, or \"No\" if you prefer to install updated packages later. Choosing \"Yes\" displays a list of places from which updates can be retrieved. Choose the one nearest you. Then a package-selection tree appears: review the selection, and press \"Install\" to retrieve and install the selected package(s), or \"Cancel\" to abort."), license => __("Before continuing, you should read carefully the terms of the license. It covers the whole Mandrake Linux distribution, and if you do not agree with all the terms in it, click on the \"Refuse\" button which will immediately terminate the installation. To continue with the installation, click on the \"Accept\" button."), miscellaneous => __("At this point, it is time to choose the security level desired for the machine. As a rule of thumb, the more exposed the machine is, and the more the data stored in it is crucial, the higher the security level should be. However, a higher security level is generally obtained at the expense of easiness of use. Refer to the \"msec\" chapter of the ``Reference Manual'' to get more information about the meaning of these levels. If you do not know what to choose, keep the default option."), partition_with_diskdrake => __("At this point, you need to choose which partition(s) will be used for the installation of your Mandrake Linux system. If partitions have already been defined, either from a previous installation of GNU/Linux or from another partitioning tool, you can use existing partitions. Otherwise, hard drive partitions must be defined. To create partitions, you must first select a hard drive. You can select the disk for partitioning by clicking on ``hda'' for the first IDE drive, ``hdb'' for the second, ``sda'' for the first SCSI drive and so on. To partition the selected hard drive, you can use these options: * \"Clear all\": this option deletes all partitions on the selected hard drive; * \"Auto allocate\": this option enables to automatically create \"Ext2\" and swap partitions in free space of your hard drive; * \"More\": gives access to additional features: * \"Save partition table\": saves the partition table to a floppy. Useful for later partition-table recovery if necessary. It is strongly recommended to perform this step; * \"Restore partition table\": allows to restore a previously saved partition table from floppy disk; * \"Rescue partition table\": if your partition table is damaged, you can try to recover it using this option. Please be careful and remember that it can fail; * \"Reload partition table\": discards all changes and loads your initial partition table; * \"Removable media automounting\": unchecking this option will force users to manually mount and unmount removable medias such as floppies and CD-ROMs. * \"Wizard\": use this option if you wish to use a wizard to partition your hard drive. This is recommended if you do not have a good knowledge of partitioning; * \"Undo\": use this option to cancel your changes; * \"Toggle to normal/expert mode\": allows additional actions on partitions (type, options, format) and gives more information; * \"Done\": when you are finished partitioning your hard drive, this will save your changes back to disk.