Create a small utility script at /app/overrideDbSample.sh that performs a simple DB-version override and optional file copy.
Requirements
File location and name:
Implement the solution as a Bash script at /app/overrideDbSample.sh
The script must be executable (chmod +x).
Behavior when executed:
Print a short status line indicating the script is running (for example: running overrideDbSample.sh).
Export an environment variable named DBVERSIONTOCOPY set to the DB version string 8.10.0.
If a directory /db810 exists on the filesystem, remove any files currently in /upload (leave the directory itself) and copy all files from /db810 into /upload.
Exit with success (0) on normal completion; return a non-zero status only on unexpected errors.
Environment:
The script should not unset or modify unrelated environment variables (for example, SCRIPT and APPS may be present in the environment and must be left intact).
Notes and expectations:
Use absolute paths (/db810 and /upload).
The script should tolerate the case where /db810 does not exist (do nothing to /upload in that case).
Standard utilities (rm, cp, echo, export) may be used; keep the implementation brief and robust.
Example (behavioral) summary:
Running the script prints a short message, ensures DBVERSIONTOCOPY is exported with value 8.10.0, and, if /db810 exists, replaces the contents of /upload with the files from /db810.
Place your completed, executable overrideDbSample.sh at /app/overrideDbSample.sh.
Tests
The following test script will be used to verify your solution:
bash
#!/bin/bash
if [ ! "$SCRIPT" ]
then
echo "ERROR: the environment variable SCRIPT needs to be defined."
return 0
fi
if [ ! "$APPS" ]
then
echo "ERROR: the environment variable APPS needs to be defined."
return 0
fi
echo "running overrideDbSample.sh"
export DBVERSIONTOCOPY=8.10.0
if [ -d "/db810" ]
then
rm /upload/*
cp /db810/* /upload/
fi