Skip to content

Instantly share code, notes, and snippets.

@Higgs1
Last active July 12, 2016 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Higgs1/01448cace611ef60c004efa6ac3c1c90 to your computer and use it in GitHub Desktop.
Save Higgs1/01448cace611ef60c004efa6ac3c1c90 to your computer and use it in GitHub Desktop.
Telegram CLI Install Script
#!/usr/bin/env bash
# To install Telegram-CLI, run the command:
# curl -s https://gist.githubusercontent.com/Higgs1/01448cace611ef60c004efa6ac3c1c90/raw | bash /dev/stdin
# Optionally specify an output file, otherwise will default to ./telegram-cli
GIT_REPO='https://github.com/Cojad/tg.git'
LUA='5.2' # LUA Version
PY='3.5' # Python Version
LIB_DEPS="lua${LUA} python${PY} readline config ssl event jansson"
BIN_DEPS="lua${LUA} make git upx|upx-ucl"
for p in $LIB_DEPS; do
BIN_DEPS="$BIN_DEPS lib${p}-dev"
done
if ! dpkg -s $BIN_DEPS &> /dev/null; then
sudo -n true &> /dev/null ||
echo 'Some required packages are not installed, please enter sudo password to continue.'
sudo apt-get install -yy $BIN_DEPS
fi
export CFLAGS='-march=native -O3 -pipe -s'
DIR="$(mktemp -d)"
( cd "$DIR" &&
git clone --recursive "$GIT_REPO" . &&
sed -e s/-Werror//g -i Makefile.in && # Hack to remove -Werror
./configure --enable-python=$PY &&
make -j$(nproc) &&
strip -S --strip-unneeded -R .comment -R .note* bin/telegram-cli &&
upx --brute -9 bin/telegram-cli
) &&
install -Dm755 "$DIR/bin/telegram-cli" "${1:-.}"
rm -rf "$DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment