User story #3398 » 0001-Copied-fileManagement-1.1-to-2.0-for-adding-new-feature.patch
techniques/fileConfiguration/fileManagement/2.0/metadata.xml | ||
---|---|---|
<!--
|
||
Copyright 2011 Normation SAS
|
||
This program is free software: you can redistribute it and/or modify
|
||
it under the terms of the GNU General Public License as published by
|
||
the Free Software Foundation, Version 3.
|
||
This program is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
GNU General Public License for more details.
|
||
You should have received a copy of the GNU General Public License
|
||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
-->
|
||
<TECHNIQUE name="Manage files and folders">
|
||
<DESCRIPTION>Make sure that files and folders exist, and set their permissions</DESCRIPTION>
|
||
<MULTIINSTANCE>true</MULTIINSTANCE>
|
||
<COMPATIBLE>
|
||
<OS version=">= 4 (Etch)">Debian</OS>
|
||
<OS version=">= 4 (Nahant)">RHEL / CentOS</OS>
|
||
<OS version=">= 10 SP1 (Agama Lizard)">SuSE LES / DES / OpenSuSE</OS>
|
||
<OS version=">= XP/5.1 (Whistler)">Windows</OS>
|
||
<AGENT version=">= 3.1.5">cfengine-community</AGENT>
|
||
</COMPATIBLE>
|
||
<BUNDLES>
|
||
<NAME>manageFilesAndFolders</NAME>
|
||
</BUNDLES>
|
||
<TMLS>
|
||
<TML name="manageFilesAndFolders"/>
|
||
</TMLS>
|
||
|
||
<TRACKINGVARIABLE>
|
||
<SAMESIZEAS>FILE_AND_FOLDER_MANAGEMENT_PATH</SAMESIZEAS>
|
||
</TRACKINGVARIABLE>
|
||
|
||
<SECTIONS>
|
||
<SECTION name="File to manage" multivalued="true">
|
||
<SECTION name="File" multivalued="false" component="true" componentKey="FILE_AND_FOLDER_MANAGEMENT_PATH">
|
||
<INPUT>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_PATH</NAME>
|
||
<DESCRIPTION>Path</DESCRIPTION>
|
||
</INPUT>
|
||
</SECTION>
|
||
<SELECT1>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_ACTION</NAME>
|
||
<DESCRIPTION>Set action on file or folder</DESCRIPTION>
|
||
<ITEM>
|
||
<VALUE>none</VALUE>
|
||
<LABEL>Do nothing</LABEL>
|
||
</ITEM>
|
||
<ITEM>
|
||
<VALUE>file</VALUE>
|
||
<LABEL>Create an empty file</LABEL>
|
||
</ITEM>
|
||
<ITEM>
|
||
<VALUE>dir</VALUE>
|
||
<LABEL>Create an empty directory</LABEL>
|
||
</ITEM>
|
||
<ITEM>
|
||
<VALUE>symlink</VALUE>
|
||
<LABEL>Create a symbolic link</LABEL>
|
||
</ITEM>
|
||
<ITEM>
|
||
<VALUE>clean</VALUE>
|
||
<LABEL>Clean (see below)</LABEL>
|
||
</ITEM>
|
||
<CONSTRAINT>
|
||
<DEFAULT>none</DEFAULT>
|
||
</CONSTRAINT>
|
||
</SELECT1>
|
||
<INPUT>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_SYMLINK_SOURCE</NAME>
|
||
<DESCRIPTION>Symbolic link source</DESCRIPTION>
|
||
<LONGDESCRIPTION>If a symbolic link is to be created, please specify its source here</LONGDESCRIPTION>
|
||
<CONSTRAINT>
|
||
<MAYBEEMPTY>true</MAYBEEMPTY>
|
||
</CONSTRAINT>
|
||
</INPUT>
|
||
<SELECT1>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_SYMLINK_ENFORCE</NAME>
|
||
<DESCRIPTION>Force symlink to be created</DESCRIPTION>
|
||
<LONGDESCRIPTION>By default, the symlink won't be created if it replaces a file or folder with the same name. With this option, you can force Rudder to create the symlink to replace existing files or folders</LONGDESCRIPTION>
|
||
<ITEM>
|
||
<VALUE>false</VALUE>
|
||
<LABEL>No, don't create the symlink if a file or folder with the same name already exists</LABEL>
|
||
</ITEM>
|
||
<ITEM>
|
||
<VALUE>true</VALUE>
|
||
<LABEL>Yes, force the creation of the symlink. </LABEL>
|
||
</ITEM>
|
||
<CONSTRAINT>
|
||
<DEFAULT>false</DEFAULT>
|
||
</CONSTRAINT>
|
||
</SELECT1>
|
||
<SECTION name="Permissions" multivalued="false" component="true" componentKey="FILE_AND_FOLDER_MANAGEMENT_PATH">
|
||
<SELECT1>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_CHECK_PERMISSIONS</NAME>
|
||
<DESCRIPTION>Set permissions</DESCRIPTION>
|
||
<ITEM>
|
||
<VALUE>false</VALUE>
|
||
<LABEL>No, don't change any permissions</LABEL>
|
||
</ITEM>
|
||
<ITEM>
|
||
<VALUE>true</VALUE>
|
||
<LABEL>Yes, enforce permissions described below</LABEL>
|
||
</ITEM>
|
||
<CONSTRAINT>
|
||
<DEFAULT>false</DEFAULT>
|
||
</CONSTRAINT>
|
||
</SELECT1>
|
||
<INPUT>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_PERM</NAME>
|
||
<DESCRIPTION>File mode</DESCRIPTION>
|
||
<CONSTRAINT>
|
||
<TYPE>perm</TYPE>
|
||
</CONSTRAINT>
|
||
</INPUT>
|
||
<INPUT>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_OWNER</NAME>
|
||
<DESCRIPTION>File Owner</DESCRIPTION>
|
||
<CONSTRAINT>
|
||
<MAYBEEMPTY>true</MAYBEEMPTY>
|
||
</CONSTRAINT>
|
||
</INPUT>
|
||
<INPUT>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_GROUP</NAME>
|
||
<DESCRIPTION>File Group</DESCRIPTION>
|
||
<CONSTRAINT>
|
||
<MAYBEEMPTY>true</MAYBEEMPTY>
|
||
</CONSTRAINT>
|
||
</INPUT>
|
||
<SELECT1>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_RECURSIVE</NAME>
|
||
<DESCRIPTION>Set these permissions</DESCRIPTION>
|
||
<ITEM>
|
||
<VALUE>1</VALUE>
|
||
<LABEL>On this path only</LABEL>
|
||
</ITEM>
|
||
<ITEM>
|
||
<VALUE>inf</VALUE>
|
||
<LABEL>Recursively from this path</LABEL>
|
||
</ITEM>
|
||
<CONSTRAINT>
|
||
<DEFAULT>1</DEFAULT>
|
||
</CONSTRAINT>
|
||
</SELECT1>
|
||
</SECTION>
|
||
<SECTION name="Post-modification hook" multivalued="false" component="true" componentKey="FILE_AND_FOLDER_MANAGEMENT_PATH">
|
||
<INPUT>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_POST_HOOK_RUN</NAME>
|
||
<DESCRIPTION>Should the command(s) below be run if any modifications are made on the path above?</DESCRIPTION>
|
||
<CONSTRAINT><TYPE>boolean</TYPE></CONSTRAINT>
|
||
</INPUT>
|
||
<INPUT>
|
||
<NAME>FILE_AND_FOLDER_MANAGEMENT_POST_HOOK_COMMAND</NAME>
|
||
<DESCRIPTION>Command(s) to run</DESCRIPTION>
|
||
<LONGDESCRIPTION>List of shell-compatible statements to be executed. Multiple commands may be specified on separate lines.</LONGDESCRIPTION>
|
||
<CONSTRAINT>
|
||
<TYPE>textarea</TYPE>
|
||
<MAYBEEMPTY>true</MAYBEEMPTY>
|
||
</CONSTRAINT>
|
||
</INPUT>
|
||
</SECTION>
|
||
<SECTION name="File cleaning options" multivalued="false" component="true" componentKey="FILE_AND_FOLDER_MANAGEMENT_PATH">
|
||
<SELECT1>
|
||
<DESCRIPTION>Deletion operation</DESCRIPTION>
|
||
<NAME>FILE_AND_FOLDER_DELETION_OPTION</NAME>
|
||
<ITEM>
|
||
<VALUE>none</VALUE>
|
||
<LABEL>This file or directory only</LABEL>
|
||
</ITEM>
|
||
<ITEM>
|
||
<VALUE>single</VALUE>
|
||
<LABEL>This file or directory content only</LABEL>
|
||
</ITEM>
|
||
<ITEM>
|
||
<VALUE>full</VALUE>
|
||
<LABEL>Everything in this directory (full recursion)</LABEL>
|
||
</ITEM>
|
||
<ITEM>
|
||
<VALUE>exterminate</VALUE>
|
||
<LABEL>Everything in this directory and the directory itself</LABEL>
|
||
</ITEM>
|
||
<CONSTRAINT>
|
||
<DEFAULT>none</DEFAULT>
|
||
</CONSTRAINT>
|
||
</SELECT1>
|
||
<INPUT>
|
||
<DESCRIPTION>File selection pattern</DESCRIPTION>
|
||
<LONGDESCRIPTION>A regular expression to use as a pattern</LONGDESCRIPTION>
|
||
<NAME>FILE_AND_FOLDER_DELETION_PATTERN</NAME>
|
||
<CONSTRAINT>
|
||
<DEFAULT>.*</DEFAULT>
|
||
</CONSTRAINT>
|
||
</INPUT>
|
||
<INPUT>
|
||
<DESCRIPTION>Suppress if older than (days)</DESCRIPTION>
|
||
<LONGDESCRIPTION>A time to live for the object(s). 0 means everything without any time constraint</LONGDESCRIPTION>
|
||
<NAME>FILE_AND_FOLDER_DELETION_DAYS</NAME>
|
||
<CONSTRAINT>
|
||
<DEFAULT>0</DEFAULT>
|
||
</CONSTRAINT>
|
||
</INPUT>
|
||
</SECTION>
|
||
</SECTION>
|
||
</SECTIONS>
|
||
</TECHNIQUE>
|
techniques/fileConfiguration/fileManagement/2.0/manageFilesAndFolders.st | ||
---|---|---|
#####################################################################################
|
||
# Copyright 2011 Normation SAS
|
||
#####################################################################################
|
||
#
|
||
# This program is free software: you can redistribute it and/or modify
|
||
# it under the terms of the GNU General Public License as published by
|
||
# the Free Software Foundation, Version 3.
|
||
#
|
||
# This program is distributed in the hope that it will be useful,
|
||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
# GNU General Public License for more details.
|
||
#
|
||
# You should have received a copy of the GNU General Public License
|
||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
#
|
||
#####################################################################################
|
||
#################################################################
|
||
# Manage files and folders, enforcing their existence #
|
||
#################################################################
|
||
bundle agent manageFilesAndFolders {
|
||
vars:
|
||
&FILE_AND_FOLDER_MANAGEMENT_PATH:{path |"file[&i&][path]" string => "&path&";
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_PERM:{perm |"file[&i&][mode]" string => "&perm&";
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_OWNER:{owner |"file[&i&][owner]" string => "&owner&";
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_GROUP:{group |"file[&i&][group]" string => "&group&";
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_POST_HOOK_COMMAND:{cmd |"file[&i&][post_hook_command]" string => "&cmd&";
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_SYMLINK_SOURCE:{symsrc |"file[&i&][symlink_source]" string => "&symsrc&";
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_SYMLINK_ENFORCE:{symlink_enforced | "file[&i&][symlink_enforced]" string => "&symlink_enforced&";
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_RECURSIVE:{recursive |"file[&i&][recursive]" string => "&recursive&";
|
||
}&
|
||
&FILE_AND_FOLDER_DELETION_DAYS:{ttl |"file[&i&][ttl]" string => "&ttl&";
|
||
}&
|
||
&FILE_AND_FOLDER_DELETION_PATTERN:{pattern |"file[&i&][pattern]" string => "&pattern&";
|
||
}&
|
||
&TRACKINGKEY:{directiveId |"file[&i&][uuid]" string => "&directiveId&";
|
||
}&
|
||
"index" slist => getindices("file");
|
||
classes:
|
||
# Set a class to define when we need to run the post-modification hook
|
||
&FILE_AND_FOLDER_MANAGEMENT_POST_HOOK_RUN:{run |"manageFilesAndFolders_post_hook_run_&i&" expression => strcmp("&run&", "true");
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_CHECK_PERMISSIONS:{perms |"manageFilesAndFolders_check_permissions_&i&" expression => strcmp("&perms&", "true");
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_ACTION:{nocreate | "manageFilesAndFolders_nocreate_&i&" expression => strcmp("&nocreate&", "none");
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_ACTION:{createfile | "manageFilesAndFolders_createfile_&i&" expression => strcmp("&createfile&", "file");
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_ACTION:{createdir | "manageFilesAndFolders_createdir_&i&" expression => strcmp("&createdir&", "dir");
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_ACTION:{createsymlink | "manageFilesAndFolders_createsymlink_&i&" expression => strcmp("&createsymlink&", "symlink");
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_ACTION:{clean | "manageFilesAndFolders_clean_&i&" expression => strcmp("&clean&", "clean");
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_RECURSIVE:{isrecursive | "manageFilesAndFolders_isrecursive_&i&" expression => strcmp("&isrecursive&", "inf");
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_OWNER:{userset | "manageFilesAndFolders_userset_&i&" expression => strcmp("&userset&", "$(file[&i&][owner])");
|
||
}&
|
||
&FILE_AND_FOLDER_MANAGEMENT_GROUP:{groupset | "manageFilesAndFolders_groupset_&i&" expression => strcmp("&groupset&", "$(file[&i&][group])");
|
||
}&
|
||
&FILE_AND_FOLDER_DELETION_OPTION:{delopt | "manageFilesAndFolders_deletion_simple_&i&" expression => strcmp("&delopt&", "none");
|
||
}&
|
||
&FILE_AND_FOLDER_DELETION_OPTION:{delopt | "manageFilesAndFolders_deletion_single_recursive_&i&" expression => strcmp("&delopt&", "single");
|
||
}&
|
||
&FILE_AND_FOLDER_DELETION_OPTION:{delopt | "manageFilesAndFolders_deletion_full_recursive_&i&" expression => strcmp("&delopt&", "full");
|
||
}&
|
||
&FILE_AND_FOLDER_DELETION_OPTION:{delopt | "manageFilesAndFolders_deletion_exterminate_&i&" expression => strcmp("&delopt&", "exterminate");
|
||
}&
|
||
"manageFilesAndFolders_isdir_$(index)" expression => isdir("$(file[$(index)][path])");
|
||
"manageFilesAndFolders_isfile_$(index)" expression => isplain("$(file[$(index)][path])");
|
||
"manageFilesAndFolders_islink_$(index)" expression => islink("$(file[$(index)][path])");
|
||
|
||
files:
|
||
# Directory
|
||
"$(file[$(index)][path])/."
|
||
create => "true",
|
||
classes => kept_if_else("manageFolders_$(index)_kept", "manageFolders_$(index)_modified", "manageFolders_$(index)_failed"),
|
||
comment => "Enforcing the existance of folder $(file[$(index)][path])",
|
||
ifvarclass => "(!manageFilesAndFolders_nocreate_$(index).!manageFilesAndFolders_createfile_$(index).manageFilesAndFolders_createdir_$(index)).!manageFilesAndFolders_createsymlink_$(index)";
|
||
# File
|
||
"$(file[$(index)][path])"
|
||
create => "true",
|
||
classes => kept_if_else("manageFiles_$(index)_kept", "manageFiles_$(index)_modified", "manageFiles_$(index)_failed"),
|
||
comment => "Enforcing the existance of file $(file[$(index)][path])",
|
||
ifvarclass => "(!manageFilesAndFolders_nocreate_$(index).!manageFilesAndFolders_createdir_$(index).manageFilesAndFolders_createfile_$(index)).!manageFilesAndFolders_createsymlink_$(index)";
|
||
# Symlink
|
||
"$(file[$(index)][path])"
|
||
# create => "true",
|
||
link_from => ln_s("$(file[$(index)][symlink_source])"),
|
||
move_obstructions => "${file[${index}][symlink_enforced]}",
|
||
classes => kept_if_else("manageSyms_$(index)_kept", "manageSyms_$(index)_modified", "manageSyms_$(index)_failed"),
|
||
ifvarclass => "(!manageFilesAndFolders_nocreate_$(index).!manageFilesAndFolders_createdir_$(index).!manageFilesAndFolders_createfile_$(index)).manageFilesAndFolders_createsymlink_$(index)",
|
||
comment => "Create the $(file[$(index)][path]) symlink pointing to $(file[$(index)][symlink_source])";
|
||
# Check the permissions none recursively
|
||
## With user and group
|
||
"$(file[$(index)][path])"
|
||
perms => mog("$(file[$(index)][mode])", "$(file[$(index)][owner])", "$(file[$(index)][group])"),
|
||
classes => kept_if_else("manageFilesAndFolders_perms_$(index)_kept", "manageFilesAndFolders_perms_$(index)_modified", "manageFilesAndFolders_perms_$(index)_failed"),
|
||
ifvarclass => "manageFilesAndFolders_check_permissions_$(index).!manageFilesAndFolders_isrecursive_$(index).manageFilesAndFolders_userset_$(index).manageFilesAndFolders_groupset_$(index)";
|
||
## With user
|
||
"$(file[$(index)][path])"
|
||
perms => mo("$(file[$(index)][mode])", "$(file[$(index)][owner])"),
|
||
classes => kept_if_else("manageFilesAndFolders_perms_$(index)_kept", "manageFilesAndFolders_perms_$(index)_modified", "manageFilesAndFolders_perms_$(index)_failed"),
|
||
ifvarclass => "manageFilesAndFolders_check_permissions_$(index).!manageFilesAndFolders_isrecursive_$(index).manageFilesAndFolders_userset_$(index).!manageFilesAndFolders_groupset_$(index)";
|
||
## With group
|
||
"$(file[$(index)][path])"
|
||
perms => mg("$(file[$(index)][mode])", "$(file[$(index)][group])"),
|
||
classes => kept_if_else("manageFilesAndFolders_perms_$(index)_kept", "manageFilesAndFolders_perms_$(index)_modified", "manageFilesAndFolders_perms_$(index)_failed"),
|
||
ifvarclass => "manageFilesAndFolders_check_permissions_$(index).!manageFilesAndFolders_isrecursive_$(index).manageFilesAndFolders_groupset_$(index).!manageFilesAndFolders_userset_$(index)";
|
||
# Check the permissions recursively
|
||
## With user and group
|
||
"$(file[$(index)][path])"
|
||
depth_search => recurse_withroot("$(file[$(index)][recursive])"),
|
||
perms => mog("$(file[$(index)][mode])", "$(file[$(index)][owner])", "$(file[$(index)][group])"),
|
||
classes => kept_if_else("manageFilesAndFolders_perms_$(index)_kept", "manageFilesAndFolders_perms_$(index)_modified", "manageFilesAndFolders_perms_$(index)_failed"),
|
||
ifvarclass => "manageFilesAndFolders_check_permissions_$(index).manageFilesAndFolders_isrecursive_$(index).manageFilesAndFolders_userset_$(index).manageFilesAndFolders_groupset_$(index)";
|
||
## With user
|
||
"$(file[$(index)][path])"
|
||
depth_search => recurse_withroot("$(file[$(index)][recursive])"),
|
||
perms => mo("$(file[$(index)][mode])", "$(file[$(index)][owner])"),
|
||
classes => kept_if_else("manageFilesAndFolders_perms_$(index)_kept", "manageFilesAndFolders_perms_$(index)_modified", "manageFilesAndFolders_perms_$(index)_failed"),
|
||
ifvarclass => "manageFilesAndFolders_check_permissions_$(index).manageFilesAndFolders_isrecursive_$(index).manageFilesAndFolders_userset_$(index).!manageFilesAndFolders_groupset_$(index)";
|
||
## With group
|
||
"$(file[$(index)][path])"
|
||
depth_search => recurse_withroot("$(file[$(index)][recursive])"),
|
||
perms => mg("$(file[$(index)][mode])", "$(file[$(index)][group])"),
|
||
classes => kept_if_else("manageFilesAndFolders_perms_$(index)_kept", "manageFilesAndFolders_perms_$(index)_modified", "manageFilesAndFolders_perms_$(index)_failed"),
|
||
ifvarclass => "manageFilesAndFolders_check_permissions_$(index).manageFilesAndFolders_isrecursive_$(index).manageFilesAndFolders_groupset_$(index).!manageFilesAndFolders_userset_$(index)";
|
||
# This will not delete the parent
|
||
"$(file[$(index)][path])"
|
||
delete => tidy,
|
||
file_select => date_pattern("$(file[$(index)][ttl])", "$(file[$(index)][pattern])"),
|
||
ifvarclass => "manageFilesAndFolders_clean_$(index).manageFilesAndFolders_deletion_single_recursive_$(index)",
|
||
depth_search => recurse("0"),
|
||
classes => kept_if_else("manageFilesAndFolders_delete_$(index)_kept", "manageFilesAndFolders_delete_$(index)_modified", "manageFilesAndFolders_delete_$(index)_failed");
|
||
# This will not delete the parent
|
||
"$(file[$(index)][path])"
|
||
delete => tidy,
|
||
file_select => date_pattern("$(file[$(index)][ttl])", "$(file[$(index)][pattern])"),
|
||
depth_search => recurse("inf"),
|
||
ifvarclass => "manageFilesAndFolders_clean_$(index).(manageFilesAndFolders_deletion_full_recursive_$(index)|manageFilesAndFolders_deletion_exterminate_$(index))",
|
||
classes => kept_if_else("manageFilesAndFolders_delete_$(index)_kept", "manageFilesAndFolders_delete_$(index)_modified", "manageFilesAndFolders_delete_$(index)_failed");
|
||
# This WILL delete the parent
|
||
"$(file[$(index)][path])"
|
||
delete => tidy,
|
||
file_select => date_pattern("$(file[$(index)][ttl])", "$(file[$(index)][pattern])"),
|
||
ifvarclass => "manageFilesAndFolders_clean_$(index).(manageFilesAndFolders_deletion_simple_$(index)|manageFilesAndFolders_deletion_exterminate_$(index))",
|
||
classes => kept_if_else("manageFilesAndFolders_delete_$(index)_kept", "manageFilesAndFolders_delete_$(index)_modified", "manageFilesAndFolders_delete_$(index)_failed");
|
||
commands:
|
||
"$(file[$(index)][post_hook_command])"
|
||
classes => if_else("manageFilesAndFolders_$(index)_command_run_ok", "manageFilesAndFolders_$(index)_command_run_failed"),
|
||
contain => in_shell,
|
||
ifvarclass => "manageFilesAndFolders_post_hook_run_$(index).(manageFiles_$(index)_modified|manageFolders_$(index)_modified|manageSyms_$(index)_modified|manageFilesAndFolders_perms_$(index)_modified)";
|
||
reports:
|
||
(linux|windows)::
|
||
# Reporting for creation
|
||
## Reporting for directory creation
|
||
"@@manageFilesAndFolders@@result_success@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The folder $(file[$(index)][path]) already exists"
|
||
ifvarclass => "manageFolders_$(index)_kept.!manageFolders_$(index)_modified.manageFilesAndFolders_isdir_$(index).!manageFilesAndFolders_isfile_$(index).!manageFilesAndFolders_islink_$(index)";
|
||
"@@manageFilesAndFolders@@result_repaired@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The folder $(file[$(index)][path]) was successfully created"
|
||
ifvarclass => "manageFolders_$(index)_modified";
|
||
"@@manageFilesAndFolders@@result_error@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The folder $(file[$(index)][path]) could not be created"
|
||
ifvarclass => "manageFolders_$(index)_failed|manageFolders_$(index)_kept.(manageFilesAndFolders_isfile_$(index)|manageFilesAndFolders_islink_$(index))";
|
||
## Reporting for file creation
|
||
"@@manageFilesAndFolders@@result_success@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The file $(file[$(index)][path]) already exists"
|
||
ifvarclass => "manageFiles_$(index)_kept.!manageFiles_$(index)_modified.manageFilesAndFolders_isfile_$(index).!manageFilesAndFolders_isdir_$(index).!manageFilesAndFolders_islink_$(index)";
|
||
"@@manageFilesAndFolders@@result_repaired@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The file $(file[$(index)][path]) was successfully created"
|
||
ifvarclass => "manageFiles_$(index)_modified";
|
||
"@@manageFilesAndFolders@@result_error@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The file $(file[$(index)][path]) could not be created"
|
||
ifvarclass => "manageFiles_$(index)_failed|manageFiles_$(index)_kept.(manageFilesAndFolders_isdir_$(index)|manageFilesAndFolders_islink_$(index))";
|
||
## Reporting for symlink creation
|
||
"@@manageFilesAndFolders@@result_success@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The symlink $(file[$(index)][path]) already exists"
|
||
ifvarclass => "manageSyms_$(index)_kept.!manageSyms_$(index)_modified";
|
||
"@@manageFilesAndFolders@@result_repaired@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The symlink $(file[$(index)][path]) was successfully created"
|
||
ifvarclass => "manageSyms_$(index)_modified";
|
||
"@@manageFilesAndFolders@@result_error@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The symlink $(file[$(index)][path]) could not be created"
|
||
ifvarclass => "manageSyms_$(index)_failed";
|
||
## Reporting for no change
|
||
"@@manageFilesAndFolders@@result_success@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#No file creation action specified for $(file[$(index)][path])"
|
||
ifvarclass => "manageFilesAndFolders_nocreate_$(index)";
|
||
|
||
# Reporting for the permissions
|
||
## Success if not set
|
||
"@@manageFilesAndFolders@@result_success@@$(file[$(index)][uuid])@@Permissions@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The item $(file[$(index)][path]) was not requested to have its permission enforced"
|
||
ifvarclass => "!manageFilesAndFolders_check_permissions_$(index)";
|
||
"@@manageFilesAndFolders@@result_success@@$(file[$(index)][uuid])@@Permissions@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The permission of the item $(file[$(index)][path]) were correct"
|
||
ifvarclass => "manageFilesAndFolders_perms_$(index)_kept.!manageFilesAndFolders_perms_$(index)_modified";
|
||
"@@manageFilesAndFolders@@result_repaired@@$(file[$(index)][uuid])@@Permissions@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The permissions of the item $(file[$(index)][path]) have been corrected"
|
||
ifvarclass => "manageFilesAndFolders_perms_$(index)_modified.!manageFilesAndFolders_perms_$(index)_failed";
|
||
"@@manageFilesAndFolders@@result_error@@$(file[$(index)][uuid])@@Permissions@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The permissions of the item $(file[$(index)][path]) could not be set"
|
||
ifvarclass => "manageFilesAndFolders_perms_$(index)_failed";
|
||
"@@manageFilesAndFolders@@log_info@@$(file[$(index)][uuid])@@Permissions@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The item $(file[$(index)][path]) will be handled recursively"
|
||
ifvarclass => "manageFilesAndFolders_check_permissions_$(index).manageFilesAndFolders_createdir_$(index).manageFilesAndFolders_recursive_$(index)";
|
||
"@@manageFilesAndFolders@@log_warn@@$(file[$(index)][uuid])@@Permissions@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The item $(file[$(index)][path]) will NOT be handled recursively, because it is either a file or a symlink"
|
||
ifvarclass => "manageFilesAndFolders_check_permissions_$(index).!manageFilesAndFolders_createdir_$(index).manageFilesAndFolders_recursive_$(index)";
|
||
# Reporting for the deletion
|
||
## Report in the general component of the file
|
||
"@@manageFilesAndFolders@@result_success@@$(file[$(index)][uuid])@@File@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#File cleaning was requested for $(file[$(index)][path]). Check specific reporting in the 'File cleaning options' component."
|
||
ifvarclass => "manageFilesAndFolders_clean_$(index)";
|
||
## Success if not set
|
||
"@@manageFilesAndFolders@@result_success@@$(file[$(index)][uuid])@@File cleaning options@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The item $(file[$(index)][path]) was not requested to be deleted"
|
||
ifvarclass => "!manageFilesAndFolders_clean_$(index)";
|
||
"@@manageFilesAndFolders@@result_success@@$(file[$(index)][uuid])@@File cleaning options@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The item $(file[$(index)][path]) was in conformity with the deletion policy"
|
||
ifvarclass => "manageFilesAndFolders_clean_$(index).!manageFilesAndFolders_delete_$(index)_modified.!manageFilesAndFolders_delete_$(index)_failed";
|
||
"@@manageFilesAndFolders@@result_repaired@@$(file[$(index)][uuid])@@File cleaning options@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The item $(file[$(index)][path]) has been put in conformity with the deletion policy"
|
||
ifvarclass => "manageFilesAndFolders_delete_$(index)_modified";
|
||
"@@manageFilesAndFolders@@result_error@@$(file[$(index)][uuid])@@File cleaning options@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#The item $(file[$(index)][path]) deletion policy could not be enforced"
|
||
ifvarclass => "manageFilesAndFolders_delete_$(index)_failed";
|
||
# Reporting for post-command execution
|
||
"@@manageFilesAndFolders@@result_success@@$(file[$(index)][uuid])@@Post-modification hook@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#Post-execution hook did not need running"
|
||
ifvarclass => "!manageFilesAndFolders_post_hook_run_$(index)|((manageFiles_$(index)_kept|manageFolders_$(index)_kept|manageSyms_$(index)_kept|manageFilesAndFolders_perms_$(index)_kept).!(manageFiles_$(index)_modified|manageFolders_$(index)_modified|manageSyms_$(index)_modified|manageFilesAndFolders_perms_$(index)_modified))";
|
||
"@@manageFilesAndFolders@@result_repaired@@$(file[$(index)][uuid])@@Post-modification hook@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#Post-execution hook successfully run"
|
||
ifvarclass => "manageFilesAndFolders_$(index)_command_run_ok";
|
||
"@@manageFilesAndFolders@@result_error@@$(file[$(index)][uuid])@@Post-modification hook@@$(file[$(index)][path])@@$(g.execRun)##$(g.uuid)@#An error occured when running the post-execution hook"
|
||
ifvarclass => "manageFilesAndFolders_$(index)_command_run_failed";
|
||
}
|
||
-
|