-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreat_elmmb_docker.sh
113 lines (94 loc) · 3.43 KB
/
creat_elmmb_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
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
OUT_ALERT() {
echo -e "${CYELLOW} $1 ${CEND}"
}
DOCKER_INSTALL() {
docker_exists=$(docker version 2>/dev/null)
if [[ ${docker_exists} == "" ]]; then
OUT_ALERT "[?] 正在安装docker"
curl -fsSL get.docker.com | bash
fi
if false;then
docker_compose_exists=$(docker-compose version 2>/dev/null)
if [[ ${docker_compose_exists} == "" ]]; then
OUT_ALERT "[?] 正在安装docker-compose"
curl -L --fail https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose && \
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
fi
fi
}
DOCKER_UP() {
chmod +x /elmmb
cd /elmmb
docker stop elmmb
docker rm elmmb
docker rmi elmmb
if [ ! -f "/elmmb/Dockerfile" ]; then
wget https://ghproxy.com/https://raw.githubusercontent.com/lu0b0/ELM/main/images/Dockerfile -O /elmmb/Dockerfile
fi
if [[ ${version} != "latest" ]];then
wget https://ghproxy.com/https://github.com/lu0b0/ELM/releases/download/$version/elmmb -O /elmmb/elmmb
fi
if [[ ${version} == "latest" ]];then
wget https://ghproxy.com/https://github.com/lu0b0/ELM/releases/download/$(curl -Ls "https://api.github.com/repos/lu0b0/ELM/releases/latest" |
grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')/elmmb -O /elmmb/elmmb
fi
chmod -R 777 /elmmb
docker build -t='elmmb' .
}
echo -e $"\n欢迎使用饿了么登陆面板Docker一键部署脚本"
read -p "输入Y/y确认安装 跳过安装请直接回车: " CONFIRM
CONFIRM=${CONFIRM:-"N"}
read -p $'\n 输入版本号(默认最新版):' version
version=${version:-"latest"}
read -p "是否需要配置授权config文件(默认配置Y)" cfg
cfg=${cfg:-"Y"}
if [[ ${CONFIRM} == "Y" || ${CONFIRM} == "y" ]];then
if [ ! -d "/elmmb" ]; then
mkdir /elmmb
fi
if [[ ${cfg} == "Y" || ${cfg} == "y" ]];then
if [[ -f "/elmmb/Config.json" ]]; then
echo -e $"\n已发现存在Config文件,是否确认重新配置?(默认N)" cfg2
cfg2=${cfg2:-"N"}
fi
fi
if [[ ${cfg2} == "Y" || ${cfg2} == "y" ]];then
read -p $'\n 输入授权码: ' sqm
sqm=${sqm:-""}
read -p $'\n 输入青龙url: 例:(http://192.168.0.1:5700):' qlurl
qlurl=${qlurl:-""}
read -p $'\n 输入容器CLIENTID: ' CLIENTID
CLIENTID=${CLIENTID:-""}
read -p $'\n 输入容器SECRET: ' SECRET
SECRET=${SECRET:-""}
read -p $'\n 输入wxpusher推送的app_token 获取地址:https://wxpusher.zjiecode.com/admin (不设置推送按回车): ' wxpusher
wxpusher=${wxpusher:-""}
echo "{
\"Authorization\":\"$sqm\",
\"Title\": \"饿了么\",
\"Announcement\": \"公告\",
\"wxpusher_token\":\"$wxpusher\",
\"Config\": [
{
\"QLkey\": 1,
\"QLName\": \"容器1\",
\"QLurl\": \"$qlurl\",
\"QL_CLIENTID\": \"$CLIENTID\",
\"QL_SECRET\": \"$SECRET\",
\"QL_CAPACITY\": 40
}
]
}" > /elmmb/Config.json
fi
DOCKER_INSTALL
DOCKER_UP
fi
read -p "输入容器映射端口: (回车默认为3000)" pp
pp=${pp:-"3000"}
if [[ ${pp} != "3000" || ${pp} != "3000" ]];then
eval "docker run -dit -v /elmmb:/etc/elm -p $pp:3000 --name elmmb --hostname elmmb --restart unless-stopped --restart always elmmb:latest"
else
eval "docker run -dit -v /elmmb:/etc/elm -p 3000:3000 --name elmmb --hostname elmmb --restart unless-stopped --restart always elmmb:latest"
fi
exit 0