-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk3back
More file actions
40 lines (28 loc) · 742 Bytes
/
k3back
File metadata and controls
40 lines (28 loc) · 742 Bytes
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
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(setsid);
sub daemon {
my $pid = fork();
die "Fork failed: $!" unless defined $pid;
exit 0 if $pid;
setsid() or die "Can't start a new session: $!";
$pid = fork();
die "Second fork failed: $!" unless defined $pid;
exit 0 if $pid;
chdir '/' or die "Can't change directory to /: $!";
umask 0;
close STDIN;
close STDOUT;
close STDERR;
open(STDIN, '<', '/dev/null');
open(STDOUT, '>', '/dev/null');
open(STDERR, '>', '/dev/null');
}
sub k3s {
my $script = '/usr/local/emhttp/plugins/k3raid/event/any_event';
my @args = ('start_k3s');
exec { $script } $script, @args or die "execvp failed: $!";
}
daemon();
k3s();