-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.sh
57 lines (49 loc) · 1.4 KB
/
setup.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
# Check for root privileges
if [ $(echo $PREFIX | wc -c) -lt 2 ] && [ $(id -g) -ne 0 ]; then
echo "This command can only be run with root access."
exit 1
fi
# Install packages using the appropriate package manager
install_packages() {
if [ -f /usr/bin/apt ]; then
apt update
apt install ffmpeg python3-pip
elif [ -f "$PREFIX"/bin/apt ]; then
pkg install ffmpeg python3-pip
pgk install
elif [ -f /usr/bin/pacman ]; then
pacman -S --needed ffmpeg python3-pip
fi
}
# Find the pip command
determine_pip_cmd() {
if [ -f /usr/bin/pip3 ]; then
PIP_CMD="/usr/bin/pip3"
elif [ -f "$PREFIX/bin/pip" ]; then
PIP_CMD="$PREFIX/bin/pip"
else
PIP_CMD="pip3"
fi
echo $PIP_CMD
}
# Install required Python packages
install_python_packages() {
local pip_cmd=$(determine_pip_cmd)
$pip_cmd install -r requirements.txt
}
# Main installation function
main_install() {
install_packages
install_python_packages
SETUP_ROOT="/usr"
if [ $(echo $PREFIX | wc -c) -gt 2 ]; then
SETUP_ROOT=$PREFIX
fi
mkdir -p "$SETUP_ROOT/share/felis" 2>&1
cp felis "$SETUP_ROOT/bin/"
cp -r * "$SETUP_ROOT/share/felis/"
chmod 755 "$SETUP_ROOT/bin/felis"
chmod 755 "$SETUP_ROOT/share/felis/"*
echo "Installation completed successfully. You can use it by typing 'felis' in the terminal."
}
main_install