-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclean-environment.sh
executable file
·71 lines (63 loc) · 1.59 KB
/
clean-environment.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
#!/usr/bin/env bash
# -*- mode: sh; indent-tabs-mode: nil; sh-basic-offset: 4 -*-
# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=bash
SCRIPT_DIR=$(dirname $0)
SCRIPT_DIR=$(readlink -e ${SCRIPT_DIR})
source ${SCRIPT_DIR}/base
CI_RUN_ENVIRONMENT="standalone"
longopts="run-environment:"
opts=$(getopt -q -o "" --longoptions "${longopts}" -n "$0" -- "$@")
if [ ${?} -ne 0 ]; then
echo "ERROR: Unrecognized option specified: $@"
exit 1
fi
eval set -- "${opts}"
while true; do
case "${1}" in
--run-environment)
shift
CI_RUN_ENVIRONMENT="${1}"
shift
;;
--)
shift
break
;;
*)
echo "ERROR: Unexpected argument [${1}]"
shift
break
;;
esac
done
# validate inputs
validate_ci_run_environment
header="Clean CI environment"
start_github_group "${header}"
echo -e "*** ${header} ***\n"
stop_github_group
header="Removing podman resources (containers and images)"
start_github_group "${header}"
echo -e "### ${header} ###\n"
echo
cmd="podman stop --all"
echo "${cmd}"
${cmd}
cmd="podman rm --all"
echo "${cmd}"
${cmd}
cmd="buildah rm --all"
echo "${cmd}"
${cmd}
cmd="podman rmi --all"
echo "${cmd}"
${cmd}
stop_github_group
header="Removing Crucible installed/created files"
start_github_group "${header}"
echo -e "### ${header} ###\n"
echo
cmd="rm -Rfv /opt/crucible* /var/lib/crucible* /etc/sysconfig/crucible /root/.crucible /etc/profile.d/crucible_completions.sh /home/crucible-containers"
echo "${cmd}"
${cmd}
stop_github_group