You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcpcfg/scripts/etckeeper

47 lines
1.2 KiB

#!/bin/bash
# Purpose: wrapper around etckeeper for usage inside ngcpcfg
################################################################################
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
timestamp_replacementchars=''
. "${FUNCTIONS}"/main
# main script
log_debug "cd /etc"
cd /etc
log_debug "type -p etckeeper"
if ! type -p etckeeper &>/dev/null ; then
log_warn "etckeeper is not available, skipping etckeeper execution"
exit 0
fi
log_debug "test -d .git"
if ! [ -d .git ] ; then
log_warn "etckeeper has not been initialized yet, skipping etckeeper execution"
exit 0
fi
log_info "Checking state of /etc files"
log_debug 'git status | grep -q "working directory clean"'
if git status | grep -q 'working directory clean' ; then
log_info "OK: nothing to commit."
else
log_debug "etckeeper commit \"ngcpcfg apply on \$(date)\""
etckeeper commit "ngcpcfg apply on $(date)" | sed "s/^/$timestamp_replacementchars/"
fi
## END OF FILE #################################################################