|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
if ! command -v pigz &> /dev/null; then |
|
|
echo "Error: pigz is not installed. Please install it and try again." |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
ROOT_DIR="../data_test" |
|
|
|
|
|
|
|
|
usage() { |
|
|
echo "Usage: $0 [--method METHOD --config CONFIG] | [--all]" |
|
|
exit 1 |
|
|
} |
|
|
|
|
|
unzip_config() { |
|
|
local method=$1 |
|
|
local config=$2 |
|
|
local output_path="$ROOT_DIR/$method/$config" |
|
|
local zipped_file="./data/$method/$config/$config.tar.gz" |
|
|
echo "Decompressing $zipped_file to $output_path" |
|
|
|
|
|
mkdir -p "$output_path" |
|
|
|
|
|
|
|
|
echo "Decompressing $zipped_file to $output_path" |
|
|
tar -xv --use-compress-program=pigz -f "$zipped_file" --directory "$output_path" |
|
|
if [[ $? -ne 0 ]]; then |
|
|
echo "Error: Failed to decompress $zipped_file" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
echo "Decompressing $zipped_file sucessfully to $output_path" |
|
|
} |
|
|
|
|
|
|
|
|
while [[ "$#" -gt 0 ]]; do |
|
|
case $1 in |
|
|
--help) usage ;; |
|
|
--h) usage ;; |
|
|
--all) ALL="true" ;; |
|
|
--method) METHOD="$2"; shift ;; |
|
|
--config) CONFIG="$2"; shift ;; |
|
|
*) echo "Unknown parameter: $1"; usage ;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
|
|
|
if [[ "$ALL" == "true" ]]; then |
|
|
|
|
|
for method_dir in ./data/*; do |
|
|
if [[ -d "$method_dir" && "$(basename "$method_dir")" != "Origin" ]]; then |
|
|
method=$(basename "$method_dir") |
|
|
for config_dir in "$method_dir"/config*; do |
|
|
if [[ -d "$config_dir" ]]; then |
|
|
config=$(basename "$config_dir") |
|
|
unzip_config "$method" "$config" |
|
|
fi |
|
|
done |
|
|
fi |
|
|
done |
|
|
|
|
|
if [ -e "./data/Origin/Origin.tar.gz" ]; then |
|
|
|
|
|
mkdir -p "$ROOT_DIR/Origin" |
|
|
|
|
|
|
|
|
echo "Decompressing ./data/Origin/Origin.tar.gz to $ROOT_DIR/Origin" |
|
|
tar -xv --use-compress-program=pigz -f "./data/Origin/Origin.tar.gz" --directory "$ROOT_DIR/Origin" |
|
|
if [[ $? -ne 0 ]]; then |
|
|
echo "Error: Failed to decompress ./data/Origin/Origin.tar.gz" |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
echo "All configurations have been zipped successfully." |
|
|
exit 0 |
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [[ ! -n "$METHOD" || ! -n "$CONFIG" ]]; then |
|
|
echo "Error: Both --method and --config or --all must be specified." |
|
|
usage |
|
|
fi |
|
|
unzip_config "$METHOD" "config$CONFIG" |