-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall.sh
More file actions
157 lines (124 loc) · 4.74 KB
/
Copy pathinstall.sh
File metadata and controls
157 lines (124 loc) · 4.74 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
plain='\033[0m'
NC='\033[0m'
BOLD='\033[1m'
cur_dir=$(pwd)
if [[ $EUID -ne 0 && $(hostname) != "localhost" && $(hostname) != "127.0.0.1" ]]; then
echo -e "${RED}Fatal error: ${plain} Please run this script with root privilege \n"
exit 1
fi
install_jq() {
if ! command -v jq &> /dev/null; then
if command -v apt-get &> /dev/null; then
echo -e "${RED}jq is not installed. Installing...${NC}"
sleep 1
apt-get update
apt-get install -y jq
else
echo -e "${RED}Error: Unsupported package manager. Please install jq manually.${NC}\n"
read -p "Press any key to continue..."
exit 1
fi
fi
}
menu(){
install_jq
clear
# Get server IP
SERVER_IP=$(hostname -I | awk '{print $1}')
# Fetch server country using ip-api.com
SERVER_COUNTRY=$(curl -sS "http://ip-api.com/json/$SERVER_IP" | jq -r '.country')
# Fetch server isp using ip-api.com
SERVER_ISP=$(curl -sS "http://ip-api.com/json/$SERVER_IP" | jq -r '.isp')
Docker_CORE=$(check_docker_installed)
echo "*---------------------------------------------------------------------------------------------*"
echo "| _____ _____ _____ ____ _____ _ __ ______ _____ |"
echo "| |_ _| | __ \ | __ \ / __ \ / ____| | |/ / | ____| | __ \ |"
echo "| | | | |__) | | | | | | | | | | | | ' / | |__ | |__) | |"
echo "| | | | _ / | | | | | | | | | | | < | __| | _ / @ALEFBEMEDIA |"
echo "| _| |_ | | \ \ | |__| | | |__| | | |____ | . \ | |____ | | \ \ join telegram channel |"
echo "| |_____| |_| \_\ |_____/ \____/ \_____| |_|\_\ |______| |_| \_\ |"
echo "*---------------------------------------------------------------------------------------------*"
echo -e "|${GREEN}Server Country |${NC} $SERVER_COUNTRY"
echo -e "|${GREEN}Server IP |${NC} $SERVER_IP"
echo -e "|${GREEN}Server ISP |${NC} $SERVER_ISP"
echo -e "|${GREEN}Server Docker |${NC} $Docker_CORE"
echo "*---------------------------------------------------------------------------------------------*"
echo -e "|${YELLOW}Please choose an option:${NC}"
echo "*---------------------------------------------------------------------------------------------*"
echo -e $1
echo "*---------------------------------------------------------------------------------------------*"
echo -e "\033[0m"
}
loader(){
menu "| 1 - Install Docker (method 1) ${YELLOW}${BOLD}Slow / Recommended ✅${NC} \n|\n| 2 - Install Docker (method 2) ${YELLOW}${BOLD}Fast / NOT Recommended ⚠️${NC} \n|\n| 0 - Exit"
read -p "Enter option number: " choice
case $choice in
1)
install_command_1
;;
2)
install_command_2
;;
0)
echo -e "${GREEN}Exiting program...${NC}"
exit 0
;;
*)
echo "Not valid"
;;
esac
}
install_command_1(){
# disable systemd-resolved and set dns
systemctl stop systemd-resolved
systemctl disable systemd-resolved
bash -c 'echo -e "nameserver 178.22.122.100\nnameserver 185.51.200.2" > /etc/resolv.conf'
# Install Requirements
apt-get update; apt-get upgrade -y; apt-get install curl socat git -y
# python installer
rm install.py
wget https://raw.githubusercontent.com/AlefbeMedia/irDocker/refs/heads/main/install.py
python3 install.py
rm install.py
# Check Docker version
docker --version
# set back dns
systemctl enable systemd-resolved
systemctl start systemd-resolved
bash -c 'echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4" > /etc/resolv.conf'
}
install_command_2(){
# Install Requirements
apt-get update; apt-get upgrade -y; apt-get install curl socat git -y
# snap check
if ! command -v snap &> /dev/null; then
echo "snapd is not installed. Installing snapd..."
apt install snapd
fi
# Install Docker using snap
echo "Installing Docker using snap..."
snap install docker
# Check Docker version
docker --version
# set mirror list docker
bash -c 'cat > /var/snap/docker/current/config/daemon.json <<EOF
{
"insecure-registries" : ["https://docker.arvancloud.ir"],
"registry-mirrors": ["https://docker.arvancloud.ir"]
}
EOF'
# restart docker
snap restart docker
}
check_docker_installed() {
if command -v docker &> /dev/null; then
echo -e "${GREEN}✅ Docker is installed.${NC}"
else
echo -e "${RED}❌ Docker is not installed.${NC}"
fi
}
loader