aboutsummaryrefslogtreecommitdiff
path: root/scripts/algaos-installer
blob: dc7acfa245a74c3cc61c401e81e7188fd47407d5 (plain)
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
#!/usr/bin/env perl
use v5.38.0;
use strict;
use warnings;

use Data::Dumper;
use AlgaOS::Installer::GUI;
use AlgaOS::Installer::Util;
use JSON qw/from_json to_json/;

use AlgaOS::Installer;

use Moo;
use Crypt::URandom qw/urandom/;

has _proxy_started          => ( is => 'rw' );
has _is_windows             => ( is => 'lazy' );
has _pipe_name              => ( is => 'lazy' );
has _secret                 => ( is => 'lazy' );

sub _build__secret($self) {
    return urandom(64);
}

sub _build__pipe_name($self) {
    state $ID_APP = 'FrontProxy';
    my $socket = "$ID_APP-$$";
    if ( $self->_is_windows ) {
        $socket = "\\\\.\\pipe\\$socket";
    }
    else {
        $socket = "/tmp/$socket.sock";
    }
    return $socket;
}

sub _build__is_windows {
    return $^O eq 'MSWin32';
}

sub run($self) {
    AlgaOS::Installer::GUI->new(
        pipe_name => $self->_pipe_name,
        secret    => $self->_secret
    )->run;
}

__PACKAGE__->new->run;