forked from openzfs/zfs
/
preinstall
executable file
·51 lines (44 loc) · 1.59 KB
/
preinstall
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
#!/usr/bin/perl
$0 =~ m/.*\/(.*)$/;
my $stage = $1;
my $action = $ARGV[3];
my $wd = `pwd`;
chomp($wd);
my $actionsDir = $wd . "/" . 'postinstall' . "_actions/";
my $upgradeDir = $wd . "/" . 'postupgrade' . "_actions/";
my $upgrade = 0;
my $debug = 1;
if ( $0 =~ /postupgrade/ || $0 =~ /preupgrade/ || $action =~ /upgrade/) {
system("logger -p install.info 'Upgrade scripts will be run.'") if ( $debug );
$upgrade = 1;
}
if ( $stage =~ /pre/ )
{
$actionsDir = $wd . "/" . 'preinstall' . "_actions/";
$upgradeDir = $wd . "/" . 'preupgrade' . "_actions/";
}
if ( $upgrade == 1 && -e $upgradeDir ) {
system("logger -p install.info 'Running Upgrade Scripts . . .'") if ( $debug );
$count = 0;
foreach my $action (`/bin/ls \"$upgradeDir\"`) {
chomp($action);
system("logger -p install.info 'Begin script: $action'") if ( $debug );
system($upgradeDir . $action, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]) == 0 or die;
system("logger -p install.info 'End script: $action'") if ( $debug );
$count++;
}
system("logger -p install.info '$count Upgrade Scripts run.'") if ( $debug );
}
if ( -e $actionsDir ) {
system("logger -p install.info 'Running Install Scripts . . .'") if ( $debug );
$count = 0;
foreach my $action (`/bin/ls \"$actionsDir\"`) {
chomp($action);
system("logger -p install.info 'Begin script: $action'") if ( $debug );
system($actionsDir . $action, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3],$upgrade) == 0 or die;
system("logger -p install.info 'End script: $action'") if ( $debug );
$count++;
}
system("logger -p install.info '$count Install Scripts run.'") if ( $debug );
}
exit(0);