-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanoid-portable.pl
62 lines (50 loc) · 1.56 KB
/
sanoid-portable.pl
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
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
use Getopt::Long;
use JSON::PP;
open my $versions_json_file, '<', "$FindBin::Bin/../lib/versions.json" or die "Can't open versions.json: $!";
my $versions_json = do { local $/; <$versions_json_file> };
close $versions_json_file;
my $versions = decode_json($versions_json);
my $sanoid_version = $versions->{'Sanoid'};
my $packaging_revision = $versions->{'PackagingRevision'};
my $apperl_version = $versions->{'APPerl'};
my $sanoid_portable_version = "$sanoid_version-$packaging_revision";
my $perl_version = $^V; # Built-in variable for Perl version
my $usage = <<'EOF';
This binary executes sanoid, syncoid, or findoid based on the name of the symbolic link invoked.
Create symbolic links to use the different tools:
ln -s sanoid-portable sanoid
ln -s sanoid-portable syncoid
ln -s sanoid-portable findoid
Make sure to make sanoid-portable executable:
chmod +x sanoid-portable
Then invoke the symlink:
./sanoid --help
./syncoid --help
./findoid --help
Options:
-V, --version Print version information and exit
-h, --help Print this help message and exit
EOF
my $all_versions = <<"EOF";
sanoid-portable: $sanoid_portable_version
sanoid: $sanoid_version
Perl: $perl_version
APPerl: $apperl_version
EOF
# Parse command-line options
my $print_version_only = 0;
my $print_help = 0;
GetOptions(
'V|version' => \$print_version_only,
'h|help' => \$print_help
);
if ($print_version_only) {
print "$sanoid_portable_version\n";
exit 0;
}
print $usage;
print "$all_versions\n";