summaryrefslogtreecommitdiffstats
path: root/perl-install/timezone.pm
Commit message (Expand)AuthorAgeFilesLines
* use output_p() instead of output() for /etc/ntp/step-tickersPascal Rigaux2003-02-231-1/+1
* language/country selection change:Guillaume Cottenceau2003-02-081-74/+65
* use "if any" instead of "if grep", and various other occurences of "any", "ev...Pascal Rigaux2003-01-071-1/+1
* (sexProb): drop (unused!)Pascal Rigaux2002-12-131-17/+0
* do not use "local *F", use "my $F" or output() insteadPascal Rigaux2002-12-031-4/+3
* perl_checker adaptationsPascal Rigaux2002-11-271-2/+1
* use $::prefix in timezone::readPascal Rigaux2002-08-081-2/+1
* timezone::read now returns a hashPascal Rigaux2002-08-081-4/+2
* Help "perl -cw" not reporting any warningPascal Rigaux2002-07-251-2/+3
* remove duplicate entry in ntp_serversGuillaume Cottenceau2002-06-071-1/+0
* added Italy (time.ien.it) inYves Duret2002-01-201-0/+1
* use new mkdir_p, rm_rf and cp_af from MDK::CommonPascal Rigaux2001-09-161-2/+1
* Asia/Taipei for Traditional ChinesePascal Rigaux2001-09-081-1/+2
* (ntp_server): fix (step-tickers was empty)Pascal Rigaux2001-09-061-2/+3
* (ntp_server): also set /etc/ntp/step-tickersPascal Rigaux2001-09-031-0/+1
* update ntp servers listPascal Rigaux2001-08-021-38/+1
* move to MDK::Common, bool->to_boolPascal Rigaux2001-07-241-1/+1
* generalize the use of chomp_ as the functional alternative to chomp (and work...Pascal Rigaux2001-07-241-2/+2
* (configureTimezone): propose a list of NTP serversPascal Rigaux2001-07-031-0/+76
* (ntp_server): fixPascal Rigaux2001-07-031-0/+1
* add ntp handlingPascal Rigaux2001-07-031-1/+21
* (%l2t): fix for fuzzyChoicePascal Rigaux2001-03-241-2/+2
* - add many timezonesPascal Rigaux2001-03-141-3/+28
* add step summary. remove steps configureTimezone and configurePrinterPascal Rigaux2001-02-101-4/+5
* configureTimezone doesn't take parameter /etc/sysconfig/clockPascal Rigaux2001-02-091-3/+3
* no_commentPascal Rigaux2000-09-141-1/+1
* no_commentPascal Rigaux2000-07-311-0/+2
* no_commentPascal Rigaux2000-04-251-3/+3
* no_commentPascal Rigaux2000-03-141-1/+0
* no_commentPascal Rigaux2000-01-241-0/+3
* no_commentPascal Rigaux2000-01-121-0/+1
* no_commentPascal Rigaux2000-01-101-0/+1
* no_commentPascal Rigaux2000-01-061-1/+3
* no_commentPascal Rigaux2000-01-041-0/+1
* *** empty log message ***Pascal Rigaux2000-01-041-0/+1
* no_commentPascal Rigaux2000-01-041-1/+3
* no_commentPascal Rigaux1999-12-271-1/+1
* no_commentPascal Rigaux1999-12-241-0/+17
* no_commentPascal Rigaux1999-12-151-0/+1
* no_commentPascal Rigaux1999-12-141-2/+2
* *** empty log message ***Francois Pons1999-09-281-0/+7
* no_commentPascal Rigaux1999-09-201-1/+15
* no_commentPascal Rigaux1999-09-071-1/+9
* no_commentPascal Rigaux1999-09-071-0/+51
isStandalone; } sub change_device { my ($md_part, $new_device) = @_; if ($new_device ne $md_part->{device}) { inactivate_and_dirty($md_part); $md_part->{device} = $new_device; $_->{raid} = $new_device foreach @{$md_part->{disks}}; } } sub removeDisk { my ($raids, $part) = @_; my $md_part = fs::get::device2part($part->{raid}, $raids); inactivate_and_dirty($md_part); fs::type::set_isFormatted($part, 0); delete $part->{raid}; my $disks = $md_part->{disks}; @$disks = grep { $_ != $part } @$disks; if (@$disks) { update($md_part); } else { @$raids = grep { $_ != $md_part } @$raids; } write_conf($raids) if $::isStandalone; } sub updateSize { my ($part) = @_; local $_ = $part->{level}; my @l = map { $_->{size} } @{$part->{disks}}; $part->{size} = do { if (/0|linear/) { sum @l } elsif (/1/) { min @l } elsif (/4|5/) { min(@l) * (@l - 1) } elsif (/6/) { min(@l) * (@l - 2) } }; } sub allmodules { [ 'raid0', 'raid1', 'raid10', 'raid456' ]; } sub module { my ($part) = @_; my $level = $part->{level}; log::l("level $level"); if (member($level, 4, 5, 6)) { 'raid456'; } elsif ($level =~ /^\d+$/) { "raid$level"; } else { $level; } } sub update { updateSize($_) foreach @_; } sub make { my ($raids, $part) = @_; return if is_active($part->{device}); inactivate_and_dirty($part); isRAID($_) and make($raids, $_) foreach @{$part->{disks}}; eval { modules::load(module($part)) }; whereis_binary('mdadm') or die 'mdadm not installed'; my $dev = devices::make($part->{device}); my $nb = @{$part->{disks}}; run_program::run_or_die('mdadm', '--create', '--run', $dev, if_($nb == 1, '--force'), '--chunk=' . $part->{'chunk-size'}, "--level=$part->{level}", "--raid-devices=$nb", map { devices::make($_->{device}) } @{$part->{disks}}); if (my $raw_part = get_md_info($dev)) { $part->{UUID} = $raw_part->{UUID}; } write_conf($raids) if $::isStandalone; } sub format_part { my ($raids, $part) = @_; $part->{isFormatted} and return; make($raids, $part); fs::format::part_raw($part, undef); set_isFormatted($_, 1) foreach @{$part->{disks}}; } sub verify { my ($raids) = @_; foreach (@$raids) { my $nb = $_->{level} =~ /6/ ? 4 : $_->{level} =~ /4|5/ ? 3 : 2; @{$_->{disks}} >= $nb or die N("Not enough partitions for RAID level %d\n", $_->{level}); } } sub inactivate_and_dirty { my ($part) = @_; run_program::run('mdadm', '--stop', devices::make($part->{device})); set_isFormatted($part, 0); } sub active_mds() { map { if_(/^(md\S+)\s*:\s*active/, $1) } cat_("/proc/mdstat"); } sub inactive_mds() { map { if_(/^(md\S+)\s*:\s*inactive/, $1) } cat_("/proc/mdstat"); } sub free_mds { my ($raids) = @_; difference2([ map { "md$_" } 0 .. max_nb() ], [ map { $_->{device} } @$raids ]); } sub detect_during_install { my (@parts) = @_; foreach (@{allmodules()}) { eval { modules::load($_) }; } detect_during_install_once(@parts); detect_during_install_once(@parts) if active_mds(); #- try again to detect RAID 10 foreach (inactive_mds()) { log::l("$_ is an inactive md, we stop it to ensure it doesn't busy devices"); run_program::run('mdadm', '--stop', devices::make($_)); } } sub detect_during_install_once { my (@parts) = @_; devices::make("md$_") foreach 0 .. max_nb(); output('/etc/mdadm.conf', join(' ', 'DEVICE', (map { "/dev/$_" } active_mds()), map { devices::make($_->{device}) } @parts), "\n"); run_program::run('mdadm', '>>', '/etc/mdadm.conf', '--examine', '--scan'); run_program::run('mdadm', '--assemble', '--scan'); } sub get_existing { my @parts = @_; my $raids = []; foreach my $md (active_mds()) { my $raw_part = get_md_info(devices::make($md)) or next; $raw_part->{level} =~ s/raid//; #- { linear | raid0 | raid1 | raid5 | raid6 } -> { linear | 0 | 1 | 5 | 6 } my @mdparts = map { if (my $part = fs::get::device2part($_, [ @parts, @$raids ])) { $part; } else { log::l("ERROR: unknown raw raid device $_"); (); } } split(',', $raw_part->{devices}); my $md_part = new($raids, device => $md, UUID => $raw_part->{UUID}, level => $raw_part->{level}, disks => \@mdparts); my $type = fs::type::type_subpart_from_magic($md_part); if ($type) { put_in_hash($md_part, $type); } else { fs::type::set_fs_type($md_part, defaultFS()); } my $fs_type = $type && $type->{fs_type}; fs::type::set_isFormatted($md_part, to_bool($fs_type)); log::l("RAID: found $md (raid $md_part->{level}) type $fs_type with parts $raw_part->{devices}"); } $raids; } sub is_active { my ($dev) = @_; member($dev, active_mds()); } sub write_conf { my ($raids) = @_; @$raids or return; my @devices = uniq(map { devices::make($_->{device}) } map { @{$_->{disks}} } @$raids); output($::isInstall ? "$::prefix/etc/mdadm.conf" : "/etc/mdadm.conf", join(' ', 'DEVICE', @devices) . "\n", map { "ARRAY " . devices::make($_->{device}) . " UUID=$_->{UUID} auto=yes\n" } @$raids); } sub get_md_info { my ($dev) = @_; my $conf = parse_mdadm_conf(scalar run_program::get_stdout('mdadm', '--detail', '--brief', '-v', $dev)); @{$conf->{ARRAY}} or return; @{$conf->{ARRAY}} == 1 or internal_error("too many answers"); $conf->{ARRAY}[0]; } sub parse_mdadm_conf { my ($s) = @_; my %conf = (DEVICE => [], ARRAY => []); $s =~ s!^\s*#.*!!gm; #- remove comments $s =~ s!\n(\s)!$1!g; #- join lines starting with a space foreach (split("\n", $s)) { if (/^DEVICE\s+(.*)/) { push @{$conf{DEVICE}}, split(' ', $1); } elsif (my ($md, $md_conf) = /^ARRAY\s+(\S+)\s*(.*)/) { my %md_conf = map { if_(/(.*)=(.*)/, $1 => $2) } split(' ', $md_conf); $md_conf{level} =~ s/^raid//; $md_conf{device} = $md; push @{$conf{ARRAY}}, \%md_conf; } } \%conf; } 1;