TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 1 | #!/bin/bash |
RehanRaza | d75f613 | 2019-02-19 14:21:30 +0000 | [diff] [blame] | 2 | # EXAMPLE: Run test case TC2 using the command "./prepare.sh TC2" |
| 3 | MAIN_DIRECTORY=./files/onap |
| 4 | TEST_FILE=./test_cases.yml |
| 5 | TEST=$1 |
| 6 | echo "Generating files for test case:" "$TEST" |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 7 | |
RehanRaza | d75f613 | 2019-02-19 14:21:30 +0000 | [diff] [blame] | 8 | sf=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'size_files') |
| 9 | sf=${sf//*size_files: /} |
| 10 | sf_array=($sf) |
| 11 | echo "size_files=""$sf" |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 12 | |
RehanRaza | d75f613 | 2019-02-19 14:21:30 +0000 | [diff] [blame] | 13 | nf=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'number_files') |
| 14 | nf=${nf//*number_files: /} |
| 15 | nf_array=($nf) |
| 16 | echo "number_files=""$nf" |
| 17 | |
| 18 | df=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'directory_files') |
| 19 | df=${df//*directory_files: /} |
| 20 | df_array=($df) |
| 21 | echo "directory_files=""$df" |
| 22 | |
| 23 | rm -rf $MAIN_DIRECTORY/* |
| 24 | if [ "${#sf_array[@]}" = "${#nf_array[@]}" ] && [ "${#nf_array[@]}" = "${#df_array[@]}" ]; |
| 25 | then |
| 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 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame^] | 40 | for ((l=0;l<=$N_SYMLINKS;l++)) |
RehanRaza | d75f613 | 2019-02-19 14:21:30 +0000 | [diff] [blame] | 41 | do |
| 42 | SYMLINK_NAME=$FILE_SIZE"MB_"$l".tar.gz" |
| 43 | ln -s ./$FILE_NAME $DIRECTORY/$SYMLINK_NAME |
| 44 | done |
| 45 | done |
| 46 | else |
| 47 | echo "ERROR: The number of parameters in size_files, number_files, and directory_files must be equal!" |
| 48 | fi |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 49 | |
| 50 | sudo chown root:root ./configuration/vsftpd_ssl.conf |