Fix collect sysadmin plugin to support copying globs
This update creates a common copy_files function that handles missing or glob copy handling modes. Test Plan: PASS: Verify copy handling when - no files match pattern - one file pattern match - several files match pattern Closes-Bug: 2068495 Change-Id: I0068e087f8867f4bafcedd7a89289da5136a29d5
This commit is contained in:
parent
2f17b903ce
commit
0f6cba1666
@ -14,10 +14,18 @@ source /usr/local/sbin/collect_utils
|
|||||||
SYSADMIN_DIR="${extradir}/sysadmin"
|
SYSADMIN_DIR="${extradir}/sysadmin"
|
||||||
mkdir -p ${SYSADMIN_DIR}
|
mkdir -p ${SYSADMIN_DIR}
|
||||||
|
|
||||||
#check files exists and then copy to sysadmin directory
|
# Function to copy files based on pattern
|
||||||
|
copy_files()
|
||||||
|
{
|
||||||
|
local pattern=$1
|
||||||
|
for file in /home/sysadmin/${pattern} ; do
|
||||||
|
[ -e "${file}" ] && cp "${file}" "${SYSADMIN_DIR}/"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
[ -e /home/sysadmin/*.log ] && cp /home/sysadmin/*.log /${SYSADMIN_DIR}/
|
# get the log and yaml files from the sysadmin home dir
|
||||||
[ -e /home/sysadmin/*.yml ] && cp /home/sysadmin/*.yml /${SYSADMIN_DIR}/
|
copy_files "*.log"
|
||||||
[ -e /home/sysadmin/*.yaml ] && cp /home/sysadmin/*.yaml /${SYSADMIN_DIR}/
|
copy_files "*.yml"
|
||||||
|
copy_files "*.yaml"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user