49 lines
1.1 KiB
Bash
Executable File
49 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m'
|
|
|
|
# Print commands
|
|
print_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Creating virtualenv
|
|
if ! python3 -m venv .compteur_electrique_env; then
|
|
print_error "Python3 returnded a non-zero error code during virtualenv creation"
|
|
fi
|
|
|
|
# Activate python vitualenv to install librairies
|
|
source .compteur_electrique_env/bin/activate
|
|
|
|
# Install librairies
|
|
if ! pip install discord.py; then
|
|
print_error "Pip returned a non-zero error code during installation of discord.py"
|
|
exit 1
|
|
fi
|
|
if ! pip install python-dotenv; then
|
|
print_error "Pip returned a non-zero error code during installation of python-dotenv"
|
|
exit 1
|
|
fi
|
|
|
|
# Quit python virtualenv
|
|
deactivate
|
|
|
|
# Create launch file
|
|
cat > launch.sh << 'EOF'
|
|
# Activate python vitualenv to install librairies
|
|
source .compteur_electrique_env/bin/activate
|
|
|
|
# Launch bot
|
|
.compteur_electrique_env/bin/python3 src/main.py
|
|
EOF
|
|
chmod +x launch.sh
|
|
|
|
echo -e "\nPython configuration created execute launch.sh to launch discord bot."
|