2015-04-05 22:13:50 +02:00
|
|
|
#!/usr/bin/env bash
|
2014-06-30 12:53:15 +02:00
|
|
|
|
2015-04-05 22:13:50 +02:00
|
|
|
THIS_DIR=$(cd $(dirname $0); pwd)
|
2015-04-07 00:27:13 +02:00
|
|
|
cd $THIS_DIR
|
2014-06-30 12:53:15 +02:00
|
|
|
|
2015-04-05 22:13:50 +02:00
|
|
|
update() {
|
|
|
|
git pull
|
|
|
|
git submodule update --init --recursive
|
|
|
|
install_rocks
|
|
|
|
}
|
2014-07-01 22:06:40 +02:00
|
|
|
|
2015-04-05 22:13:50 +02:00
|
|
|
# Will install luarocks on THIS_DIR/.luarocks
|
|
|
|
install_luarocks() {
|
|
|
|
git clone https://github.com/keplerproject/luarocks.git
|
|
|
|
cd luarocks
|
|
|
|
git checkout tags/v2.2.1 # Current stable
|
2015-05-28 16:47:30 +02:00
|
|
|
|
2015-04-05 22:13:50 +02:00
|
|
|
PREFIX="$THIS_DIR/.luarocks"
|
2015-05-28 16:47:30 +02:00
|
|
|
|
2015-04-05 22:13:50 +02:00
|
|
|
./configure --prefix=$PREFIX --sysconfdir=$PREFIX/luarocks --force-config
|
2015-05-28 16:47:30 +02:00
|
|
|
|
2015-04-05 22:13:50 +02:00
|
|
|
RET=$?; if [ $RET -ne 0 ];
|
2015-05-28 16:47:30 +02:00
|
|
|
then echo "Error. Exiting."; exit $RET;
|
2015-04-05 22:13:50 +02:00
|
|
|
fi
|
2014-06-30 12:53:15 +02:00
|
|
|
|
2015-04-05 22:13:50 +02:00
|
|
|
make build && make install
|
|
|
|
RET=$?; if [ $RET -ne 0 ];
|
|
|
|
then echo "Error. Exiting.";exit $RET;
|
|
|
|
fi
|
2015-05-28 16:47:30 +02:00
|
|
|
|
2015-04-05 22:13:50 +02:00
|
|
|
cd ..
|
|
|
|
rm -rf luarocks
|
|
|
|
}
|
|
|
|
|
|
|
|
install_rocks() {
|
|
|
|
./.luarocks/bin/luarocks install luasocket
|
|
|
|
RET=$?; if [ $RET -ne 0 ];
|
|
|
|
then echo "Error. Exiting."; exit $RET;
|
|
|
|
fi
|
|
|
|
|
|
|
|
./.luarocks/bin/luarocks install oauth
|
|
|
|
RET=$?; if [ $RET -ne 0 ];
|
|
|
|
then echo "Error. Exiting."; exit $RET;
|
|
|
|
fi
|
2015-05-28 16:47:30 +02:00
|
|
|
|
|
|
|
./.luarocks/bin/luarocks install redis-lua
|
|
|
|
RET=$?; if [ $RET -ne 0 ];
|
|
|
|
then echo "Error. Exiting."; exit $RET;
|
|
|
|
fi
|
|
|
|
|
|
|
|
./.luarocks/bin/luarocks install lua-cjson
|
|
|
|
RET=$?; if [ $RET -ne 0 ];
|
|
|
|
then echo "Error. Exiting."; exit $RET;
|
|
|
|
fi
|
|
|
|
|
|
|
|
./.luarocks/bin/luarocks install fakeredis
|
|
|
|
RET=$?; if [ $RET -ne 0 ];
|
|
|
|
then echo "Error. Exiting."; exit $RET;
|
|
|
|
fi
|
|
|
|
|
|
|
|
./.luarocks/bin/luarocks install xml
|
|
|
|
RET=$?; if [ $RET -ne 0 ];
|
|
|
|
then echo "Error. Exiting."; exit $RET;
|
|
|
|
fi
|
2015-06-02 21:52:21 +02:00
|
|
|
|
|
|
|
./.luarocks/bin/luarocks install feedparser
|
|
|
|
RET=$?; if [ $RET -ne 0 ];
|
|
|
|
then echo "Error. Exiting."; exit $RET;
|
|
|
|
fi
|
2015-04-05 22:13:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
install() {
|
2015-04-05 23:01:42 +02:00
|
|
|
git pull
|
|
|
|
git submodule update --init --recursive
|
2015-06-08 01:51:09 +02:00
|
|
|
cd tg && ./configure && make
|
2015-04-05 22:13:50 +02:00
|
|
|
RET=$?; if [ $RET -ne 0 ];
|
|
|
|
then echo "Error. Exiting."; exit $RET;
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
install_luarocks
|
|
|
|
install_rocks
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" = "install" ]; then
|
|
|
|
install
|
|
|
|
elif [ "$1" = "update" ]; then
|
|
|
|
update
|
|
|
|
else
|
2015-04-07 00:27:13 +02:00
|
|
|
if [ ! -f ./tg/telegram.h ]; then
|
2015-04-05 22:13:50 +02:00
|
|
|
echo "tg not found"
|
|
|
|
echo "Run $0 install"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-04-07 00:27:13 +02:00
|
|
|
if [ ! -f ./tg/bin/telegram-cli ]; then
|
2015-04-05 22:13:50 +02:00
|
|
|
echo "tg binary not found"
|
|
|
|
echo "Run $0 install"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-04-09 22:27:19 +02:00
|
|
|
|
2015-06-07 22:46:59 +02:00
|
|
|
./tg/bin/telegram-cli -k ./tg/tg-server.pub -s ./bot/bot.lua -l 1 -E --disable-link-preview
|
2015-05-28 16:47:30 +02:00
|
|
|
fi
|