LedgerSMB-Installer
view release on metacpan or search on metacpan
lib/LedgerSMB/Installer/OS/unix.pm view on Meta::CPAN
sub pkgs_from_modules($self, $mods) {
croak $log->fatal( 'Generic Unix support does not include package installers' );
}
sub pkg_install($self, $pkgs) {
croak $log->error( 'Generic linux support does not include package installers' );
}
sub untar($self, $tar, $target, %options) {
my @cmd = ($self->{cmd}->{tar}, 'xzf', $tar, '-C', $target);
push @cmd, ('--strip-components', $options{strip_components})
if $options{strip_components};
push @cmd, '--no-same-owner'
if $options{no_same_owner};
$log->debug( 'system(): ' . join(' ', map { "'$_'" } @cmd ) );
system(@cmd) == 0
or croak $log->fatal( "Failure executing tar - exit code: $?" );
}
sub verify_sig($self, $installpath, $tar, $sig, $key) {
my $tempdir = File::Spec->catdir( $installpath, 'tmp' );
my $gpgdir = File::Spec->catdir( $tempdir, 'gnupg' );
make_path( $tempdir, $gpgdir );
chmod( 0700, $gpgdir )
or warn $log->warning( "Unable to protect $gpgdir: $!" );
my @cmd = (
$self->{cmd}->{gpg},
'--quiet',
'--homedir', $gpgdir,
'--no-autostart',
'--batch',
'--no-tty',
'--yes',
'--trust-model', 'always',
'--no-default-keyring',
'--keyring',
File::Spec->catfile( $tempdir, 'verification-keyring.kbx' ),
);
$log->trace( "Importing key:\n$key" );
$log->debug( 'system(): ' . join( ' ', map { "'$_'" } (@cmd, '--import') ) );
open(my $fh, '|-', @cmd, '--import')
or die "Can't open pipe to gpg for download verification: $!";
print $fh $key;
close($fh) or warn "Error closing pipe to gpg on key import: $!";
$log->debug( 'system(): ' . join( ' ', map { "'$_'" } (@cmd, '--verify', $sig, $tar) ) );
system( @cmd, '--verify', $sig, $tar ) == 0
or croak $log->fatal( "Failure to verify gpg signature - exit code: $?" );
remove_tree( $tempdir );
$log->info( 'gpg signature validated correctly' );
}
sub generate_start_script($self, $installpath, $locallib) {
###TODO: capture file open error
my $script = File::Spec->catfile( $installpath, 'server-start' );
open( my $fh, '>', $script );
my $starman = $self->have_cmd( 'starman', 0, [ File::Spec->catdir( $locallib, 'bin' ) ] );
my $locallib_lib = File::Spec->catdir( $locallib, 'lib', 'perl5' );
say $fh <<~EOF;
#!/usr/bin/bash
cd $installpath
exec $^X \\
-I $installpath/lib \\
-I $installpath/old/lib \\
-I $locallib_lib \\
$starman \\
--listen 0.0.0.0:5762 \\
--workers \${LSMB_WORKERS:-5} \\
--preload-app bin/ledgersmb-server.psgi
EOF
###TODO: capture mode change error
chmod( 0755, $script );
}
1;
( run in 0.792 second using v1.01-cache-2.11-cpan-e93a5daba3e )