MT#63742 Add new post-build script to handle database actions

We will use this new action to handle database actions that are
currently done in the commit action.

These need to be performed after build and before service, so that
any service restart will have the correct grants and schema changes
to be able to operate correctly.

Change-Id: Ia13c40bcd219902fa523f989d3f1f686fdff93a1
mr26.0
Guillem Jover 9 months ago
parent 48ba665f85
commit ad0cf94b46

@ -36,6 +36,7 @@ scripts/get usr/share/ngcp-ngcpcfg/scripts/
scripts/initialise usr/share/ngcp-ngcpcfg/scripts/
scripts/log usr/share/ngcp-ngcpcfg/scripts/
scripts/patch usr/share/ngcp-ngcpcfg/scripts/
scripts/post-build usr/share/ngcp-ngcpcfg/scripts/
scripts/services usr/share/ngcp-ngcpcfg/scripts/
scripts/set usr/share/ngcp-ngcpcfg/scripts/
scripts/show usr/share/ngcp-ngcpcfg/scripts/

@ -311,13 +311,14 @@ Actions and action specific options
**apply** [--dry-run] [--force-all-services] [--ignore-branch-check] [--ignore-shared-storage-check] [--modified-only] [<commit_message>]::
Executes the _check_, _build_, _services_ and _commit_ commands in a batch
(assuming each command worked as expected). This option serves as a shortcut for
the most commonly executed commands. If there are any outstanding changes that
need to be committed, then the commit message needs to be provided. This is
meant so the configuration change history (accessible e.g. via 'ngcpcfg log')
provides useful information.
Options for _services_, _build_ and _check_ can be used here too.
Executes the _check_, _build_, _post-build_, _services_ and _commit_ commands
in a batch (assuming each command worked as expected).
This option serves as a shortcut for the most commonly executed commands.
If there are any outstanding changes that need to be committed,
then the commit message needs to be provided.
This is meant so the configuration change history
(accessible e.g. via 'ngcpcfg log') provides useful information.
Options for _check_, _build_ and _services_ can be used here too.
**cat** [<config-type>...]::
@ -366,6 +367,12 @@ shell globbing patterns - so argument 'mo..t' will match the files
You can combine _<files_or_directories>_ and _<pattern>_ and use multiple
arguments.
**post-build**::
Performs needed actions after building the files, and before starting the
services, such as synchronizing the database credentials or updating its
timestamps.
**clean** [--all] [--branches] [--force] [--help] [--reset-master] [--stashes] [--tracked-files] [--untracked-files]::
Clean ngcpcfg from not-yet committed/applied changes, reset git state and remove
@ -609,6 +616,7 @@ The main workflow *with* High Availability setup is:
ngcpcfg pull # retrieve possibly pending updates
$EDITOR /etc/ngcp-config/config.yml # adjust/extend configuration
ngcpcfg build # generate/update configuration files
ngcpcfg post-build # perform post build actions
ngcpcfg services # restart services for modified configs
ngcpcfg commit "summary of changes" # register changes
ngcpcfg push # upload changes to shared storage + remote systems

@ -65,6 +65,9 @@ if ! ${DRYRUN} && check_for_outstanding_commits && [ -z "${1:-}" ] ; then
fi
"${SCRIPTS}"/build "${build_args[@]}" "${check_args[@]}"
if ! ${DRYRUN} ; then
"${SCRIPTS}"/post-build
fi
"${SCRIPTS}"/services "${services_args[@]}"
if ! ${DRYRUN} ; then

@ -0,0 +1,26 @@
#!/bin/bash
# Purpose: perform post-build actions
################################################################################
set -e
set -u
set -o pipefail
# support testsuite
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
if ! [ -r "${FUNCTIONS}"/main ]; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}" >&2
exit 1
fi
# shellcheck source=./functions/main
. "${FUNCTIONS}"/main
# main script
cd "$NGCPCTL_MAIN"
# XXX: Skeleton for incremental deployment.
## END OF FILE #################################################################
Loading…
Cancel
Save