cme1p
Check or edit configuration data with config::model
Usage
cme [global_options]
command
application
[options]
[file]
[modification_instructions]
cme edit
dpkg
cme check
dpkg-copyright
-file
path/to/file
sudo cme
edit
sshd
cme edit
ssh
cme check
multistrap
file.conf
cme check
multistrap
-file
file.conf
cme migrate
dpkg
cme fix
dpkg
cme modify
dpkg
source
'format="(3.0)
quilt"'
cme modify
dpkg-copyright
'Comment="Modified
with
cme"'
cme edit
multistrap
my.conf
cme fusefs
multistrap
my.conf
-d
fuse_dir
cme fusefs
dpkg
-d
fuse_dir
cme list
Version
version 1.041
Overview
Depending on the command described below, "cme" program will use Config::Model configuration descriptions to check or modify or fix configuration files.
The 3rd parameter specify the application you want to work on. Most of the time, the relevant configuration file(s) will be found by cme. This is the most simple case. For instance:
sudo cme check popcon
Some application like "multistrap" have no constraint on the configuration file name and will require you to specify your configuration file name:
cme check multistrap raspbian.conf
or
cme check multistrap -file raspbian.conf
Configuration file specification
The configuration of an application can take different forms. Either several files (like debian packages), a single file with a predefined file (popcon), or a single file with an arbitrary file name (multistrap).
When needed the configuration file name is specified as the 3rd command argument, i.e. "cme command application file_name". This applies if the application requires a configuration file name (like multistrap), or if the application allows configuration file override.
Main commands
This section describes the main commands shipped with cme. Other Config::Model extensions can bring more command. Run "cme help" to get the list of available commands on your system.
list
Show a list all applications where a model is available. This list depends on installed Config::Model modules.
edit
Edit a configuration. By default, a Tk GUI will be opened If Config::Model::TkUI is installed. See App::Cme::Command::edit.
shell
Edit the configuration with a shell like interface. See App::Cme::Command::shell.
check
Checks the content of the configuration file of an application. See App::Cme::Command::check.
migrate
Update deprecated parameters (old value are saved to new parameters) and save the new configuration. See App::Cme::Command::migrate.
fix
Migrate data and fix warnings. See App::Cme::Command::fix.
modify
Modify a configuration file with the values passed on the command line. See App::Cme::Command::modify.
update
Update the content of the configuration file from external data. Currently, only dpkg-copyright model support update sub command. See App::Cme::Command::update.
search
Search configuration data for a specific string. See App::Cme::Command::search.
fusefs
Map the configuration file content to a FUSE virtual file system on a directory specified with option "-fuse-dir". Modifications done in the fuse file system are saved to the configuration file when the "fusermount -u" is run.
Options
The following options are available for all commands:
-
-create -
Perform the operation even if the configuration file is missing. This may be used to create a minimal configuration file. This option is disabled by default as a missing configuration file often indicates an error during the installation of the application.
-
-file -
For model that support it, specify an alternate file to read and write the configuration.
You can use this option for model that require the target file to be specified (e.g. multitrap model), but file can in this case be also specified with the 4th command argument. E.g. these 2 commands have the same effect:
cme check multistrap foo.confcme check multistrap -file foo.conf
-
-force-load -
Load file even if error are found in data. Bad data are discarded
-
-canonical -
Write config data back using model order. By default, write items back using the order found in the configuration file. This feature is experimental and not supported by all backends.
-
-backup -
Create a backup of configuration files before saving. By default,
"old"will be appended to the backup file. I.e."foo.conf"will be backed up as"foo.conf.old". You can specify an alternate suffix. For instance"-backup dpkg-old".
-
-save -
Force a save even if no change was done. Useful to reformat the configuration file.
-
-strict -
When set, cme will exit 1 if warnings are found during check (of left after fix)
-
-verbose -
Show more information about what's going on.
-
-quiet -
Suppress all output except error messages.
Options
-
-model-dir -
Specify an alternate directory to find model files. Mostly useful for tests.
-
-root-dir -
Specify a pseudo root directory to read and write the configuration files. (Actual default directory and file names depends on the model (See
"-model"option). For instance, if you specify"~/mytest", the"/etc/ssh/sshd_config"files will be written in"~/mytest/etc/ssh/"directory.
-
-stack-trace -
Provides a full stack trace when exiting on error.
-
-try-app-as-model -
When set, try to load a model using directly the application name specified as 3rd parameter on the command line. Experimental.
Embedding cme
You can use cme from another program by using "-ui simple" option. This way you will be able to send command on the standard input of "cme" and get the results from the standard output.
Logging
All Config::Model logging is now based on Log::Log4perl. Logging can be configured in the following files:
- •
-
~/.log4config-model
- •
-
/etc/log4config-model.conf
A sample of a ".log4config-model" is provided in contrib directory in "Config::Model" distribution of on github <https://github.com/dod38fr/config-model/blob/master/contrib/log4config-model>
Without these files, the following Log4perl config is used:
log4perl.rootLogger=WARN, Screenlog4perl.logger.Model.Legacy = INFO, SimpleScreenlog4perl.additivity.Model.Legacy = 0log4perl.appender.Screen = Log::Log4perl::Appender::Screenlog4perl.appender.Screen.stderr = 0log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayoutlog4perl.appender.Screen.layout.ConversionPattern = %M %m (line %L)%nlog4perl.appender.SimpleScreen = Log::Log4perl::Appender::Screenlog4perl.appender.SimpleScreen.stderr = 0log4perl.appender.SimpleScreen.layout = Log::Log4perl::Layout::PatternLayoutlog4perl.appender.SimpleScreen.layout.ConversionPattern = %p: %m%nlog4perl.oneMessagePerAppender = 1
Log4perl uses the following categories:
- Anything
- Anything::Change
-
Trace change notification through configuration tree and instance.
- Backend
- Backend::Debian::Dpkg
- Backend::Debian::Dpkg::Control
- Backend::Debian::Dpkg::Copyright
- Backend::Fstab
- Backend::IniFile
- Backend::PlainFile
- Backend::ShellVar
- Backend::Yaml
- FuseUI
- Instance
- Loader
- Model::Searcher
- Tree::Element::CheckList
- Tree::Element::Id
- Tree::Element::Id::Hash
- Tree::Element::Id::List
- Tree::Element::Value
- Tree::Element::Value::Dependency
- Tree::Node
- Tree::Node::Warped
- ValueComputer
- Warper
- Iterator
- Model
More categories will come.
Exit code
cme exits 0 when no errors are found. Exit 1 otherwise.
For more information
For more information, please check:
- •
-
config-model wiki: <http://github.com/dod38fr/config-model/wiki>
- •
-
Blogs about this project: <https://ddumont.wordpress.com/category/perl/configmodel/>
Contributors
In alphabetical order:
Ross Vandegrift
Feedbacks
Feedback from users are highly desired. If you find this module useful, please share your use cases, success stories with the author.
Copyright and license
This software is Copyright (c) 2014-2022 by Dominique Dumont <[email protected]>.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999
Releases
7 releases since Debian 7 (Wheezy); the text changed 6 times.
-backup since Debian 8 (Jessie);
-canonical since Debian 10 (Buster);
-create since Debian 8 (Jessie);
-file since Debian 9 (Stretch);
-quiet since Debian 10 (Buster);
-save since Debian 8 (Jessie);
-strict since Debian 8 (Jessie);
-try-app-as-model since Debian 8 (Jessie);
-verbose since Debian 10 (Buster).
-backend until Debian 9 (Stretch);
-dev until Debian 9 (Stretch);
-dfuse until Debian 8 (Jessie);
-dir-char until Debian 8 (Jessie);
-experience until Debian 7 (Wheezy);
-fuse-dir until Debian 8 (Jessie);
-narrow-search until Debian 8 (Jessie);
-search until Debian 8 (Jessie).