-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_env.sh
executable file
·99 lines (85 loc) · 1.63 KB
/
check_env.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
trap 'echo >&2 Ctrl+C captured, exiting; exit 1' SIGINT
PACKAGE_LIST=( docker \
docker-compose \
circleci \
python \
vim \
gcc \
jq \
make
)
VERSION=1.0.0
if [ ! "${EUID}" -eq 0 ] ; then
echo "Error: Pleas do run root!"
exit 1
fi
function usage_exit()
{
cat << EOF
Usage:
$(basename $0) [-d|-v]
$(basename $0) -h
Options:
-h Print this help
-d Exec debug mode
-v Print version
EOF
}
# @param : Err Message
function abort_exit()
{
local status=$?
echo "$@" 1>&2
exit 1
}
function get_os_info()
{
local OS=""
if [ "$(uname)" == 'Darwin' ]; then
OS='Mac'
elif [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
OS='Linux'
elif [ "$(expr substr $(uname -s) 1 10)" == 'MINGW32_NT' ]; then
OS='Cygwin'
fi
if [ ${OS} != "Linux" ]; then
abort_exit "Your OS is not supported! : ${OS}"
fi
}
while getopts hvd OPT
do
case $OPT in
h) usage_exit
;;
d) set -ex
;;
v) echo "$VERSION"
exit 0
;;
\?) usage_exit
;;
esac
done
function main() {
get_os_info
for i in ${PACKAGE_LIST[@]}; do
which ${i} > /dev/null 2>&1
if [ ! $? -eq 0 ]; then
abort_exit "Please install ${i}!"
else
echo "Package ${i} : OK"
fi
usleep 50000
done
DOCKER_VERSION=$(docker --version | awk '{print $3}' | sed -e 's/,$//g')
DOCKER_COMPOSE_VERSION=$(docker-compose --version | awk '{print $3}' | sed -e 's/\,//g')
CIRCLECI_VERSION=$(circleci --version)
MAKE_VERSION=$(make --version | grep GNU | awk '{print $3}')
systemctl status docker.service > /dev/null 2>&1
if [ ! $? -eq 0 ]; then
abrt "Please start the Docker daemon"
fi
}
main "$@"
exit