update
This commit is contained in:
parent
0016219ca6
commit
7e8a24f699
1 changed files with 50 additions and 7 deletions
|
@ -88,15 +88,58 @@ check_os_version() {
|
||||||
|
|
||||||
# Function to install dependencies
|
# Function to install dependencies
|
||||||
install_dependencies() {
|
install_dependencies() {
|
||||||
sudo apt-get update > /dev/null 2>&1
|
local install_output
|
||||||
sudo apt-get install -y ca-certificates curl gnupg > /dev/null 2>&1
|
local update_output
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
echo -e "Dependencies installed $CHECK_MARK"
|
# Update package lists with error handling
|
||||||
return 0
|
echo "Updating package lists..."
|
||||||
else
|
update_output=$(sudo apt-get update 2>&1)
|
||||||
echo -e "Failed to install dependencies $CROSS_MARK"
|
if [ $? -ne 0 ]; then
|
||||||
|
echo -e "Failed to update package lists $CROSS_MARK"
|
||||||
|
echo "Error output: $update_output"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if packages are already installed
|
||||||
|
local missing_packages=()
|
||||||
|
local packages=("ca-certificates" "curl" "gnupg" "apt-transport-https" "software-properties-common")
|
||||||
|
|
||||||
|
for pkg in "${packages[@]}"; do
|
||||||
|
if ! dpkg -l | grep -q "^ii $pkg "; then
|
||||||
|
missing_packages+=("$pkg")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# If all packages are installed, return success
|
||||||
|
if [ ${#missing_packages[@]} -eq 0 ]; then
|
||||||
|
echo -e "All required packages are already installed $CHECK_MARK"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install missing packages
|
||||||
|
echo "Installing missing packages: ${missing_packages[*]}"
|
||||||
|
install_output=$(sudo apt-get install -y "${missing_packages[@]}" 2>&1)
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo -e "Failed to install dependencies $CROSS_MARK"
|
||||||
|
echo "Error output: $install_output"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify installation
|
||||||
|
local failed_packages=()
|
||||||
|
for pkg in "${missing_packages[@]}"; do
|
||||||
|
if ! dpkg -l | grep -q "^ii $pkg "; then
|
||||||
|
failed_packages+=("$pkg")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ${#failed_packages[@]} -gt 0 ]; then
|
||||||
|
echo -e "Failed to install some packages: ${failed_packages[*]} $CROSS_MARK"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "Dependencies installed successfully $CHECK_MARK"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup Docker repository
|
# Function to setup Docker repository
|
||||||
|
|
Loading…
Reference in a new issue