Created
March 4, 2016 07:43
-
-
Save jreisinger/29119eaa31b156f93637 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use 5.010; | |
use autodie; | |
use Getopt::Long; | |
use Pod::Usage; | |
use File::Copy; | |
# Command line options | |
my $help = 0; | |
my $config = '/etc/network/interfaces'; | |
GetOptions( | |
"h|?|help" => \$help, | |
"config" => \$config, | |
) or pod2usage(1); | |
# Help | |
pod2usage( -exitval => 0, -verbose => 2, -noperldoc => 1 ) if $help; | |
# Backup config file or die | |
my $file = shift or die "you need to supply the config file\n"; | |
my $backup = $file . "_bak"; | |
die "backup $backup already exists\n" if -e $backup; | |
copy( $file, $file . "_bak" ) or die "can't make a backup: $!\n"; | |
# Create new file with changed configuration | |
# Show diff | |
__END__ | |
=head1 NAME | |
change-ip - <One-line description of programs's purpose> | |
=head1 SYNOPSIS | |
change-ip [options] NEW_IP | |
options: | |
-h, -?, --help brief help message | |
--config FILE interfaces configuration file | |
=head1 DESCRIPTION | |
A full description of the change-ip and its features. | |
May include numerous subsections (i.e., =head2, =head3, etc.). | |
=head1 EXAMPLES | |
Print out a short help message and exit: | |
change-ip -h | |
change-ip 192.168.1.11 | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment