Newer
Older
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
help() {
echo "Usage: $1 <options>"
echo " -c : Clean capif services tmp files"
echo " -m : Clean monitoring service tmp files"
echo " -t : Clean robot-test service tmp files"
echo " -d : Clean docs folder tmp files"
echo " -a : Clean all tmp files"
echo " -h : show this help"
exit 1
}
if [[ $# -lt 1 ]]
then
echo "You must specify an option before run script."
help
fi
FILES=()
echo "${FILES[@]}"
# Read params
while getopts "cmtdah" opt; do
case $opt in
c)
echo "Remove capif services temporary files"
FILES+=("services")
;;
m)
echo "Remove monitoring service temporary files"
FILES+=("monitoring")
;;
t)
echo "Remove robot-test service temporary files"
FILES+=("tests")
;;
d)
echo "Remove docs folder temporary files"
FILES+=("docs")
;;
a)
echo "Remove all temporary files"
FILES=("services" "monitoring" "tests" "docs")
;;
h)
help
;;
\?)
echo "Not valid option: -$OPTARG" >&2
help
exit 1
;;
:)
echo "The -$OPTARG option requires an argument." >&2
help
exit 1
;;
esac
done
echo "after check"
echo "${FILES[@]}"
for FILE in "${FILES[@]}"; do
echo "Remove temporary files for $FILE"
sudo rm -r $(git ls-files . --ignored --exclude-standard --others --directory | grep $FILE)
status=$?
if [ $status -eq 0 ]; then
echo "*** Removed tmp files from $FILE ***"
else
echo "*** Some files from $FILE failed on removing ***"
fi
done
cd ./services