edrcscripts

Package: WA2L/edrc 1.5.57
Section: Maintenance Commands (1m)
Updated: 18 November 2020
Index Return to Main Contents

 

NAME

edrcscripts - writing recovery scripts in edrc

 

SYNOPSIS

edrc/bin/scripts/CUSTOMER-edrc/...

edrc/bin/scripts/CUSTOMER-sat/...

edrc/bin/scripts/CUSTOMER-sat/sup:Support/osup:OperationSupport/...

edrc/bin/scripts/CUSTOMER-sat/sup:Support/psup:ProductionSupport/...

CUSTOMER ::= `server_environment -C`

 

AVAILABILITY

WA2L/edrc

 

DESCRIPTION

 

READ ALSO

It is highly recommended to also read the manual pages listed in the SEE ALSO section, especially edrc(1m) and edrcintro(1) because the WA2L/edrc package provides many commands and concepts that significantly ease up the efficient development of recovery scripts.

 

CREATE/RENAME/REMOVE RECOVERY SCRIPTS

Recovery scripts are created using the newscript command in edrc (1m), are renamed using the renamescript command and are removed using removescript.

The newscript command provides a script file template and ensures that the recovery script name adheres to the supported name convention.

edrc maintains an environment that makes it obsolete to initialize common settings of the operating system in each script and makes a recovery script tree portable.

 

CENTRAL INITIALIZATION AND COMMAND EXECUTION

If it is needed to centrally initialize variables or execute commands before each script in a menu, the env command in edrc supports to do this initialization or command start before each script by handling an environment-file that sits in the menu.

Candidates of commands to be executed in an environment-file created with env are for example scripttitle(3) and scriptsequence(3).

 

CREATE/RENAME/REMOVE (SUB) MENUS

(Sub)Menus are created, renamed and removed using the newmenu, renamemenu and removemenu commands in edrc.

 

DOCUMENTATION

A recovery script can easily be documented using doc tags as understood by the contrib.doc (1m) command.

Doing this the description can be easily displayed using the doc contributed command, which generates an ah-hoc manual page where the essentials to know about a script, as if a RE-RUN of the script is allowed, the duration of the execution or an example output and more can be documented.

This documentation can be used later to produce a whole documentation, the ScriptDocBook using the scriptdocbook command that can be used for offline-reading in a Web-browser without the need to write another documentation.

 

OPTIONS

recovery scripts do not receive options, all input needs to be queried, best using the input(3) and choice(3) commands which are tuned to work smooth with edrc(1m).

 

ENVIRONMENT

See section ENVIRONMENT in edrc(1m) for a description of all environment variables exported to a recovery script.

Use the edrcenv(1) command in the shell started from edrc or the edrcenv contributed command in edrc to print the official environment variables that can be used.

 

EXIT STATUS

a recovery script can exit with any exit status, it will not be resolved.

 

FILES

$EDRC_TMP_DIR/
secure temporary directory that should be used by a recovery script to save temporary data.

The directory with a unique name is created new just before the start of a recovery script and is removed after the script execution.

Therefore a recovery script doesn't need to take care of the temporary directory.

$EDRC_TMP_DIR_SESSION/
this variable points to a secure temporary directory that exists during the execution of an edrc session and is afterwards removed. This variable is exported to recovery scripts, contributed commands and the shell command only.

This variable should be used to securely save temporary data from recovery scripts or contributed commands that must be accessed multiple times throughout the edrc session.

You should add the name of the recovery script or contributed command as prefix to ensure a unique filename.


Example:

date > $EDRC_TMP_DIR_SESSION/$EDRC_SCRIPTNAME.data

If you need to save temporary data during the execution of a recovery script or a contributed command the $EDRC_TMP_DIR variable shall be used.

 

EXAMPLES

1) Example environment (_env) file:

#
# _env - Environment settings for commands in /DR
#
# [00] 07.05.2020 CWa   Initial Version
#
#
test "$DEBUG" = True && set -x

scripttitle
scriptsequence -a query || exit

export AVAMAR_ADMIN="admin"
export AVAMAR_SYSADMIN="sysadmin"

export CONNECTION_USER="edrc"

2) Example recovery script:

#!/bin/bash
# 
# 1291:setup_ndmp - setup NDMP accelerator
#
# [00] 06.05.2020 CWa   Initial Version
# 
test "$DEBUG" = True && set -x

# const and defaults
#
user_at_node=root@acme-007.acme.ch
root_password="`pwsafe root@IDPA`"

# query information
#
while [ "$ok" != "y" ]; do
        echo
        root_password=`input "Root server password" "$root_password" \
                       LOG_STARS,NOT_NULL,NO_TRIM`
        echo
        ok=`choice "input OK? <yn>" yn n`
done
echo

# execute commands
#
ssh-exec -l $CONNECTION_USER -u $user_at_node <<EOM

[COMMANDS]

avsetupndmp

[ANSWERS]

;avsetupndmp will stop all running agents;Y\r;
;Network address or DNS name of this Accelerator Node;\r;
;Network address or DNS name of the Avamar Server;\r;
;Root password of Avamar Server;$root_password\r;
;Repeat password;$root_password\r;
;Enable support for multiple simultaneous backups Y/N?;Y\r;
;Enter action:;5\r;

EOM


# D: Setup NDMP accelerator nodes:
# D:
# D: - setup NDMP accelerator node bkpviewbad01
#
# R: YES
#
# O: Root server password [********]: ********
# O: 
# O: input OK? <yn>  [n] :y
# O: 
# O: avsetupndmp version 5.0
# O: Configure systems for backup and restore.
# O: avsetupndmp will stop all running agents, do you wish to continue Y/N? [Y]: Y
# O: 
# O: avagent Info: ------------------------------------------------------------
# O: avagent Info: Client 'acme-008-0815' in directory '/usr/local/avamar/var/acme-008-0815'
# O: avagent Info: Client Agent acme-008-0815 not running.
# O: avagent Info: ------------------------------------------------------------
:
:
# O: avagent Info: ------------------------------------------------------------
# O: 
# O: IMPORTANT: Be sure to run avregister if you have added new accounts.
#
# N: Chapter: 6.16, Step 1
#
# T: ~10 seconds
#

3) Examples in script trees part of the WA2L/edrc package:

See "recovery" script examples in the sys (1) maintenance configuration located in edrc/scripts/sys/.

 

SEE ALSO

edrcintro(1), edrc(1m), approot(3), choice(3), contrib(1m) contrib.edrc(1m), contrib.doc(1m), contrib.pwsafe(1m), pwsafe(3), contrib.scriptsequence(1m), scriptsequence(3), hostlist(3), hostlist.dat(4), input(3), input_targets(3), outex(1), rel2abs(3), scripttitle(3), server_environment(3), ssh-exec(1)

 

NOTES

-

 

BUGS

-

 

AUTHOR

edrcscripts was developed by Christian Walther. Send suggestions and bug reports to wa2l@users.sourceforge.net .

 

COPYRIGHT

Copyright © 2020 by Christian Walther

This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 

Index

NAME
SYNOPSIS
AVAILABILITY
DESCRIPTION
READ ALSO
CREATE/RENAME/REMOVE RECOVERY SCRIPTS
CENTRAL INITIALIZATION AND COMMAND EXECUTION
CREATE/RENAME/REMOVE (SUB) MENUS
DOCUMENTATION
OPTIONS
ENVIRONMENT
EXIT STATUS
FILES
EXAMPLES
SEE ALSO
NOTES
BUGS
AUTHOR
COPYRIGHT

This document was created by man2html using the manual pages.
Time: 16:52:54 GMT, August 28, 2024