-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-docker_fedora.sh
executable file
·66 lines (60 loc) · 2.52 KB
/
install-docker_fedora.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
#!/bin/bash
#docker-compose
latest=$(curl --silent "https://api.github.com/repos/docker/compose/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
if [ -f /usr/local/bin/docker-compose ]
then
echo -e ">> $(docker-compose -v) already installed.\n\n>> Checking if any update is available\n"
current=$(docker-compose -v | awk '{print $3}' | tr -d '(,)')
if [ $latest != $current ]
then
echo -e "A newer version $latest is availble .. Installing\n"
sudo curl -L "https://github.com/docker/compose/releases/download/$latest/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod x /usr/local/bin/docker-compose
#sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
echo -e ">> Docker Compose Updated to version $latest"
else
echo -e ">> Docker Compose is up-to-date."
fi
else
echo -e "Docker Compose not found. >>>> Installing \n "
sudo curl -L "https://github.com/docker/compose/releases/download/$latest/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
fi
if [ $(dnf -q list installed docker-ce &>/dev/null && echo "1" || echo "0") -eq 0 ];
then
echo -e ">> DOCKER NOT FOUND -- INSTALLING ...."
echo -e ">> REMOVING OLDER VERSIONS IF EXIST"
sudo dnf remove -y -qq docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
echo -e ">> Installing dnf-plugins-core"
sudo dnf -y -qq install dnf-plugins-core
echo -e ">> Setting Up Stable Repo"
sudo dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo
echo -e ">> Installing docker-ce docker-ce-cli containerd.io \n"
sudo dnf -y install docker-ce docker-ce-cli containerd.io
echo -e ">> Adding $USER to docker group \n"
sudo usermod -aG docker $USER
else
current=`docker -v | awk '{print $3}' | tr -d '(,|.)'`;
echo -e "\n$(docker -v) already Installed\n"
echo -e "Checking if it can be Updated\n"
sudo dnf -y -qq install docker-ce docker-ce-cli containerd.io
updated=`docker -v | awk '{print $3}' | tr -d '(,|.)'`;
if [ $current != $updated ];
then
echo -e "Updatecurrentd to $(docker -v)\n"
else
echo -e "No Update Found!\n"
fi
fi