|
Alain Reguera Delgado |
cdbf5c |
tcar_checkFiles(1)
|
|
Alain Reguera Delgado |
cdbf5c |
==================
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
== Name
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
tcar_checkFiles - Standardize constructions for file verifications.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
== Synopsis
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
*cli_checkFiles [-d|-e|-f|-h|-x] LOCATION*
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
== Description
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
The *cli_checkFiles* exists to answer basic questions like ``Is
|
|
Alain Reguera Delgado |
cdbf5c |
+LOCATION+ is a regular file?'' and ``Is +LOCATION+ a directory?''.
|
|
Alain Reguera Delgado |
cdbf5c |
The answer to such questions affects the script execution flow in the
|
|
Alain Reguera Delgado |
cdbf5c |
following way: when the answer positive (e.g., +LOCATION+ is a regular
|
|
Alain Reguera Delgado |
cdbf5c |
file), the script passes the test silently and continues its
|
|
Alain Reguera Delgado |
cdbf5c |
execution. When the answer is negative(e.g., +LOCATION+ is not a
|
|
Alain Reguera Delgado |
cdbf5c |
regular file), the script finishes its execution immediately with an
|
|
Alain Reguera Delgado |
cdbf5c |
error message.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
The *cli_checkFiles* function is exported to *centos-art.sh* script
|
|
Alain Reguera Delgado |
cdbf5c |
environment in the very beginning of its execution and will be
|
|
Alain Reguera Delgado |
cdbf5c |
available all along its execution lifetime. You can use this function
|
|
Alain Reguera Delgado |
cdbf5c |
inside common and specific functions whenever you need to verify files
|
|
Alain Reguera Delgado |
cdbf5c |
inside the The CentOS Artwork Repository.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
The *cli_checkFiles* function is available inside the *centos-art.sh*
|
|
Alain Reguera Delgado |
cdbf5c |
script only as part of its execution environment. This function is
|
|
Alain Reguera Delgado |
cdbf5c |
exported to *centos-art.sh* script just after executing the script
|
|
Alain Reguera Delgado |
cdbf5c |
from the command-line and will be available all along the script
|
|
Alain Reguera Delgado |
cdbf5c |
lifetime. So, you can use this function both in common and specific
|
|
Alain Reguera Delgado |
cdbf5c |
functionalities of centos-art.sh script.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
The *cli_checkFiles* function doesn't create
|
|
Alain Reguera Delgado |
cdbf5c |
subsequent execution environments.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
== Usage
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
Use the *cli_checkFiles* function inside *centos-art.sh* script
|
|
Alain Reguera Delgado |
cdbf5c |
whenever you need to control the script execution flow based on file
|
|
Alain Reguera Delgado |
cdbf5c |
type (e.g., regular files, directories, links, etc.) verifications.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
== Options
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
The *cli_checkFiles* function accepts the following options:
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
-d::
|
|
Alain Reguera Delgado |
cdbf5c |
Verifies whether +LOCATION+ exists and is a directory. If it
|
|
Alain Reguera Delgado |
cdbf5c |
doesn't exists or isn't a directory, an error message is printed
|
|
Alain Reguera Delgado |
cdbf5c |
and the script finishes its execution. Otherwise, if it exists
|
|
Alain Reguera Delgado |
cdbf5c |
and is a directory, the script continues its execution normally.
|
|
Alain Reguera Delgado |
cdbf5c |
-e::
|
|
Alain Reguera Delgado |
cdbf5c |
Verifies whether +LOCATION+ exists or not. If it doesn't exist, an
|
|
Alain Reguera Delgado |
cdbf5c |
error message is printed and the script finishes its execution.
|
|
Alain Reguera Delgado |
cdbf5c |
Otherwise, if it does exists, the script continues its execution
|
|
Alain Reguera Delgado |
cdbf5c |
normally.
|
|
Alain Reguera Delgado |
cdbf5c |
-f::
|
|
Alain Reguera Delgado |
cdbf5c |
Verifies whether +LOCATION+ exists and is a regular file. If it
|
|
Alain Reguera Delgado |
cdbf5c |
doesn't exists or isn't a regular file, an error message is
|
|
Alain Reguera Delgado |
cdbf5c |
printed and the script finishes its execution. Otherwise, if it
|
|
Alain Reguera Delgado |
cdbf5c |
exists and is a regular file, the script continues its execution
|
|
Alain Reguera Delgado |
cdbf5c |
normally.
|
|
Alain Reguera Delgado |
cdbf5c |
-h::
|
|
Alain Reguera Delgado |
cdbf5c |
Verifies whether +LOCATION+ exists and is a symbolic link. If it
|
|
Alain Reguera Delgado |
cdbf5c |
doesn't exists or isn't a symbolic link, an error message is
|
|
Alain Reguera Delgado |
cdbf5c |
printed and the script finishes its execution immediately.
|
|
Alain Reguera Delgado |
cdbf5c |
Otherwise, if it does exist and is a symbolic link, the script
|
|
Alain Reguera Delgado |
cdbf5c |
continue its execution normally.
|
|
Alain Reguera Delgado |
cdbf5c |
-x::
|
|
Alain Reguera Delgado |
cdbf5c |
Verifies whether +LOCATION+ exists and execution permission is
|
|
Alain Reguera Delgado |
cdbf5c |
granted. If it doesn't exist or hasn't execution permission, the
|
|
Alain Reguera Delgado |
cdbf5c |
script finishes its execution immediately. Otherwise, if it exists
|
|
Alain Reguera Delgado |
cdbf5c |
and has execution permissions, the script continues its execution
|
|
Alain Reguera Delgado |
cdbf5c |
normally.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
The value of the +LOCATION+ argument must be an absolute path to the
|
|
Alain Reguera Delgado |
cdbf5c |
file you want to verify. If such file doesn't exists in any supported
|
|
Alain Reguera Delgado |
cdbf5c |
form, the script finishes its execution with an error message.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
== Examples
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
The following example was taken from *centos-art.sh* script
|
|
Alain Reguera Delgado |
cdbf5c |
initialization phase. Notice the position of *cli_checkFiles*
|
|
Alain Reguera Delgado |
cdbf5c |
function inside the loop. If some of the function files we need to
|
|
Alain Reguera Delgado |
cdbf5c |
export doesn't have execution rights, *cli_checkFiles* will finish the
|
|
Alain Reguera Delgado |
cdbf5c |
script execution immediately with an error message.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
cdbf5c |
for FUNCFILE in ${FUNCFILES};do
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
# Verify the execution rights for function file.
|
|
Alain Reguera Delgado |
cdbf5c |
cli_checkFiles -x ${FUNCFILE}
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
# Initialize the function file.
|
|
Alain Reguera Delgado |
cdbf5c |
. ${FUNCFILE}
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
# Export the function names inside the file to current shell
|
|
Alain Reguera Delgado |
cdbf5c |
# script environment.
|
|
Alain Reguera Delgado |
cdbf5c |
export -f $(egrep "${PATTERN}" ${FUNCFILE} | gawk '{ print $2 }')
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
done
|
|
Alain Reguera Delgado |
cdbf5c |
----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
== Bugs
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
See https://centos.org.cu/bugs/
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
== Authors
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
The *tcar_checkFiles* function has received contributions from the
|
|
Alain Reguera Delgado |
cdbf5c |
following people:
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
- Alain Reguera Delgado <al@centos.org.cu>, =COPYRIGHT_YEAR_LIST=
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
== License
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
Copyright (C) =COPYRIGHT_YEAR_LIST= =COPYRIGHT_HOLDER=
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
cdbf5c |
it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
cdbf5c |
the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
cdbf5c |
your option) any later version.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
cdbf5c |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
cdbf5c |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
cdbf5c |
General Public License for more details.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
cdbf5c |
along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
cdbf5c |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
cdbf5c |
|
|
Alain Reguera Delgado |
cdbf5c |
// vim: set syntax=asciidoc:
|