mirror of https://github.com/sipwise/ngcpcfg.git
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.
79 lines
2.4 KiB
79 lines
2.4 KiB
#!/bin/bash
|
|
# Purpose: commit pending changes
|
|
################################################################################
|
|
|
|
set -e
|
|
set -u
|
|
set -o pipefail
|
|
|
|
if ! [ -r /usr/share/ngcp-ngcpcfg/functions/main ] ; then
|
|
printf "Error: /usr/share/ngcp-ngcpcfg/functions/main could not be read. Exiting.\n" >&2
|
|
exit 1
|
|
fi
|
|
|
|
. /usr/share/ngcp-ngcpcfg/functions/main
|
|
|
|
HELPER="${HELPER:-/usr/share/ngcp-ngcpcfg/helper/}"
|
|
# main script
|
|
|
|
cd "$NGCPCTL_MAIN"
|
|
|
|
if [ -z "${NO_DB_SYNC:-}" ] ; then
|
|
if [ -f "${RTP_INTERFACES_CONFIG}" ] ; then
|
|
log_info "Executing sync-db: "
|
|
"${HELPER}/sync-db" "$NGCPCTL_CONFIG" "$CONSTANTS_CONFIG" "$RTP_INTERFACES_CONFIG" | sed "s/^/$timestamp_replacementchars/" || true
|
|
else
|
|
log_info "Executing sync-db: "
|
|
"${HELPER}/sync-db" "$NGCPCTL_CONFIG" "$CONSTANTS_CONFIG" | sed "s/^/$timestamp_replacementchars/" || true
|
|
fi
|
|
else
|
|
log_debug "no-db-sync: skipping 'sync-db'"
|
|
fi
|
|
|
|
if ! git config user.name >/dev/null ; then
|
|
log_debug 'git config user.name ngcp-config'
|
|
git config user.name "ngcp-config"
|
|
fi
|
|
if ! git config user.email >/dev/null ; then
|
|
log_debug 'git config user.email "root@$(hostname)"'
|
|
git config user.email "root@$(hostname)"
|
|
fi
|
|
|
|
if ! git config --global user.name >/dev/null ; then
|
|
log_debug 'git config --global user.name "git user on $(hostname)"'
|
|
git config --global user.name "git user on $(hostname)"
|
|
fi
|
|
if ! git config --global user.email >/dev/null ; then
|
|
log_debug 'git config --global user.email "root@$(hostname)"'
|
|
git config --global user.email "root@$(hostname)"
|
|
fi
|
|
|
|
# commit message
|
|
if [ -z "${1:-}" ] ; then
|
|
msg="commiting uncommented changes"
|
|
else
|
|
msg="$*"
|
|
fi
|
|
|
|
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 'git add . ; git commit -a -m "$msg [$(date --rfc-3339=ns)]"'
|
|
git add .
|
|
git commit -a -m "$msg [$(date --rfc-3339=ns)]" >/dev/null
|
|
log_info "OK"
|
|
fi
|
|
|
|
log_debug "/usr/share/ngcp-ngcpcfg/scripts/etckeeper"
|
|
/usr/share/ngcp-ngcpcfg/scripts/etckeeper >/dev/null
|
|
|
|
if [ -z "${NO_DB_SYNC:-}" ] ; then
|
|
log_info "Synchronizing data from ${CONSTANTS_CONFIG}"
|
|
ngcp-sync-constants >/dev/null | sed "s/^/$timestamp_replacementchars/"
|
|
else
|
|
log_debug "no-db-sync: skipping 'ngcp-sync-constants'"
|
|
fi
|
|
|
|
## END OF FILE #################################################################
|