forked from ellermister/mtproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmtproxy-entrypoint.sh
48 lines (41 loc) · 1.31 KB
/
mtproxy-entrypoint.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
#!/bin/bash
set -e
/usr/sbin/php-fpm7.4 -R
chmod 777 /etc/nginx/ip_white.conf
chmod 777 /run/php/php7.4-fpm.sock
mtp_config="/home/mtproxy/mtp_config"
init_lock="/home/mtproxy/mtp_config.lock"
set_config(){
if [ "$secret" ] && [[ "$secret" =~ ^[A-Za-z0-9]{32}$ ]]; then
sed -i 's/secret="[0-9A-Za-z]*"/secret="'$secret'"/' $mtp_config
fi
if [ "$tag" ] && [[ "$tag" =~ ^[A-Za-z0-9]{32}$ ]]; then
sed -i 's/proxy_tag="[0-9A-Za-z]*"/proxy_tag="'$tag'"/' $mtp_config
fi
if [ "$domain" ]; then
sed -i 's/domain="[A-z\.\-\d]*"/domain="'$domain'"/' $mtp_config
fi
}
if [ ! -f $init_lock ];then
cp "${mtp_config}.bak" "$mtp_config"
echo 1>"$init_lock"
if [ ! "$secret" ]; then
secret=$(head -c 16 /dev/urandom | xxd -ps)
fi
if [ ! "$ip_white_list" ]; then
ip_white_list='IPSEG'
fi
if [ $ip_white_list == "OFF" ]; then
echo "0.0.0.0/0 1;" >> /etc/nginx/ip_white.conf
fi
echo $ip_white_list > /var/ip_white_list
set_config
fi;
set_config
echo "=================================================="
echo -e "Default port is \033[31m443\033[0m by docker started mtproxy!!!"
echo "=================================================="
cd /home/mtproxy
curl -s https://core.telegram.org/getProxySecret -o proxy-secret
curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf
bash /home/mtproxy/mtproxy.sh start