-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
69 lines (60 loc) · 1.8 KB
/
install.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
#!/bin/bash
# Variables
vnev_name="vnev"
# Launches the bot if it is installed
if [ -e requirements.txt ] && [ -d $vnev_name ]; then
echo "Launch bot"
$vnev_name/bin/python3 main.py
exit
fi
# Install bot
echo "Start installing"
# Checks if the required programs are installed
echo "Check python"
if [ -z `which python3` ]; then
echo "Python 3 is not found, try installing it with 'apt install python3'"
exit
fi
echo "Check pip"
if [ -z `which pip` ]; then
echo "Pip is not found, try installing it with 'apt install python3-pip'"
exit
fi
echo "Check virtualenv"
if [ -z `which virtualenv` ]; then
echo "Virtualenv is not found, try installing it with 'apt install virtualenv'"
exit
fi
# Creates a virtual environment for the project to avoid library conflicts
echo "Create virtual environment"
virtualenv $vnev_name -q
echo "Done"
# Installs dependencies for the project
echo "Install requirements"
if [ -e requirements.txt ]; then
$vnev_name/bin/pip3 install -q -r "requirements.txt"
else
echo "Can't find the requirements.txt, try downloading the project again"
exit
fi
# Get input from user
echo "Please enter VK token, if you don't have it and you don't know how to get it please read README in FAQ"
read vk_token
echo "OK. Now enter Telegram bot token. Also see FAQ if you don't have it"
read tg_bot_token
echo "And lastly, add the id of the administrator who will have access to the control panel of the bot"
read admin_id
# Create settings.ini file
echo "[Bot]
update_timer = 600
telegram_token = $tg_bot_token
vk_token = $vk_token
database_path = sqlite:///databases/release.db
admin_id = $admin_id
" >> settings.ini
# Offer to run a bot
echo "Installation complete, start the bot? [Y/N]"
read ans
if [ $ans == "Y" ] || [ $ans == "y" ]; then
$vnev_name/bin/python3 main.py
fi