This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/launch.sh

79 lines
1.6 KiB
Bash
Raw Normal View History

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)
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
PREFIX="$THIS_DIR/.luarocks"
./configure --prefix=$PREFIX --sysconfdir=$PREFIX/luarocks --force-config
RET=$?; if [ $RET -ne 0 ];
then echo "Error. Exiting."; exit $RET;
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
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
}
install() {
2015-04-05 23:01:42 +02:00
git pull
git submodule update --init --recursive
2015-04-05 22:13:50 +02:00
cd tg && ./configure && make
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
if [ ! -f ./tg/telegram.h ]; then
echo "tg not found"
echo "Run $0 install"
exit 1
fi
if [ ! -f ./tg/bin/telegram-cli ]; then
echo "tg binary not found"
echo "Run $0 install"
exit 1
fi
PREFIX="$THIS_DIR/.luarocks"
export LUA_CPATH=";;${PREFIX}/lib/lua/5.2/?.so"
export LUA_PATH=";;${PREFIX}/share/lua/5.2/?.lua;${PREFIX}/share/lua/5.2/?/init.lua"
./tg/bin/telegram-cli -k tg/tg-server.pub -s ./bot/bot.lua -l 1
fi