-
Notifications
You must be signed in to change notification settings - Fork 7
/
install.sh
104 lines (67 loc) · 2.02 KB
/
install.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
#!/bin/sh
sudo apt update -y
ABSOLUTE_FILENAME=`readlink -e "$0"`
DIRECTORY=`dirname "$ABSOLUTE_FILENAME"`
IP=`wget -qO- ipv4.icanhazip.com`
INSTALL_ROOT="/opt/mtprotoproxy"
gitlink="https://github.com/alexbers/mtprotoproxy.git"
SECRET=$1
finish() {
cd $DIRECTORY
echo "MTProxy " > check_file.cfg
echo "\nУстановка MTProxy успешно завершена! Ваша ссылка для подключения:\nhttps://t.me/proxy?server=${IP}&port=1443&secret=dd${SECRET}\n"
exit 0
}
generate() {
if [ -n "$SECRET" ]; then
SECRET=$SECRET; else
SECRET=`head -c 16 /dev/urandom | xxd -ps`
fi
if [ -z `echo $SECRET | grep -x '[[:xdigit:]]\{32\}'` ]; then
echo "Secret должен быть 32-значным ключом, содержащим только HEX-символы"
exit 1
fi
}
install() {
echo ====================================================================================
echo ==START INSTALLING MTPROXY=====START INSTALLING MTPROXY=====START INSTALLING MTPROXY
echo ====================================================================================
generate
CONFIG="PORT = 1443\nUSERS = {\"tg\": \"${SECRET}\"}"
writing(){
cd $INSTALL_ROOT
rm config.py
echo "$CONFIG" > config.py
}
#MTProxy setup
cd /opt
sudo mkdir $INSTALL_ROOT
sudo chown $USER $INSTALL_ROOT
git clone -b master $gitlink
writing
sudo cp $DIRECTORY/MTProxy.service /etc/systemd/system/
sudo systemctl daemon-reload && sudo systemctl restart MTProxy.service && sudo systemctl enable MTProxy.service
finish
}
preinstall() {
sudo apt-get update -y
sudo apt-get -y install htop git
install
}
checkinstallation() {
if [ -e $DIRECTORY/check_file.cfg ]; then
if grep -q "MTProxy" check_file.cfg; then
echo "MTProxy уже установлен на вашем сервере. Установка отменена (для сброса данных о установке введите команду: rm check_file.cfg)"
exit 1
else
if grep -q "SOCKS" check_file.cfg; then
install
else
preinstall
fi
fi
else
preinstall
fi
}
checkinstallation