-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall-requirements.sh
executable file
·110 lines (88 loc) · 5.17 KB
/
install-requirements.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
#!/bin/bash
# Set some colors
CNT=$(tput setaf 7)$(tput bold)"["$(tput sgr0)$(tput setaf 6)$(tput bold)NOTE$(tput sgr0)$(tput setaf 7)$(tput bold)"]"$(tput sgr0)
COK=$(tput setaf 7)$(tput bold)"["$(tput sgr0)$(tput setaf 2)$(tput bold)OK$(tput sgr0)$(tput setaf 7)$(tput bold)"]"$(tput sgr0)
CER=$(tput setaf 7)$(tput bold)"["$(tput sgr0)$(tput setaf 1)$(tput bold)ERROR$(tput sgr0)$(tput setaf 7)$(tput bold)"]"$(tput sgr0)
CAT=$(tput setaf 7)$(tput bold)"["$(tput sgr0)$(tput setaf 7)$(tput bold)ATTENTION$(tput sgr0)$(tput setaf 7)$(tput bold)"]"$(tput sgr0)
CWR=$(tput setaf 7)$(tput bold)"["$(tput sgr0)$(tput setaf 5)$(tput bold)WARNING$(tput sgr0)$(tput setaf 7)$(tput bold)"]"$(tput sgr0)
CAC=$(tput setaf 7)$(tput bold)"["$(tput sgr0)$(tput setaf 3)$(tput bold)ACTION$(tput sgr0)$(tput setaf 7)$(tput bold)"]"$(tput sgr0)
CIN=$(tput setaf 7)$(tput bold)"["$(tput sgr0)$(tput setaf 4)$(tput bold)INPUT$(tput sgr0)$(tput setaf 7)$(tput bold)"]"$(tput sgr0)
CDE=$(tput setaf 7)$(tput bold)"["$(tput sgr0)$(tput setaf 7)$(tput bold)DEBUG$(tput sgr0)$(tput setaf 7)$(tput bold)"]"$(tput sgr0)
CPR=$(tput setaf 7)$(tput bold)"["$(tput sgr0)$(tput setaf 7)$(tput bold)PROGRESS$(tput sgr0)$(tput setaf 7)$(tput bold)"]"$(tput sgr0)
echo "##########################################################"
echo "### SCRIPT TO INSTALL ALL REQUIREMENTS ###"
echo "### LINUX VERSION ###"
echo "### ###"
echo "### MADE WITH LOVE BY 'Luciousdev' ###"
echo "### luciousdev.nl ###"
echo "##########################################################"
log_file="pip-install.log"
# Function to log output to the log file
log() {
echo -e "$1" | tee -a "$log_file"
}
# Function to handle errors
handle_error() {
local argument=$1
if [ $argument == "pip" ]; then
log "$CER - An error occurred during the pip installation. Try running the script again with the break-system-packages enabled. Exiting..."
exit 1
else
log "$CER - An error occurred. Exiting..."
exit 1
fi
}
if [ -f /etc/os-release ]; then
. /etc/os-release
# Check the value of the ID variable for Arch-based distributions
if [[ "$ID" == "arch" || "$ID_LIKE" == *"arch"* ]]; then
log "$CNT - Detected Arch-based Linux distribution"
if ! command -v yay &> /dev/null; then
log "$CAT - yay is not installed. Installing..."
# Install yay using yay's official installation command
sudo pacman -S --needed git base-devel ffmpeg && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si || handle_error
log "$COK - successfully installed yay. Continuing with the script."
fi
log "$CNT - yay is already installed"
# Check if Python is installed
if ! command -v python &> /dev/null; then
log "$CWR - Python is not installed. Installing Python..."
yay -S --noconfirm python3 || handle_error
log "$COK - Python is successfully installed."
fi
# Check if Pip is installed
if ! command -v pip &> /dev/null; then
log "$CWR - pip is not installed. Installing Pip..."
yay -S --noconfirm python-pip || handle_error
log "$COK - pip is successfully installed."
fi
if ! command -v ani-cli &> /dev/null; then
log "$CWR - ani-cli is not installed. Installing Pip..."
yay -S --noconfirm ani-cli || handle_error
log "$COK - ani-cli is successfully installed."
fi
# Install packages from requirements.txt using Pip
if command -v pip &> /dev/null; then
log "$CWR - Installing Python packages from requirements.txt..."
pip install --break-system-packages -r requirements.txt || handle_error
pip install git+https://github.com/openai/whisper.git --break-system-packages || handle_error
else
log "$CER - pip installation failed. Please install Pip manually and run 'pip install -r requirements.txt'."
fi
elif [[ "$ID" == "debian" || "$ID_LIKE" == *"debian"* ]]; then
log "$CNT - Detected Debian-based Linux distribution"
sudo apt-get update
sudo apt-get install -y python3-pip python3 portaudio19-dev mpv || handle_error
log "$COK - Installation of python, pip and or the needed packages were successfull."
# Install packages from requirements.txt using Pip
if command -v pip &> /dev/null; then
log "$CWR - Installing Python packages from requirements.txt..."
pip install --break-system-packages -r requirements.txt || handle_error
else
log "$CER - pip installation failed. Please install Pip manually and run 'pip install -r requirements.txt'."
fi
log "$CWR - Ani-cli NEEDS TO BE INSTALLED MANUALLY. Please install it manually using the guide on their github. We won't be installing it automatically since it requires adding the unstable repository to your system."
fi
fi
log "$COK - Installation of python, pip and or the needed packages were successfull."
exit 0