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: Modify the configuration of an application |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package App::Cme::Command::modify ; |
13
|
|
|
|
|
|
|
$App::Cme::Command::modify::VERSION = '1.037'; |
14
|
1
|
|
|
1
|
|
670
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
15
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
16
|
1
|
|
|
1
|
|
9
|
use 5.10.1; |
|
1
|
|
|
|
|
4
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
4
|
use App::Cme -command ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
293
|
use base qw/App::Cme::Common/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
147
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
6
|
use Config::Model::ObjTreeScanner; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
23
|
1
|
|
|
1
|
|
5
|
use Config::Model qw/initialize_log4perl/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
322
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub validate_args { |
26
|
6
|
|
|
6
|
1
|
15622
|
my ($self, $opt, $args) = @_; |
27
|
6
|
|
|
|
|
35
|
$self->check_unknown_args($args); |
28
|
6
|
|
|
|
|
27
|
$self->process_args($opt,$args); |
29
|
|
|
|
|
|
|
$self->usage_error("No modification instructions given on command line") |
30
|
6
|
50
|
66
|
|
|
23
|
unless @$args or $opt->{save}; |
31
|
6
|
|
|
|
|
24
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub opt_spec { |
35
|
6
|
|
|
6
|
1
|
18
|
my ( $class, $app ) = @_; |
36
|
|
|
|
|
|
|
return ( |
37
|
6
|
|
|
|
|
44
|
[ "backup:s" => "Create a backup of configuration files before saving." ], |
38
|
|
|
|
|
|
|
$class->cme_global_options, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub usage_desc { |
43
|
6
|
|
|
6
|
1
|
12330
|
my ($self) = @_; |
44
|
6
|
|
|
|
|
28
|
my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" |
45
|
6
|
|
|
|
|
110
|
return "$desc [application] [file ] instructions"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub description { |
49
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
50
|
0
|
|
|
|
|
0
|
return $self->get_documentation; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub execute { |
54
|
6
|
|
|
6
|
1
|
54
|
my ($self, $opt, $args) = @_; |
55
|
|
|
|
|
|
|
|
56
|
6
|
100
|
|
|
|
39
|
$opt->{_verbose} = 'Loader' if $opt->{verbose}; |
57
|
|
|
|
|
|
|
|
58
|
6
|
|
|
|
|
37
|
my ($model, $inst, $root) = $self->init_cme($opt,$args); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# needed to create write_back subs |
61
|
6
|
100
|
100
|
|
|
36441
|
$root->dump_tree() if $opt->{save} and not @$args; |
62
|
|
|
|
|
|
|
|
63
|
6
|
|
|
|
|
12281
|
$root->load("@$args"); |
64
|
|
|
|
|
|
|
|
65
|
4
|
|
|
|
|
21722
|
$root->deep_check; # consistency check |
66
|
|
|
|
|
|
|
|
67
|
4
|
|
|
|
|
11009
|
$self->save($inst,$opt) ; |
68
|
|
|
|
|
|
|
|
69
|
4
|
|
|
|
|
166
|
return; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=pod |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=encoding UTF-8 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
App::Cme::Command::modify - Modify the configuration of an application |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 VERSION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
version 1.037 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SYNOPSIS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# modify configuration with command line |
91
|
|
|
|
|
|
|
cme modify dpkg source 'format="(3.0) quilt"' |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Modify a configuration file with the values passed on the command line. |
96
|
|
|
|
|
|
|
These command must follow the syntax defined in L<Config::Model::Loader> |
97
|
|
|
|
|
|
|
(which is similar to the output of L<cme dump|"/dump"> command) |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Example: |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
cme modify dpkg 'source format="(3.0) quilt"' |
102
|
|
|
|
|
|
|
cme modify multistrap my_mstrap.conf 'sections:base source="http://ftp.fr.debian.org"' |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Some application like dpkg-copyright allows you to override the |
105
|
|
|
|
|
|
|
configuration file name. You must then use C<-file> option: |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
cme modify dpkg-copyright -file ubuntu/copyright 'Comment="Silly example"' |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Finding the right instructions to perform a modification may be |
110
|
|
|
|
|
|
|
difficult when starting from scratch. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
To get started, you can run C<cme dump --format cml> command to get |
113
|
|
|
|
|
|
|
the content of your configuration in the syntax accepted by C<cme modify>: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$ cme dump ssh -format cml |
116
|
|
|
|
|
|
|
Host:"*" - |
117
|
|
|
|
|
|
|
Host:"alioth.debian.org" |
118
|
|
|
|
|
|
|
User=dod - |
119
|
|
|
|
|
|
|
Host:"*.debian.org" |
120
|
|
|
|
|
|
|
IdentityFile:="~/.ssh/id_debian" |
121
|
|
|
|
|
|
|
User=dod - |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Then you can use this output to create instruction for a modification: |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$ cme modify ssh 'Host:"*" User=dod' |
126
|
|
|
|
|
|
|
Changes applied to ssh configuration: |
127
|
|
|
|
|
|
|
- Host:"*" User has new value: 'dod' |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 Common options |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
See L<cme/"Global Options">. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 options |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=over |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item -savek |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Force a save even if no change was done. Useful to reformat the configuration file. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item -verbose |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Show effect of the modify instructions. |
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 |