-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·70 lines (58 loc) · 1.9 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·70 lines (58 loc) · 1.9 KB
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
#!/bin/bash
# shellcheck disable=SC2059
now=$(date +"%T")
g='\033[0;32m'
c='\033[0m'
log_file="autovod_installation.log"
# Log all the outputs of the script to the log file
exec &> >(tee -a "$log_file")
# Check if apt, dnf, or brew is installed
install_command='install'
if command -v apt-get &>/dev/null; then
package_manager='apt-get'
update_command='update'
upgrade_command='upgrade'
check_install='dpkg -s'
elif command -v dnf &>/dev/null; then
package_manager='dnf'
update_command='check-update'
upgrade_command='upgrade'
check_install='rpm -q'
elif command -v brew &>/dev/null; then
package_manager='brew'
update_command='update'
upgrade_command='upgrade'
check_install='brew list -1 | grep -w'
else
printf "${g}[$now] Error: Could not find a supported package manager. Exiting...${c}\n"
exit 1
fi
printf "${g}[$now] Updating and upgrading packages...${c}\n"
$package_manager -qq $update_command && $package_manager -qq $upgrade_command
printf "${g}[$now] Installing necessary packages...${c}\n"
# Package names for different package managers
apt_packages=(python3-pip ffmpeg streamlink)
dnf_packages=(python3-pip ffmpeg streamlink)
brew_packages=(python@3.12 ffmpeg streamlink)
# Use the appropriate package array based on the detected package manager
if [ "$package_manager" = "apt-get" ]; then
packages=("${apt_packages[@]}")
elif [ "$package_manager" = "dnf" ]; then
packages=("${dnf_packages[@]}")
elif [ "$package_manager" = "brew" ]; then
packages=("${brew_packages[@]}")
fi
# Install the packages
for package in "${packages[@]}"; do
$check_install "$package" &>/dev/null
if [ $? -eq 0 ]; then
printf "${g}[$now] $package already installed...${c}\n"
else
sudo $package_manager $install_command "$package" -y
fi
done
# Copy .env.example to .env if .env does not exist
if [ ! -f .env ]; then
cp .env.example .env
printf "${g}[$now] Copied .env.example to .env${c}\n"
fi