-
Notifications
You must be signed in to change notification settings - Fork 1
/
idocker.sh
75 lines (70 loc) · 1.87 KB
/
idocker.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
#!/bin/bash
#
# Automatic Install Docker & Docker-compose [Ubuntu or CentOs]
#
# Tested on Ubuntu 16.04 & CentOs 7
# @Author : Rafsanzani Suhada
# @Github : github.com/suhada99
UbuntuIdocker(){
# Add Repository
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add > /dev/null
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# Update
apt-get update
# Install docker-ce
apt-get install docker-ce
# Install PIP
apt install python-pip
# Install docker-compose
pip install docker-compose
echo ""
echo "[ ! ] Docker Version [ ! ]"
docker -v
echo ""
echo "[ + ] Add your username to the docker group [ + ]"
echo "$ sudo usermod -aG docker ${USER}"
}
CentOsIdocker(){
# Install needed packages
yum install -y yum-utils device-mapper-persistent-data lvm2
# Configure the docker-ce repo:
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install docker-ce
yum install docker-ce
# Set start Automatic
systemctl enable docker.service
# Start docker service
systemctl start docker.service
# Install needed packages
yum install epel-release
# Install PIP
yum install -y python-pip
# Install docker-compose
pip install docker-compose
echo ""
echo "[ ! ] Docker Version [ ! ]"
docker -v
echo ""
echo "[ + ] Add your username to the docker group [ + ]"
echo "$ sudo usermod -aG docker ${USER}"
}
Validasi(){
# Validasi Operasi Sistem
ceKOs=$(cat /etc/*release)
if [[ $ceKOs =~ 'ubuntu' ]]; then
# Jika OS Ubuntu
echo " [ ! ] Your system operation Ubuntu [ ! ]"
UbuntuIdocker
elif [[ $ceKOs =~ 'centos' ]]; then
# Jika OS CentOs
echo " [ ! ] Your system operation CentOs [ ! ]"
CentOsIdocker
fi
}
# Membutuhkan akses root
ceKRoot=$(whoami)
if [[ $ceKRoot =~ 'root' ]]; then
Validasi
else
echo "[ X ] Requires root for running tools [ X ]"
fi