X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=scripts%2Flilo-uuid-diskid;h=60866b9849bae06346bbb73054af082aeb4c7a31;hb=e05a6f05e7fce66ac7560e066d995c456073d29f;hp=ab03744ade7667fe80525a48ea1e8496eb45a7e6;hpb=f574e1127a225e2de2e77a6b9e46a65986789f1f;p=rrq%2Fmaintain_lilo.git diff --git a/scripts/lilo-uuid-diskid b/scripts/lilo-uuid-diskid index ab03744..60866b9 100644 --- a/scripts/lilo-uuid-diskid +++ b/scripts/lilo-uuid-diskid @@ -3,7 +3,7 @@ # lilo-uuid-diskid - convert boot and root options to diskid # and uuid in /etc/lilo.conf # -# Copyright 2010-2011 Joachim Wiedorn +# Copyright 2010-2014 Joachim Wiedorn # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ use File::Copy; #---- global variables my $prog = $0; $prog =~ s#.*/##; -my $version = "0.3"; +my $version = "0.4"; #---- parameter check our $opt_h = 0; @@ -42,7 +42,8 @@ pod2usage(1) if $opt_h; #---- other variables our $liloconf = "/etc/lilo.conf"; -our $liloconfold = ''; +our $liloconfold = $liloconf . ".old"; +our $liloconfnew = $liloconf . ".new"; our $fstabconf = "/etc/fstab"; our $idpath = "/dev/disk/by-id"; our $uuidpath = "/dev/disk/by-uuid"; @@ -64,11 +65,12 @@ sub main { } if (-f $liloconf) { - $liloconfold = $liloconf . "_old"; + $liloconfold = $liloconf . ".old"; + $liloconfnew = $liloconf . ".new"; $exit = convert_lilo_conf(); } else { - print "cannot open $liloconf: file not found!\n"; + print "E: cannot open $liloconf: file not found!\n"; $exit = 1; } return $exit; @@ -85,7 +87,7 @@ sub convert_lilo_conf { # at first read lilo.conf and search for 'boot' my $ok = 0; - open(MYFH, "<$liloconf") or die ("cannot open $liloconf: $!"); + open(MYFH, "<$liloconf") or die ("E: cannot open $liloconf: $!"); @sellines = grep(/^#?boot/, readline(MYFH)); close(MYFH); @@ -113,7 +115,7 @@ sub convert_lilo_conf { write_boot_option(); } else { - if($opt_v) { print "cannot open $boot_id: link does not exist!\n"; } + if($opt_v) { print "E: cannot open $boot_id: link does not exist!\n"; } $exit = 1; } } @@ -122,7 +124,7 @@ sub convert_lilo_conf { } } else { - print "cannot use $liloconf: uncomplete configuration!\n"; + print "E: cannot use $liloconf: uncomplete configuration!\n"; $exit = 1; } @@ -151,12 +153,12 @@ sub detect_boot_device { # found only ^#boot in lilo.conf, then /etc/fstab is needed if (-f $fstabconf) { if($opt_v) { - print "no boot option in $liloconf: selecting from $fstabconf\n"; + print "W: no boot option in $liloconf: selecting from $fstabconf\n"; } $boot_disk = read_fstab($fstabconf); } else { - print "no boot option in $liloconf and no file $fstabconf found!\n"; + print "E: no boot option in $liloconf and no file $fstabconf found!\n"; $exit = 1; } } @@ -165,11 +167,11 @@ sub detect_boot_device { if($boot_disk =~ /$idpath/ or $boot_disk =~ /$uuidpath/ or $boot_disk =~ /$labpath/) { - print "boot option is already updated to $boot_disk\n"; + print "Boot option is already updated to $boot_disk\n"; $bootready = 1; $exit = 1; } else { - if($opt_v) { print "convert boot option $boot_disk into new ID\n"; } + if($opt_v) { print "Convert boot option $boot_disk into new ID\n"; } # is it a block device name ? $_part = $boot_disk; @@ -181,7 +183,7 @@ sub detect_boot_device { } } else { - if($opt_v) { print "cannot read $boot_disk: link does not exist!\n"; } + if($opt_v) { print "E: cannot read $boot_disk: link does not exist!\n"; } $exit = 1; } return $exit; @@ -257,7 +259,7 @@ sub detect_root_device { # check if root device exist / also for raid volume if (-b $root_disk) { - if($opt_v) { print "convert root option $root_disk into new UUID\n"; } + if($opt_v) { print "Convert root option $root_disk into new UUID\n"; } $root_id = find_id_link($root_disk,$uuidpath); if (not -l "$uuidpath/$root_id") { $exit = 1; } } @@ -269,7 +271,7 @@ sub detect_root_device { $root_link =~ s{^LABEL=}{/dev/disk/by-label/}; $root_link =~ s{^UUID=}{/dev/disk/by-uuid/}; if (not -l $root_link) { - if($opt_v) { print "cannot check $root_link: link does not exist!\n"; } + if($opt_v) { print "W: cannot check $root_link: link does not exist!\n"; } } } return $exit; @@ -285,7 +287,7 @@ sub find_id_link { my $newdevid = ''; my $ok = 0; - opendir(MYDH, "$path_id") or die("cannot open $path_id: $! \n"); + opendir(MYDH, "$path_id") or die("E: cannot open $path_id: $! \n"); @sellinks = grep(!/\-part\d\d?$/, grep(!/^\.\.?$/, readdir(MYDH))); @sellinks = sort(@sellinks); closedir(MYDH); @@ -305,7 +307,7 @@ sub find_id_link { } } - if($opt_v and not $ok) { print "$olddev not converted: link not useful\n\n"; } + if($opt_v and not $ok) { print "W: $olddev not converted: link not useful!\n\n"; } return ($newdevid); } @@ -329,8 +331,8 @@ sub write_boot_option { # copy all lines from lilo.conf_old into # new lilo.conf and add 'boot=' line my $ok = 0; - open(MYFH_NEW, "> $liloconf") or die("cannot open $liloconf: $!"); - open(MYFH_OLD, "< $liloconfold") or die ("cannot open $liloconfold: $!"); + open(MYFH_NEW, "> $liloconf") or die("E: cannot open $liloconf: $!"); + open(MYFH_OLD, "< $liloconfold") or die ("E: cannot open $liloconfold: $!"); while () { # line read from MYFH_OLD @@ -381,7 +383,7 @@ sub write_boot_option { chmod (0600,$liloconf); } else { - print "file $liloconf does not exist: nothing changed\n"; + print "W: file $liloconf does not exist: nothing changed!\n"; } } @@ -424,7 +426,7 @@ lilo-uuid-diskid - convert boot / root options to diskid and uuid in lilo.conf =head1 SYNOPSIS -lilo-uuid-diskid [-h] [-v] [lilo.conf] +B [B<-h>] [B<-v>] [B] =head1 DESCRIPTION @@ -436,16 +438,6 @@ These conversions are necessary for use with newer kernel (>= 2.6.26) if it use the libata module for parallel and serial ATA interfaces of block devices (i. e. hard disks with IDE or SATA interface, usbsticks). -=head1 EXAMPLES - -Lines in the configuration file /etc/lilo.conf: - - #boot = /dev/sda - boot = /dev/disk/by-id/ata-SAMSUNG_SV1604N_S01FJ10X999999 - - #root = /dev/sda1 - root = "UUID=18843936-00f9-4df0-a373-000d05a5dd44" - =head1 OPTIONS =over 4 @@ -460,8 +452,33 @@ Print verbose messages. =back +=head1 EXAMPLES + +Lines in the configuration file /etc/lilo.conf: + + #boot = /dev/sda + boot = /dev/disk/by-id/ata-SAMSUNG_SV1604N_S01FJ10X999999 + + #root = /dev/sda1 + root = "UUID=18843936-00f9-4df0-a373-000d05a5dd44" + +=head1 COPYRIGHT and LICENSE + +Copyright (C) 2010-2014 Joachim Wiedorn + +This script is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + =head1 AUTHOR B was written by Joachim Wiedorn. +This manual page was written by Joachim Wiedorn . + +=head1 SEE ALSO + +B(8), B(8), B(8) + =cut