-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest
executable file
·43 lines (37 loc) · 2.17 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
if [ "$#" -ne 1 ]; then # check if there is 1 argument
echo "Usage: $0 <folder>" >&2
exit 1 # if not exit program
fi
folder=$1
if [[ "${folder:0-4}" =~ ".zip"$ ]] ; then # check if last 4 chars are ".zip"
folder=${folder%????} # remove last 4 character
echo "Checking $folder.zip ..."
python3 check-files.py --zip-file $folder.zip ./$folder/required-files.yml # check-files for ***.zip with check-files.py
exit 1 # close programm
elif [[ "${folder:0-1}" =~ '/'$ ]] ; then # check if last char is '/'
folder=${folder%?} # remove last char
fi
echo "Checking $folder ..."
cd $folder # change to folder
python3 ../check-files.py required-files.yml # check files from folder
echo
while true; do # ask as long as first char is not nN or yY
read -p "Do you wish to zip the folder $folder[y/n]?" yn # ask if ***.zip should be generated
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo
if [ -f ../$folder".zip" ]; then # check if ***.zip already exist
echo -e "deleting $folder.zip ...\n"
rm "../$folder.zip" # delete if already exists
fi
echo "creating $folder.zip..."
zip -r ../$folder . -x required-files.yml # creat zip without required-files.yml
cd .. # return from folder
echo -e "\nChecking $folder.zip ..."
python3 check-files.py --zip-file $folder.zip ./$folder/required-files.yml # check new ***.zip with check-files.py
exit 1