bash script
This commit is contained in:
75
process_dbm.sh
Normal file
75
process_dbm.sh
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
helpFunction()
|
||||||
|
{
|
||||||
|
echo ""
|
||||||
|
echo "Usage: $0 --input_path parameterA --output_path parameterB --dbm_group parameterC"
|
||||||
|
echo -e "\t--input_path Description of what is parameterA"
|
||||||
|
echo -e "\t--output_path Description of what is parameterB"
|
||||||
|
echo -e "\t-dbm_group Description of what is parameterC"
|
||||||
|
exit 1 # Exit script after printing help
|
||||||
|
}
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--input_path=*) input_path="${1#*=}" ;;
|
||||||
|
--output_path=*) output_path="${1#*=}" ;;
|
||||||
|
--dbm_group=*) dbm_group="${1#*=}" ;;
|
||||||
|
*) helpFunction ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Print helpFunction in case parameters are empty
|
||||||
|
if [ -z "$input_path" ] || [ -z "$output_path" ]
|
||||||
|
then
|
||||||
|
echo "Input or Output path is missing.";
|
||||||
|
helpFunction
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Checking input path argument
|
||||||
|
if [[ -d $input_path ]]; then
|
||||||
|
echo "$input_path is a directory"
|
||||||
|
input_path="$input_path/."
|
||||||
|
elif [[ -f $input_path ]]; then
|
||||||
|
echo "$input_path is a file"
|
||||||
|
else
|
||||||
|
echo "Error: Input path does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Checking output path argument
|
||||||
|
if [[ -d $output_path ]]; then
|
||||||
|
echo "$output_path is available"
|
||||||
|
else
|
||||||
|
mkdir -p "$output_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Checking dbm group input
|
||||||
|
if [[ $dbm_group == *"facial"* ]]; then
|
||||||
|
dbm_new=" facial"
|
||||||
|
fi
|
||||||
|
if [[ $dbm_group == *"acoustic"* ]]; then
|
||||||
|
dbm_new="$dbm_new acoustic"
|
||||||
|
fi
|
||||||
|
if [[ $dbm_group == *"movement"* ]]; then
|
||||||
|
dbm_new="$dbm_new movement"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#docker commands to run container
|
||||||
|
docker create -ti --name dbm_container dbm bash
|
||||||
|
docker cp $input_path dbm_container:/app/raw_data
|
||||||
|
|
||||||
|
docker start dbm_container
|
||||||
|
if [ -z "$dbm_new" ]
|
||||||
|
then
|
||||||
|
docker exec -it dbm_container /bin/bash -c "python3 process_data.py --input_path /app/raw_data --output_path /app/output"
|
||||||
|
else
|
||||||
|
docker exec -it dbm_container /bin/bash -c "python3 process_data.py --input_path /app/raw_data --output_path /app/output --dbm_group$dbm_new"
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker cp dbm_container:/app/output $output_path
|
||||||
|
docker stop dbm_container
|
||||||
|
docker rm dbm_container
|
||||||
|
|
||||||
|
exit
|
||||||
Reference in New Issue
Block a user