-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_docker.sh
executable file
·61 lines (50 loc) · 1.57 KB
/
install_docker.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
#!/bin/bash
# Author: Persi.Liao <xiangchu.liao AT gmail.com>
#
# Notes: Linux Took Kit
#
# Project home page:
# https://github.com/persiliao/ltk
cd "$(dirname "$0")" || {
fmt_error "You do not have permission to do this."
exit 1
}
LTK_DIRECTORY="$(pwd)"
. "${LTK_DIRECTORY}/bootstrap.sh"
# Check if user is root
if ! is_root; then
fmt_error "You must be ${FMT_GREEN}root${FMT_RESET} ${FMT_RED}to run this script."
exit 1;
fi
setup_install_docker() {
fmt_tips "Do you want to install Docker? [Y/n] "
read -r opt
case $opt in
y*|Y*|"") LTK_OPT_INSTALL_DOCKER=1;;
n*|N*) fmt_notice "install Docker skipped."; return ;;
*) fmt_notice "Invalid choice. install Docker skipped."; return ;;
esac
yum remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --enable docker-ce-nightly
yum update -y
yum makecache
if yum install -y docker-ce docker-ce-cli containerd.io; then
fmt_information "Docker install successfully."
fi
}
setup_systemctl_service_restart() {
if [ ${LTK_OPT_INSTALL_DOCKER} -eq 1 ]; then
systemctl enable docker.service
systemd_service_restart "docker.service"
fi
}
main() {
if ! check_in_docker; then
setup_install_docker
setup_systemctl_service_restart
fi
}
main "$@"