-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·95 lines (80 loc) · 2.49 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
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
#!/bin/bash
# This script installs the discord bot of "L'Union des Rôlistes"
#UR_Bot © 2020 by "Association Union des Rôlistes & co" is licensed under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA)
#To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/
#Ask a derogation at [email protected]
# Variables
install_folder="/usr/local/src/URbot"
src="src"
bot_pckg_name='bot'
bot_pckg="$src/$bot_pckg_name"
urpy_pckg="$src/urpy"
# TODO better variables
python='python3.8'
venv='/opt/virtualenv/URBot'
bin="$venv/bin/"
service='Bot_Base.service'
requirements="$urpy_pckg/requirements.txt"
# Installs required softwares
sudo apt update
sudo apt install -y $python
sudo apt install -y $python-venv
sudo apt install -y python3-venv
sudo apt install -y $python-dev
sudo apt install -y build-essential
# Creates a python virtualenv
sudo $python -m venv $venv
source $bin/activate
sudo $bin/pip install -r "$requirements"
deactivate
# Copies python code to install folder
sudo mkdir $install_folder
sudo cp -vra "$src/bot" $install_folder
sudo cp -vra "$src/start.py" $install_folder
sudo cp -vra "$src/locale" $install_folder
sudo cp -vra "$src/urpy" $venv/lib/$python/site-packages
# rush
sudo chmod -R 755 $install_folder
sudo chown "$USER" $install_folder
# Copies .service to /etc/systemd/system
sudo cp -v src/$service /etc/systemd/system
sudo systemctl enable $service
echo
# Reads and writes token into root folder
if [ ! -e $install_folder/.bot_token ]; then
echo '------------ TEXT: |~ Veuillez entrer le token du bot : ------------'
read -r bot_token
echo "$bot_token" | sudo tee $install_folder/.bot_token > /dev/null
echo
exit
fi
if [ -e $install_folder/.bot_token ]; then
echo '------------ TEXT: Token déjà saisi ------------'
echo
exit
fi
echo '------------ TEXT: Creation des fichiers de stockage webhook ------------'
echo
# Create 2 files for webhook storing
if [ ! -e $install_folder/wh ]; then
touch $install_folder/wh
chmod 776 $install_folder/wh
exit
fi
if [ ! -e $install_folder/whPrez ]; then
touch $install_folder/whPrez
chmod 776 $install_folder/wh
exit
fi
echo '------------ TEXT: Installation du bot terminée ------------'
echo
echo '------------ TEXT: Begin webserver installation ------------'
echo
apt install -y apache2
apt install -y php
apt install -y libapache2-mod-php # TODO check if necessary
apt install -y php-xml
apt install -y php-curl
a2enmod cgid
systemctl restart apache2
# TODO add user name