2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-21 01:42:15 +00:00

fix(xcat-core): nic_cfg.sh backup hides a failed copy of a SUSE ifcfg file

The SUSE branch of nic_cfg.sh backup ran one cp over the ifcfg-* glob
with "|| :" and stderr sent to /dev/null. That form was needed so a
directory with no ifcfg file did not fail the backup, but it also made a
real copy failure return 0 with no message.

Copy each ifcfg file in a loop. A glob that matches nothing is skipped,
and a cp that fails stops the backup with a non-zero exit and the cp
error on stderr.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-10-07 13:46:28 -03:00
parent cec3d05b3c
commit fd7e2ade84
@@ -185,7 +185,12 @@ case "$1" in
be=$(detect_backend); rm -rf "$BACKUP"; mkdir -p "$BACKUP" || exit 1
case "$be" in
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 ;;
suse)
for f in "$SUSEDIR"/ifcfg-*; do
[ -e "$f" ] || continue
cp -af "$f" "$BACKUP"/ || exit 1
done
;;
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