mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-24 19:32:17 +00:00
fix(xcat-core): nic_cfg.sh backup fails on a node with no network configuration
"nic_cfg.sh backup" returns 1 on a node that has just netbooted, so confignetwork_static_installnic fails on its third command before it configures anything. The identical call seven seconds later returns 0, once confignetwork has created the directory. The backup arm ended in a cp over the backend's configuration directory, so the script exited with that cp's status. A diskless Ubuntu node has no /etc/network/interfaces.d until confignetwork writes one, the cp failed, and the caller read "nothing to back up" as a failure. Copy only when the source directory exists. A cp that fails with the directory present still returns non-zero, and so does a backup that cannot create its own directory. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> (cherry picked from commit 3a682a130dffe2406a5048174e174ee693133cc4)
This commit is contained in:
@@ -181,12 +181,15 @@ case "$1" in
|
||||
esac
|
||||
;;
|
||||
backup)
|
||||
be=$(detect_backend); rm -rf "$BACKUP"; mkdir -p "$BACKUP"
|
||||
# A source directory that does not exist holds no configuration to snapshot, which is
|
||||
# the state of a node that has just netbooted. Report success: the exit status of a cp
|
||||
# over an absent directory made the caller read "nothing to back up" as a failure.
|
||||
be=$(detect_backend); rm -rf "$BACKUP"; mkdir -p "$BACKUP" || exit 1
|
||||
case "$be" in
|
||||
nm) cp -af "$NMDIR"/. "$BACKUP"/ 2>/dev/null ;;
|
||||
suse) cp -af "$SUSEDIR"/ifcfg-* "$BACKUP"/ 2>/dev/null ;;
|
||||
rh) cp -af "$RHDIR" "$BACKUP"/ 2>/dev/null ;;
|
||||
ubuntu) cp -af "$UBUDIR"/. "$BACKUP"/ 2>/dev/null ;;
|
||||
nm) if [ -d "$NMDIR" ]; then cp -af "$NMDIR"/. "$BACKUP"/ 2>/dev/null; fi ;;
|
||||
suse) if [ -d "$SUSEDIR" ]; then cp -af "$SUSEDIR"/ifcfg-* "$BACKUP"/ 2>/dev/null || :; fi ;;
|
||||
rh) if [ -d "$RHDIR" ]; then cp -af "$RHDIR" "$BACKUP"/ 2>/dev/null; fi ;;
|
||||
ubuntu) if [ -d "$UBUDIR" ]; then cp -af "$UBUDIR"/. "$BACKUP"/ 2>/dev/null; fi ;;
|
||||
esac
|
||||
;;
|
||||
restore)
|
||||
|
||||
Reference in New Issue
Block a user