Last active
December 7, 2018 05:17
-
-
Save k4yt3x/1555014dad07fcbf6f1bd95cc9f18d0c to your computer and use it in GitHub Desktop.
This is a script that will help you easily deploy MTProxy on a Debian server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# Name: MTProxy Debian Quick Deploy Script | |
# Author: K4YT3X | |
# Date Created: December 3, 2018 | |
# Last Modified: December 7, 2018 | |
version="1.0.1" | |
echo "MTProxy Debian Quick Deploy Script $version" | |
echo "(C) 2018 K4YT3X" | |
echo "Licensed under GNU GPL v3" | |
# Check if user is root | |
if [[ $EUID -ne 0 ]]; then | |
echo -e "\033[0;31mThis script must be run as root\033[0m" | |
exit 1 | |
fi | |
# Generate server options | |
echo -e -n "Hostname/IP address: " | |
read host | |
echo -e -n "Port: " | |
read port | |
if [ -z "$host" ] || [ -z "$port" ] ; then | |
echo -e "Invalid hostname/port" | |
exit 1 | |
fi | |
secret=$(head -c 16 /dev/urandom | xxd -ps) | |
# Download and compile MTProxy | |
echo -e "\033[0;32mDownloading and compiling MTProxy\033[0m" | |
apt-get install git curl build-essential libssl-dev zlib1g-dev | |
git clone https://github.com/TelegramMessenger/MTProxy /tmp/MTProxy | |
make -C /tmp/MTProxy | |
if [ ! -d "/opt/MTProxy" ]; then | |
mkdir /opt/MTProxy | |
fi | |
systemctl is-active --quiet mtproxy && systemctl stop mtproxy | |
cp /tmp/MTProxy/objs/bin/mtproto-proxy /opt/MTProxy/mtproto-proxy | |
rm -rf /tmp/MTProxy | |
# Download Telegram secret and configuration | |
curl -s https://core.telegram.org/getProxySecret -o /opt/MTProxy/proxy-secret | |
curl -s https://core.telegram.org/getProxyConfig -o /opt/MTProxy/proxy-multi.conf | |
# Write service file | |
echo -e "\033[0;32mWriting mtproxy service file\033[0m" | |
cat << __EOF__ > /etc/systemd/system/mtproxy.service | |
[Unit] | |
Description=MTProxy | |
After=network.target | |
[Service] | |
Type=simple | |
WorkingDirectory=/opt/MTProxy | |
ExecStart=/opt/MTProxy/mtproto-proxy -6 -u nobody -p 8888 -H $port -S $secret --aes-pwd /opt/MTProxy/proxy-secret /opt/MTProxy/proxy-multi.conf -M 1 | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
__EOF__ | |
# Reload systemd services | |
systemctl daemon-reload | |
# Start mtproxy serivce | |
systemctl restart mtproxy | |
# Enable mtproxy on startup | |
systemctl enable mtproxy | |
# Display service status | |
systemctl status mtproxy | |
###### Print Results | |
echo -e "\n\033[0;32mInstallation completed\033[0m" | |
echo -e "MTProxy secret: \033[0;32m$secret\033[0m" | |
echo -e "Telegram link: \033[0;32mhttps://t.me/proxy?server=$host&port=$port&secret=$secret\033[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment