|
|
|
|
@ -19,6 +19,62 @@ if ! [ -d "${NGCPCTL_MAIN:-}" ] ; then
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
|
printf "ngcpcfg status -- supported command line options:
|
|
|
|
|
|
|
|
|
|
--local-only - do not check state on any remote host(s) (HA/PRO only)\n\n"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CHECK_REMOTE=true
|
|
|
|
|
REMOTE_INVOKED=false
|
|
|
|
|
while [ -n "${1:-}" ] ; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
*--local-only*) CHECK_REMOTE=false ; shift ;;
|
|
|
|
|
*--remote*) REMOTE_INVOKED=true ; shift ;; # used when invoking ngcpcfg status remotely
|
|
|
|
|
*--help*) usage ; exit 0 ;;
|
|
|
|
|
*) break ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
remote_check() {
|
|
|
|
|
if ! "$CHECK_REMOTE" ; then
|
|
|
|
|
log_info "Skipping remote checks as requested via --local-only option."
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if "$REMOTE_INVOKED" ; then
|
|
|
|
|
log_debug "REMOTE_INVOKED is enabled, skipping remote_check"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ! [ -r "$NGCPCTL_MAIN/systems.cfg" ] ; then
|
|
|
|
|
log_error "File $NGCPCTL_MAIN/systems.cfg could not be read, can not check foreign servers."
|
|
|
|
|
log_error "Either execute 'ngcpcfg status' without --remote option or configure $NGCPCTL_MAIN/systems.cfg."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
hostlist="$(cat $NGCPCTL_MAIN/systems.cfg)"
|
|
|
|
|
log_debug "hostlist = $hostlist"
|
|
|
|
|
|
|
|
|
|
for host in $hostlist ; do
|
|
|
|
|
log_debug "check $host == $HNAME"
|
|
|
|
|
if [[ "$host" == "$HNAME" ]] ; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
log_info "-----------------------------------------------------------------"
|
|
|
|
|
log_info "Checking state on remote system ${host}:"
|
|
|
|
|
log_debug "timeout 30 ssh $host ngcpcfg status --remote"
|
|
|
|
|
if timeout 30 ssh $host ngcpcfg status --remote ; then
|
|
|
|
|
log_debug "ssh $host ngcpcfg status returned without error"
|
|
|
|
|
else
|
|
|
|
|
log_error "Error while checking state on remote host ${host}."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
log_info "End of state check on ${host}."
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log_debug "cd $NGCPCTL_MAIN"
|
|
|
|
|
cd "$NGCPCTL_MAIN"
|
|
|
|
|
|
|
|
|
|
@ -28,12 +84,12 @@ if ! [ -r /etc/ngcp-config/.git/HEAD ] ; then
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
log_info "OK: has been initialised already "
|
|
|
|
|
log_info "OK: has been initialised already"
|
|
|
|
|
|
|
|
|
|
log_info "Checking state of configuration 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."
|
|
|
|
|
log_info "OK: nothing to commit"
|
|
|
|
|
else
|
|
|
|
|
if git diff-index --name-only HEAD | grep -q . ; then
|
|
|
|
|
log_info "ACTION_NEEDED: configuration files have been modified:"
|
|
|
|
|
@ -58,12 +114,35 @@ fi
|
|
|
|
|
log_debug "cd /etc"
|
|
|
|
|
cd /etc
|
|
|
|
|
|
|
|
|
|
log_info "Checking state of /etc files"
|
|
|
|
|
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."
|
|
|
|
|
log_info "OK: nothing to commit"
|
|
|
|
|
else
|
|
|
|
|
log_info "ACTION_NEEDED: configuration files changed (execute 'etckeeper commit [message]')."
|
|
|
|
|
log_info "ACTION_NEEDED: configuration files changed (execute 'etckeeper commit [message]')"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
log_debug "cd $NGCPCTL_MAIN"
|
|
|
|
|
cd "$NGCPCTL_MAIN"
|
|
|
|
|
|
|
|
|
|
if [ -r /usr/share/ngcp-ngcpcfg/functions/ha_features ] ; then
|
|
|
|
|
log_info "Checking state of shared storage:"
|
|
|
|
|
log_debug "git push --dry 2>&1 | grep -q 'Everything up-to-date'"
|
|
|
|
|
if git push --dry 2>&1 | grep -q 'Everything up-to-date' ; then
|
|
|
|
|
log_info "OK: nothing to push"
|
|
|
|
|
else
|
|
|
|
|
log_info "ACTION_NEEDED: outstanding changes to push (execute 'ngcpcfg push')"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
log_debug "git fetch --dry-run 2>&1 | grep -q From"
|
|
|
|
|
if ! git fetch --dry-run 2>&1 | grep -q From ; then
|
|
|
|
|
log_info "OK: nothing to pull"
|
|
|
|
|
else
|
|
|
|
|
log_info "ACTION_NEEDED: outstanding changes to pull (execute 'ngcpcfg pull')"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
log_debug "remote_check"
|
|
|
|
|
remote_check
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
## END OF FILE #################################################################
|
|
|
|
|
|