line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of App-Cme |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2014-2022 by Dominique Dumont <ddumont@cpan.org>. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# ABSTRACT: Edit the configuration of an application with fuse |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package App::Cme::Command::fusefs ; |
13
|
|
|
|
|
|
|
$App::Cme::Command::fusefs::VERSION = '1.037'; |
14
|
1
|
|
|
1
|
|
743
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
15
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
16
|
1
|
|
|
1
|
|
9
|
use 5.10.1; |
|
1
|
|
|
|
|
3
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
5
|
use App::Cme -command ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
301
|
use base qw/App::Cme::Common/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
97
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
8
|
use Config::Model::ObjTreeScanner; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
409
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub validate_args { |
25
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
26
|
0
|
|
|
|
|
|
$self->check_unknown_args($args); |
27
|
0
|
|
|
|
|
|
$self->process_args($opt,$args); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $has_fuse = eval { require Config::Model::FuseUI; 1; }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
die "could not load Config::Model::FuseUI. Is Fuse installed ?\n" |
32
|
|
|
|
|
|
|
unless $has_fuse; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $fd = $opt->{fuse_dir}; |
35
|
0
|
0
|
|
|
|
|
die "Directory $fd does not exists\n" unless -d $fd; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub opt_spec { |
41
|
0
|
|
|
0
|
1
|
|
my ( $class, $app ) = @_; |
42
|
|
|
|
|
|
|
return ( |
43
|
|
|
|
|
|
|
[ |
44
|
0
|
|
|
|
|
|
"fuse-dir=s" => "Directory where the virtual file system will be mounted", |
45
|
|
|
|
|
|
|
{required => 1} |
46
|
|
|
|
|
|
|
], |
47
|
|
|
|
|
|
|
[ "dfuse!" => "debug fuse problems" ], |
48
|
|
|
|
|
|
|
[ "dir-char=s" => "string to replace '/' in configuration parameter names"], |
49
|
|
|
|
|
|
|
[ "backup:s" => "Create a backup of configuration files before saving." ], |
50
|
|
|
|
|
|
|
$class->cme_global_options, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub usage_desc { |
55
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
56
|
0
|
|
|
|
|
|
my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" |
57
|
0
|
|
|
|
|
|
return "$desc [application] [file ] -fuse-dir xxx [ -dir-char x ] "; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub description { |
61
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
62
|
0
|
|
|
|
|
|
return $self->get_documentation; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub execute { |
66
|
0
|
|
|
0
|
1
|
|
my ($self, $opt, $args) = @_; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my ($model, $inst, $root) = $self->init_cme($opt,$args); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my @extra; |
71
|
0
|
0
|
|
|
|
|
if (my $dc = $opt->{dir_char}) { |
72
|
0
|
|
|
|
|
|
push @extra, dir_char_mockup => $dc; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $fuse_dir = $opt->{fuse_dir}; |
76
|
0
|
|
|
|
|
|
print "Mounting config on $fuse_dir in background.\n", |
77
|
|
|
|
|
|
|
"Use command 'fusermount -u $fuse_dir' to unmount\n"; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $ui = Config::Model::FuseUI->new( |
80
|
|
|
|
|
|
|
root => $root, |
81
|
|
|
|
|
|
|
mountpoint => $fuse_dir, |
82
|
|
|
|
|
|
|
@extra, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# now fork |
87
|
0
|
|
|
|
|
|
my $pid = fork; |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
0
|
|
|
|
if ( defined $pid and $pid == 0 ) { |
90
|
|
|
|
|
|
|
# child process, just run fuse and wait for exit |
91
|
0
|
|
|
|
|
|
$ui->run_loop( debug => $opt->{fuse_debug} ); |
92
|
0
|
|
|
|
|
|
$self->save($inst,$opt); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# parent process simply exits |
96
|
0
|
|
|
|
|
|
return; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=pod |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=encoding UTF-8 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 NAME |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
App::Cme::Command::fusefs - Edit the configuration of an application with fuse |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 VERSION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
version 1.037 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SYNOPSIS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 DESCRIPTION |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Map the configuration file content to a FUSE virtual file system on a |
120
|
|
|
|
|
|
|
directory specified with option C<-fuse-dir>. Modifications done in |
121
|
|
|
|
|
|
|
the fuse file system are saved to the configuration file when |
122
|
|
|
|
|
|
|
C<< fusermount -u <mounted_fuse_dir> >> is run. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 Common options |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
See L<cme/"Global Options">. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 options |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=over |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item -fuse-dir |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Mandatory. Directory where the virtual file system will be mounted. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item -dfuse |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Use this option to debug fuse problems. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item -dir-char |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Fuse will fail if an element name or key name contains '/'. You can specify a |
143
|
|
|
|
|
|
|
substitution string to replace '/' in the fused dir. Default is C<< <slash> >>. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 SEE ALSO |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
L<cme> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 AUTHOR |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Dominique Dumont |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This software is Copyright (c) 2014-2022 by Dominique Dumont <ddumont@cpan.org>. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This is free software, licensed under: |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |