forked from dennyzhang/cheatsheet-docker-A4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer-install-devkit.sh
executable file
·71 lines (61 loc) · 1.88 KB
/
container-install-devkit.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
## @copyright 2018 DennyZhang.com
## Licensed under MIT
## https://www.dennyzhang.com/wp-content/mit_license.txt
##
## File: container_install_devkit.sh
## Author : Denny <https://www.dennyzhang.com/contact>
## Description : https://cheatsheet.dennyzhang.com/cheatsheet-docker-A4
## --
## Created : <2018-07-10>
## Updated: Time-stamp: <2018-11-23 21:39:12>
##-------------------------------------------------------------------
set -ex
function os_release() {
# Sample:
# os_release -> ubuntu
# os_release true -> ubuntu-14.04
local show_version=${1:-"false"}
set -e
os_type=""
if which lsb_release 1>/dev/null 2>/dev/null; then
distributor_id=$(lsb_release -a 2>/dev/null | grep 'Distributor ID' | awk -F":\t" '{print $2}')
if [ "$distributor_id" == "RedHatEnterpriseServer" ]; then
os_type="redhat"
fi
if [ "$distributor_id" == "Ubuntu" ]; then
os_type="ubuntu"
fi
fi
if grep CentOS /etc/issue 1>/dev/null 2>/dev/null; then
os_type="centos"
fi
if grep Debian /etc/issue 1>/dev/null 2>/dev/null; then
os_type="debian"
fi
if grep Ubuntu /etc/issue 1>/dev/null 2>/dev/null; then
os_type="ubuntu"
fi
if uname -a | grep '^Darwin' 1>/dev/null 2>/dev/null; then
os_type="osx"
fi
if [ -z "$os_type" ]; then
echo"ERROR: Not supported OS"
exit 1
fi
if [ "$show_version" = "true" ]; then
release_version=$(lsb_release -a 2>/dev/null | grep 'Release' | awk -F":\t" '{print $2}')
echo "${os_type}-${release_version}"
else
echo "$os_type"
fi
}
function ubuntu_install_devkit {
echo "Install tools in ubuntu"
apt -y update
apt-get install -y netcat lsof
}
if [ "$os_release_name" == "ubuntu" ]; then
ubuntu_install_devkit
fi
## File: container_install_devkit.sh ends