-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.sh
145 lines (134 loc) · 3.61 KB
/
start.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
THIS_DIR=$(cd $(dirname $0); pwd)
cd $THIS_DIR
gray() {
printf '\e[1;30m%s\n\e[0;39;49m' "$@"
}
red() {
printf '\e[1;31m%s\n\e[0;39;49m' "$@"
}
green() {
printf '\e[1;32m%s\n\e[0;39;49m' "$@"
}
brown() {
printf '\e[1;33m%s\n\e[0;39;49m' "$@"
}
blue() {
printf '\e[1;34m%s\n\e[0;39;49m' "$@"
}
pink() {
printf '\e[1;35m%s\n\e[0;39;49m' "$@"
}
paleblue() {
printf '\e[1;36m%s\n\e[0;39;49m' "$@"
}
white() {
printf '\e[1;37m%s\n\e[0;39;49m' "$@"
}
function logo() {
white " "
green "----------------------------------------------"
red "| ___ ____ __ __ ___ _ _ |"
red "| / _ \ | _ \\\ \ / // _ \ | \ | | |"
red "| / /_\ \ | |_| |\ \/ // /_\ \ ||\\_| | |"
red "| /_/ \_\|____/ \__//_/ \_\|| \__| |"
red "| |"
green "----------------------------------------------"
blue "| CopyRight all right reserved |"
green "----------------------------------------------"
white " "
}
update() {
git pull
install
}
install() {
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get install g++-4.7 -y c++-4.7 -y
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libreadline-dev -y libconfig-dev -y libssl-dev -y lua5.2 -y liblua5.2-dev -y lua-socket -y lua-sec -y lua-expat -y libevent-dev -y make unzip git redis-server autoconf g++ -y libjansson-dev -y libpython-dev -y expat libexpat1-dev -y
sudo apt-get install screen -y
sudo apt-get install tmux -y
sudo apt-get install libstdc++6 -y
sudo apt-get install lua-lgi -y
sudo apt-get install libnotify-dev
#sudo ln -sf /usr/share/zoneinfo/Iran /etc/localtime
sudo apt-get install axel
axel http://luarocks.org/releases/luarocks-2.2.2.tar.gz
tar zxpf luarocks-2.2.2.tar.gz
rm luarocks-2.2.2.tar.gz
cd luarocks-2.2.2
./configure
make build
make install
sudo make bootstrap
sudo apt-get install libnotify-dev -y
sudo luarocks install serpent
sudo luarocks install redis-lua
sudo luarocks install json-lua
sudo luarocks install lua-cjson
cd ..
rm -rf luarocks-2.2.2
}
telegram-cli() {
wget "https://valtman.name/files/telegram-cli-1222"
mv telegram-cli-1222 tgcli
sudo chmod +x tgcli
sleep 1
echo "Done :)"
green "IF you have problem to start bot use: ./${0##*/} fix"
}
fixer() {
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y gcc-4.9 g++-4.9 && sudo update-alternatives —install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 —slave /usr/bin/g++ g++ /usr/bin/g++-4
}
function commands() {
white ""
brown " Usage: $0 [options]"
red " Options:"
white ""
green "install bot ./${0##*/} install"
blue "update bot ./${0##*/} update"
green "fix error ./${0##*/} fix"
green "help (this message) ./${0##*/} help"
blue "on (start with screen) ./${0##*/} on"
white ""
}
if [ "$1" = "install" ]; then
logo
install
telegram-cli
elif [ "$1" = "help" ]; then
logo
commands
elif [ "$1" = "update" ]; then
logo
update
elif [ "$1" = "fix" ]; then
logo
fixer
elif [[ "$1" = "on" ]]; then
if [ ! -f ./tgcli ]; then
brown " >>>>>>>>>>> Tg not found"
red " >>>>>>>>>>> Run $0 install"
exit 1
fi
logo
while true; do
screen ./tgcli -s ./bot.lua
done
if [ ! -f ./tgcli ]; then
brown " >>>>>>>>>>> Tg not found"
red " >>>>>>>>>>> Run $0 install"
exit 1
fi
else
logo
if [ -f ./tgcli ]; then
./tgcli -s ./bot.lua
else
brown " >>>>>>>>>>> Tg not found"
red " >>>>>>>>>>> Run $0 install"
echo ""
fi
fi