-
Notifications
You must be signed in to change notification settings - Fork 0
/
kill_all.sh
executable file
·35 lines (29 loc) · 954 Bytes
/
kill_all.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
#!/bin/bash
local_root_path=$(readlink -f $(dirname "$0"))
source $local_root_path/run_conf.sh
function delete_confirm(){
confirmation="N"
echo -e $SHDOL"docker rm $disposable_containers_list"
echo -n -e $GREEN"\nProceed with deleting the following containers ? "$END_C" $disposable_containers_list "
[[ -t 0 ]] && # If tty => prompt the question
read -n 1 -p \
$'(Y/n) ' confirmation
if [[ $confirmation =~ ^(y|Y|)$ ]] # Do if 'y', 'Y' or empty
then
echo -e $SHDOL"docker rm $disposable_containers_list"
docker rm $disposable_containers_list && \
return 0
else
return 0
fi
return 1
}
now=`date --rfc-3339=second | sed 's/ /T/'`
echo -e $SHDOL"./stop_all.sh"
./stop_all.sh && \
delete_confirm() && \
echo -e $SHDOL"docker rename $mysql_cont_name $mysql_cont_name""_$now" && \
docker rename $mysql_cont_name $mysql_cont_name"_"$now && \
echo -e $GREEN"SUCCESS"$END_C && exit 0
echo -e $RED"FAILURE"$END_C
exit 1