-
Notifications
You must be signed in to change notification settings - Fork 11
/
launch.sh
executable file
·117 lines (105 loc) · 2.66 KB
/
launch.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
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
THIS_DIR=$(cd $(dirname $0); pwd)
RAM=`grep MemTotal /proc/meminfo | awk '{print $2}'`
VBIN=virtualenv-3.4
PYBIN=python
if ! hash $VBIN 2>/dev/null; then
VBIN=virtualenv3
fi
if ! hash $VBIN 2>/dev/null; then
VBIN=virtualenv
fi
if ! hash $VBIN 2>/dev/null; then
echo "You have to install virtualenv"
exit 1
fi
cd $THIS_DIR
update() {
git pull
git submodule update --init --recursive
if [ ! -f ./env/bin/activate ]; then
echo "You need virtualenv in env directory"
echo "Run virtualenv -p python3 env"
exit 1
fi
source env/bin/activate
pip install -r requirements.txt
}
opt_install() {
if [ ! -f ./env/bin/activate ]; then
echo "You need virtualenv in env directory"
echo "Run ./launch.sh install first"
exit 1
fi
source env/bin/activate
pip install -r opt_requirements.txt
}
install_no_lua() {
if [ $RAM -lt 307200 ]; then
./configure --disable-extf --disable-liblua && make
else
./configure --disable-liblua && make
fi
RET=$?
if [ $RET -ne 0 ];then
echo "Error installing tg"; exit $RET;
fi
}
check_python3dev() {
local res=1
for python in python3.4 python3 python; do
local path=`$python -c "from distutils.sysconfig import *; print(get_config_var('CONFINCLUDEPY'))"`
if [[ $path == *"python3.4m"* ]]; then
PYBIN=$python
res=0
fi
done
if [ $res -ne 0 ]; then
echo "You need to install the python 3 libs, in ubuntu: 'sudo apt-get install python3-dev'"
exit 1
fi
}
install() {
check_python3dev
$VBIN -p python3 env
RET=$?
if [ $RET -ne 0 ]; then
echo "Error creating the virtualenv with python 3, check the install instructions"; exit $RET
fi
update
check_python3dev
if [ $RAM -lt 307200 ]; then
cd tg && ./configure --disable-extf && make
else
cd tg && ./configure && make
fi
if [ $? -ne 0 ]; then
install_no_lua
fi
cd ..
}
if [ "$1" = "install" ]; then
install
elif [ "$1" = "update" ]; then
update
elif [ "$1" = "optdeps" ]; then
opt_install
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
if [ ! -f ./env/bin/activate ]; then
echo "You need virtualenv in env directory"
echo "Run virtualenv -p python3 env"
exit 1
fi
source env/bin/activate
./tg/bin/telegram-cli -k ./tg/tg-server.pub -Z bot/bot.py -l 1 -E
fi