[ xtrnaw7@t15g /data/develop/scripts ] $ ./execute_tasks.sh --help -v
[12.01.2024 12:27 ] ### execute_tasks.sh started at 12.01.2024 12:27:17 (The PID of this process is 1224325)
[12.01.2024 12:27 ] ### Processing the parameter ...
[12.01.2024 12:27 ] Tasks to execute are: ""
[12.01.2024 12:27 ] Parameter for the function init_tasks are: ""
egrep: warning: egrep is obsolescent; using grep -E
 execute_tasks.sh

 Function: execute one or more tasks defined in include files
           This is only a wrapper script with a framework to execute tasks
           You need at least one include file with task definitions for this script to do something useful
 
 Usage:    execute_tasks.sh [-v|--verbose] [-q|--quiet] [-f|--force] [-o|--overwrite] [-y|--yes] [-n|--no] [-l|--logfile filename]
               [-d{:dryrun_prefix}|--dryrun{:dryrun_prefix}] [-D|--debugshell] [-t fn|--tracefunc fn] [-L]
               [-T|--tee] [-V|--version] [--var name=value] [--appendlog] [--nologrotate] [--noSTDOUTlog] [--disable_tty_check] [--nobackups]
               [--print_task_template [filename]] [--create_include_file_template [filename]] [--list [taskmask]] [--list_tasks [taskmask]]
               [--list_task_groups [groupmask]] [--list_default_tasks] [--abort_on_error] [--abort_on_task_not_found] [--abort_on_duplicates]
               [--checkonly] [--check] [--singlestep] [--unique] [--trace] [--info] [--print_includefile_help] [-i|--includefile [?|+]filename]
               [--no_init_tasks[ [--no_finish_tasks] [--only_list_tasks] [--disabled_tasks task1[...,task#]] [--list_disabled_tasks] [--enable_all_tasks]
               [task1] [... task#] [-- parameter_for_init_tasks]

 Parameter:
   task#
      - "task#" can be a task to execute, a task group with multiple tasks to execute, the default task group "all" or "ALL",
        a pattern for tasks to execute, or an input file with a list of tasks to execute

        Tasks
        -----

        Each task is simply a function in one of the include files. There must be a function for every task to execute
        in one of the include files. The function name must start with "task_" but NOT with "task_dummy" or "task_template".
        To execute the function "task_mytask01" you can use the script parameter "task_mytask01" or "mytask01".
        If the function for a task is defined in more then one include file only the function defined
        in the last include file read will be used (use the parameter "--abort_on_duplicates" to abort the script if
        duplicate task definitions are found).

        Parameter for a task are supported; the format for tasks with parameter is: 'task#:parameter1[:...[:parameter#]]'
        Whitespaces (blanks or tabs) in the parameter for a task are not supported.

        The task names can be used with or without the leading "task_" if nothing else is stated below.
        In case a task and a task group use the same name the script will use the task group. To use the task
        instead use the task name with the leading "task_".

        Use the parameter "--print_task_template" to generate a template for a new task; use the parameter "--create_include_file_template"
        to generate a new (empty) include file.


        Patterns
        --------

        You can also use pattern with "*" and "?" -- e.g use the parameter "check*" to execute all tasks beginning with "check".


        Task groups
        -----------

        Task groups are variables with a list of tasks to execute. These variables must be defined in the include files.
        To define a task group use the statement

          TASK_GROUP_<groupname>="task1 [... [task#]]"

        in one of the include files.
        The prefix "TASK_GROUP_" is mandatory for task groups; "<groupname>" can be any string that is allowed
        for variable names in the shell executing the script. To execute the tasks in a task group use the script
        parameter "<groupname>". E.g. to execute all tasks in the task group "TASK_GROUP_include1" use the
        script parameter "include1".
       
        Parameter for a task group are not possible but the tasks in a task group can be defined with parameter.
        To use parameter define the task like this

          task#:parameter1[:...[:parameter#]]

        Note: Whitespaces in the parameter for a task in a task group are not allowed.
        Comments in task group definitions are allowed; comments must start with a hash "#" in the first column.
        So to add comments to a task group use a task group definition with line breaks, e.g.:
       
TASK_GROUP_mytaskgroup001="# comment 1
# comment 2
# ...
#I# This line will be used as task info line and printed by the script
#I# This line also ...
        task1 task2 task3
task4:parameter1 task5:parameter1:parameter2 task8
[...]
  task9
  "
       
        Lines starting with the prefix "#I#" in a task group definition will be printed if one of the parameter
        "--list", "--list_tasks", or "--list_task_groups" together with the parameter "-v" is used.


        Task group "all"
        ----------------

        To execute all defined tasks in all used include files use the parameter "all"; the tasks will then be executed
        in alphabetical order. If the parameter "all" is found all other task parameter will be ignored.
        Add the statement "DISABLE_THE_PARAMETER_ALL=0" to an include file to disable the parameter "all"
        (this setting can NOT be reverted in other include files).

        To change the list of tasks that should be executed for an include file if the parameter "all" is used create
        a variable called "DEFAULT_TASKS" with the list of tasks to execute for "all" separated by white spaces in the include file .
        If the variable "DEFAULT_TASKS" is defined in at least one include file it will be used for the parameter "all".
        If the variable "DEFAULT_TASKS" is defined in more then one include file the contents of the variables will be concatenated.
       
        Use the statement "DEFAULT_TASKS=all" in an include file to add all tasks defined in an include file to the variable
        "DEFAULT_TASKS" if that variable is defined in another include file.
        Add the statement "DEFAULT_TASKS=none" to an include file to suppress the warning about a missing definition for DEFAULT_TASKS
        for that include file.
        The use of the variable "DEFAULT_TASKS" is also neccessary to change the order for executing the tasks.
        Be carefull if using include files with and without a defined variable "DEFAULT_TASKS"; execute the script with the parameter
         "--only_list_tasks" to check which tasks would be executed.

        To define tasks that should not be executed if the parameter "all" is used create a variable called "NO_DEFAULT_TASKS"
        in the include file with the task names. If a task is defined in the variable DEFAULT_TASKS and NO_DEFAULT_TASKS it will not
        be executed if "all" is used. You may also use patterns with "*" and "?" (like "check_*" or "*003") in the list of tasks
        to ignore for "all".
        If the variable "NO_DEFAULT_TASKS" is defined in more then one include file the contents of the variables will be concatenated.


        Task group "ALL"
        ----------------

        Use the parameter "ALL" to override the DEFAULT_TASKS settings from the include files and ignore the setting for
        DISABLE_THE_PARAMETER_ALL from all include files. If the parameter "ALL" is found all other task parameter will be ignored.
        Use the parameter "ALL" only if really neccessary -- in principle you should never use this parameter.


        Disable tasks
        -------------

        To disable one or more tasks add the tasks to the variable DISABLED_TASKS in one of the include files - the tasks in that
        variable will not be executed. DISABLED_TASKS can be set and changed in any function or task in the include files. This can
        be used to dynamically disable tasks.
        To not override DISABLED_TASKS defined in other include files always add new tasks to the variable, e.g.:

          DISABLED_TASKS="${DISABLED_TASKS} [new_disabled_tasks]"

        To disable one or more tasks via the parameter use the parameter "--disabled_tasks".
        To list all disabled tasks use the parameter "--list_disabled_tasks".
        To temporary enable the disabled tasks use the parameter "--enable_all_tasks".


        Input files with tasks list
        ---------------------------

        To use an input file with the list of tasks to execute use a filename with at least one slash "/",
        e.g. "./mytasklist"
        Each line in that file must contain either a comment starting with a hash "#" or one task or task group to execute; e.g.:

#
# sample task input file
#
# with the list of the tasks to execute, e.g.
#
#   use one blank to separate the parameter from the tasks; multiple parameter are possible;
#   blanks or colons (:) in the parameter values are not possible)
#
mytask0
mytask1 parameter1 parameter2
#
# task groups can also be used, e.g.:
#   parameter for the tasks are not possible if using task groups
#
mytask_group0
#
# patterns with "*" and "?" can also be used to define tasks to execute, e.g. :
#   parameter for the tasks are not possible if using patterns
#
check*

        Empty lines and lines beginning with a "#" in an input file are ignored.

        Special tasks
        -------------
       
        The function "init_tasks" will always be executed before the first task is executed if defined in
        one of the include files. If "init_tasks" ends with a return code not equal "0" the
        script execution will be aborted without executing any of the tasks (use the parameter "--no_init_tasks" to
        disable the execution of the function "init_tasks").

        The function "finish_tasks" will always be executed after the last task is executed if defined
        in one of the include files (use the parameter "--no_finish_tasks" to disable the execution of the
        function "finish_tasks"). The return code of the function finish_tasks will be ignored.

        If either "init_tasks" or "finish_tasks" are defined in more then one include file only the definition
        from the last include file read is used.

        Note:

        Additional tasks that should not be executed if the parameter all is used can now be defined in
        the function init_vars in the variable NO_DEFAULT_TASKS



   -- parameter_for_init_tasks
        All parameter following the separator "--" are parameter for the function "init_tasks" defined in the include file(s).
        Use the variable "PARAMETER_FOR_INIT_TASKS" in the function "init_tasks"to read the parameter.
        These parameter will be ignored by the script execute_tasks.sh.

   --includefile
      - name of an include file to use; the parameter can be used multiple times
        The parameter is optional; without the parameter "--includefile" the script only reads the
        default include file
        The default include file for the script
          "execute_tasks.sh "
        is
          "execute_tasks.include"
        this file is searched in the current directory and in the directory with this script
          "/data/develop/scripts"

        Note: The name of the default include file depends on the script name (which can also be a symbolic link)

        Use a leading question mark "?" for the filenames of optional include files, e.g. "-i ?my_optional_file".
        Optional include files are only used if they exist.
        use "--includefile none" to delete the list of include files (including the default include file and
        optional include files)
        The script will not read the default include file if the parameter "--includefile" is used
        for at least one mandatory include file.
        The default include file will be read if the parameter "--includefile" is only used for
        optional include files.
        To read additional include files before reading the default include file add the parameter
        "--includefile default" after all other include files.
        To read additional include files after reading the default include file add a leading plus sign "+" to the
        name of the includefile
        The format "--includefile:filename" is also supported for this parameter

   --print_includefile_help
        only show the help text for all include files (these are all lines beginning with the prefix "#H#" in the
        1st column in all include files read)
   --print_task_template
      - print the template for a new task definition to the file "filename" and exit. If "filename" is missing
        the template is written to STDOUT
   --list [pattern1[...[pattern#]]
      - list all defined tasks and task groups and exit; use "-v --list " to print also the usage help for each task
        if defined and the task group info for each task group if defined
        use one or more patterns with "*" and "?" (pattern) to only list tasks and task groups matching one of the pattern.
        The script will add a leading "*" and a trailing "*" to every pattern without a "*" and a "?".
        e.g. the pattern "check" will list all tasks and task groups matching the pattern "*check*";
        the pattern "check*" will only match the tasks and task groups matching the patterns with "check*".
        Do not use the leading string "task_" in the patterns.
   --list_tasks
      - like the parameter "--list" but only list the tasks and do not list the task groups
   --list_task_groups [pattern1[...[pattern#]]
      - list all defined task groups and exit;
        pattern# are (optional) patterns with "*" and "?" to list only the task groups that match one of the pattern.
        see the description for the parameter "--list" for details regarding the supported pattern.
   --list_default_tasks
      - list only the tasks that would be executed if the parameter "all" is used
   --list_disabled_tasks
       - execute the function init_tasks if defined, list the disabled tasks, and exit
   --create_include_file_template
      - create an include file template and exit. If "filename" is missing the default include file will be created.
   --abort_on_error
      - abort the task execution if a task fails, default: continue the task execution after a task failed
   --abort_on_task_not_found
      - abort the task execution if a task is not defined, default: continue the task execution with the next task
   --abort_on_duplicates
      - do not start the task execution if one or more tasks are defined multiple times; default: use the
        task definition found in the last include file read and ignore the other definitions
        use "++abort_on_duplicates" to suppress the warnings for duplicate task definitions
   --checkonly
      - check if all requested tasks exist and exit
   --check
      - check if all requested tasks exist before executing the tasks; exit if one or more tasks are missing
   --singlestep
      - execute the steps in single step mode
   --unique
      - execute every task only once
   --trace
      - enable trace for all tasks to execute
        to enable trace for only one task if multiple tasks are executed use the parameter "-t task_<taskname>"
        Tracing will only work if the function for the task starts like this

function task_taskname {
  typeset __FUNCTION=task_taskname
  ${__DEBUG_CODE}
  ${__FUNCTION_INIT}
       
   --info
      - enable verbose mode for the tasks to execute
   --no_init_tasks
      - do not execute the function "init_tasks"
   --no_finish_tasks
      - do not execute the function "finish_tasks"
   --only_list_tasks
      - only list the tasks that would be executed; init_tasks and finish_tasks will also
        not be executed. This parameter will not process the list of disabled tasks.
        To check which tasks would be executed considering the disabled tasks defined in the
        include files or the parameter for the script use the parameter "-d".
       
   --disabled_tasks
        Add one or more tasks to the list of disabled tasks; use blanks or commas to separate tasks;
        pattern for the disabled tasks are supported. This parameter can be used more then once
        Use "--disabled_tasks none" to delete the list of disabled tasks defined with this parameter
        also supported is the format "--disabled_tasks:task[...]"

   --enable_all_tasks
        enable all disabled tasks again

   -h - print the script usage; use -h and -v one or more times to print more help text       
   -v - verbose mode; use -v -v to also print the runtime system messages
        (or set the environment variables VERBOSE to 0 and VERBOSE_LEVEL to the level)
   -q - quiet mode (or set the environment variable QUIET to 0)
   -f - force execution (or set the environment variable FORCE to 0 )
   -o - eanble overwrite mode (or set the environment variable OVERWRITE to 0 )
   -y - answer "yes" to all questions
   -n - answer "no" to all questions
   -l - logfile to use; use -l none to not use a logfile at all
        the default logfile is /var/tmp/execute_tasks.sh.log
        also supported is the format "-l:filename"
        The build-in logrotate will keep 10 versions of the log file
        Set the environment variable NO_OF_LOGFILES_TO_KEEP to change this.
   -d - dryrun mode, default dryrun_prefix is: "echo  "
        Use the parameter "-d:<dryrun_prefix>" or the syntax
        "PREFIX=<new dryrun_prefix> /data/develop/scripts/execute_tasks.sh"
        to change the dryrun prefix
        The script will run in dryrun mode if the environment variable PREFIX
        is set. To disable that behaviour use the parameter "+d"
        
   -D - start a debug shell and continue the script afterwards
   -t - trace the function fn
        also supported is the format "-t:fn[,...,fn#]"
   -L - list all defined functions and end the script
   -T - copy STDOUT and STDERR to the file /var/tmp/execute_tasks.sh.1224325.tee.log
        using tee; set the environment variable __TEE_OUTPUT_FILE before
        calling the script to change the file used for the output of tee
   -V - print the script version and exit; use "-v -V" to print the
        template version also
   --var
      - set the variable "name" to the value "value"
        also supported is the format "--var:<varname>=<value>"
   --appendlog
      - append the messages to the logfile (default: overwrite an existing logfile)
        This parameter also sets --nologrotate
   --nologrotate
      - do not create a backup of an existing logfile
   --noSTDOUTlog
      - do not write STDOUT/STDERR to a file if /dev/tty is not a a device
   --nobackups
      - do not create backups
   --disable_tty_check
      - disable the check if we do have a tty
   --nocleanup
      - do no house keeping at script end

Current environment: ksh version: 93 | change function code supported: yes | tracing feature using $0 supported: yes

 Parameter that toggle a switch from true to false or vice versa can
 be used with the plus sign (+) instead of minus (-) to invert the usage, e.g.
 
 The parameter "-v" enables the verbose mode; the parameter "+v" disables the verbose mode.
 The parameter "--quiet" enables the quiet mode; the parameter "++quiet" disables the quiet mode.

 All parameter are processed in the given order, e.g.

  execute_tasks.sh -v +v
    -> verbose mode is now off

  execute_tasks.sh +v -v
    -> verbose mode is now on

 Parameter are evaluated after the evaluation of environment variables, e.g

 VERBOSE=0  execute_tasks.sh
     -> verbose mode is now on

 VERBOSE=0  execute_tasks.sh +v
     -> verbose mode is now off

 
 To disable one or more of the house keeping tasks you might set some variables
 either before starting the script or via the parameter "--var name=value"
 
 The defined variables are
 
  NO_EXIT_ROUTINES=0       # do not execute the exit routines if set to 0
  NO_TEMPFILES_DELETE=0    # do not delete temporary files if set to 0
  NO_TEMPDIR_DELETE=0      # do not delete temporary directories if set to 0
  NO_FINISH_ROUTINES=0     # do not execute the finish routines if set to 0
  NO_UMOUNT_MOUNTPOINTS=0  # do not umount temporary mount points if set to 0
  NO_KILL_PROCS=0          # do not kill the processes if set to 0
 
 Supported environment variables are (values for booleans: 0 = TRUE, 1 = FALSE):

 Variable                    Type                                       Current value                               Comment                                           

 PREFIX                      string                                     ""                                          prefix used in dry-run-mode                       
 __DEBUG_CODE                string                                     ""                                          debug code for the functions                      
 __TEE_OUTPUT_FILE           filename                                   "/var/tmp/execute_tasks.sh.1224325.tee.log" log file used for  --tee                          
 USE_ONLY_KSH88_FEATURES     boolean                                    "1"                                                                                           
 DISABLE_TTY_CHECK           boolean                                    "1"                                         paramaeter disable_tty_check                      
 BREAK_ALLOWED               string                                     "DebugShell"                                0 / 1 / DebugShell                                
 EDITOR                      filename                                   "/usr/bin/nano"                             editor to use                                     
 PAGER                       filename                                   "/usr/bin/less"                             pager to use                                      
 LOGFILE                     filename                                   "/var/tmp/execute_tasks.sh.log"             log file                                          
 NO_OF_LOGFILES_TO_KEEP      integer                                    "10"                                        number of log files to keep                       
 NOHUP_STDOUT_STDERR_FILE    filename                                   ""                                          log file used in the function switch_to_background

 FORCE                       boolean                                    "1"                                         parameter --force                                 
 QUIET                       boolean                                    "1"                                         parameter --quiet                                 
 VERBOSE                     boolean                                    "0"                                         parameter --verbose                               
 VERBOSE_LEVEL               boolean                                    "1"                                                                                           
 OVERWRITE                   boolean                                    "1"                                         parameter --overwrite                             

# environment variables for the RCM methods

 RCM_SERVICE                 string                                     "veritas"                                   used only in the RCM methods                      
 RCM_FUNCTION                string                                     "vcsscripts"                                used only in the RCM methods                      
 RCM_USERID                  string                                     ""                                          used only in the RCM methods                      
 RCM_PASSWORD                string                                     ""                                          used only in the RCM methods                      

 How to use the variables:
     
 Either define the environment variables before executing the script or use the parameter "--var name=value"
 
[12.01.2024 12:27 ] ### The start time was 12.01.2024 12:27:17, the script runtime is (day:hour:minute:seconds) 0:00:00:00 (= 0 seconds)
[12.01.2024 12:27 ] ### execute_tasks.sh ended at 12.01.2024 12:27:17 (The PID of this process is 1224325; the RC is 0)
[ xtrnaw7@t15g /data/develop/scripts ] $