blob: f1146a61eb230428ec338028569bbceb6968a5a3 [file] [log] [blame]
TamasBakai9b780332019-02-15 08:38:16 +00001#!/bin/bash
RehanRazad75f6132019-02-19 14:21:30 +00002# EXAMPLE: Run test case TC2 using the command "./prepare.sh TC2"
3MAIN_DIRECTORY=./files/onap
4TEST_FILE=./test_cases.yml
5TEST=$1
6echo "Generating files for test case:" "$TEST"
TamasBakai9b780332019-02-15 08:38:16 +00007
RehanRazad75f6132019-02-19 14:21:30 +00008sf=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'size_files')
9sf=${sf//*size_files: /}
10sf_array=($sf)
11echo "size_files=""$sf"
TamasBakai9b780332019-02-15 08:38:16 +000012
RehanRazad75f6132019-02-19 14:21:30 +000013nf=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'number_files')
14nf=${nf//*number_files: /}
15nf_array=($nf)
16echo "number_files=""$nf"
17
18df=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'directory_files')
19df=${df//*directory_files: /}
20df_array=($df)
21echo "directory_files=""$df"
22
23rm -rf $MAIN_DIRECTORY/*
24if [ "${#sf_array[@]}" = "${#nf_array[@]}" ] && [ "${#nf_array[@]}" = "${#df_array[@]}" ];
25then
26 N_ELEMENTS=${#df_array[@]}
27 for ((n=0;n<$N_ELEMENTS;n++))
28 do
29 # Create directory
30 DIRECTORY=$MAIN_DIRECTORY/${df_array[$n]}
31 mkdir -p "$DIRECTORY"
32
33 # Create original file
34 FILE_SIZE=${sf_array[$n]}
35 FILE_NAME=$FILE_SIZE"MB.tar.gz"
36 dd if=/dev/urandom of=$DIRECTORY/$FILE_NAME bs=1k count=$(echo $FILE_SIZE*1000/1 | bc)
37
38 # Create symlinks
39 N_SYMLINKS=${nf_array[$n]}-1
40 for ((l=1;l<=$N_SYMLINKS;l++))
41 do
42 SYMLINK_NAME=$FILE_SIZE"MB_"$l".tar.gz"
43 ln -s ./$FILE_NAME $DIRECTORY/$SYMLINK_NAME
44 done
45 done
46else
47echo "ERROR: The number of parameters in size_files, number_files, and directory_files must be equal!"
48fi
TamasBakai9b780332019-02-15 08:38:16 +000049
50sudo chown root:root ./configuration/vsftpd_ssl.conf