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