line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# remote::winsvc Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Remote::Winsvc; |
7
|
1
|
|
|
1
|
|
633
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use base qw(Metabrik::Remote::Winexe Metabrik::Client::Smbclient); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
477
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
host => [ qw(host) ], # Inherited |
20
|
|
|
|
|
|
|
user => [ qw(username) ], # Inherited |
21
|
|
|
|
|
|
|
password => [ qw(password) ], # Inherited |
22
|
|
|
|
|
|
|
domain => [ qw(domain) ], # Inherited |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
commands => { |
25
|
|
|
|
|
|
|
start => [ qw(service host|OPTIONAL user|OPTIONAL password|OPTIONAL) ], |
26
|
|
|
|
|
|
|
stop => [ qw(service host|OPTIONAL user|OPTIONAL password|OPTIONAL) ], |
27
|
|
|
|
|
|
|
restart => [ qw(service host|OPTIONAL user|OPTIONAL password|OPTIONAL) ], |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub start { |
33
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
34
|
0
|
|
|
|
|
|
my ($service, $host, $user, $password) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
0
|
|
|
|
$host ||= $self->host; |
37
|
0
|
|
0
|
|
|
|
$user ||= $self->user; |
38
|
0
|
|
0
|
|
|
|
$password ||= $self->password; |
39
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('start', $service) or return; |
40
|
0
|
0
|
|
|
|
|
$self->brik_help_set_undef_arg('host', $host) or return; |
41
|
0
|
0
|
|
|
|
|
$self->brik_help_set_undef_arg('user', $user) or return; |
42
|
0
|
0
|
|
|
|
|
$self->brik_help_set_undef_arg('password', $password) or return; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $cmd = "\"cmd.exe /c sc start $service\""; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $self->execute($cmd); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub stop { |
50
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
51
|
0
|
|
|
|
|
|
my ($service, $host, $user, $password) = @_; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
0
|
|
|
|
$host ||= $self->host; |
54
|
0
|
|
0
|
|
|
|
$user ||= $self->user; |
55
|
0
|
|
0
|
|
|
|
$password ||= $self->password; |
56
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('stop', $service) or return; |
57
|
0
|
0
|
|
|
|
|
$self->brik_help_set_undef_arg('host', $host) or return; |
58
|
0
|
0
|
|
|
|
|
$self->brik_help_set_undef_arg('user', $user) or return; |
59
|
0
|
0
|
|
|
|
|
$self->brik_help_set_undef_arg('password', $password) or return; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $cmd = "\"cmd.exe /c sc stop $service\""; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $self->execute($cmd); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub restart { |
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
$self->stop(@_) or return; |
70
|
0
|
0
|
|
|
|
|
$self->start(@_) or return; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return 1; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |