forked from zrml/CPF-merge-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteDurableSYS.sh
executable file
·81 lines (69 loc) · 1.5 KB
/
deleteDurableSYS.sh
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
#
# Assumptions:
# 1) everything is driven from this working directory
# 2) Durable %SYS are in ./iris.sys.d1, ./iris.sys.d2, etc.
#
WDIR=$(pwd)
printf "pwd=%s" $WDIR
# delete all Durable %SYS dirs
function deleteDurableSYSs()
{
cd $IDIR
printf "Deleting files and sub-dirs in \"%s\"... \n" $IDIR
sudo rm -r -f *
if [ $? -eq 0 ]
then
printf "Done.\n"
else
printf "There are issues...\n"
exit 1
fi
# back home & delete the directory
cd $WDIR
printf "Deleting directory \"%s\"... " $IDIR
sudo rmdir $IDIR
if [ $? -eq 0 ]
then
printf "Done.\n"
else
printf "There are issues...\n"
exit 1
fi
}
# work out the directories to delete
#
# directory name format
# single iris instance (via run.sh) = ./iris.sys.d
# multiple iris with docker-compose = ./iris.sys.d1, iris.sys.d2, etc.
#
function workoutDirs()
{
for IDIR in $(ls -d iris.sys*)
do
if [ -d $IDIR ]
then
printf "\nDeleting EVERYTHING in directory \"%s\"\n" $IDIR
read -p "OK? (Y/N) " YNans
case $YNans in
[Yy]* ) deleteDurableSYSs
;;
[Nn]* ) printf "OK, everything left untouched.\n"
;;
* ) printf "\nUnclear answer. Leaving all as is.\n"
;;
esac
else
printf "\nDirectory \"%s\" does not exist." $IDIR
printf "\nNothing to delete or check the value of \$IDIR.\n"
fi
done
}
function main()
{
# work out the possible Durable %SYS directories and delete them
workoutDirs
}
# starting
main
## end