This commit is contained in:
hhftechnologies 2024-11-27 18:21:06 +05:30
parent 83303ccac6
commit 0016219ca6

View file

@ -4,7 +4,7 @@
# VARIABLES #
#-----------------------------------#
this_script_url="https://git.hhf.technology/hhf/script-management-cloudpanel/raw/branch/main/install/docker-install.sh"
this_script_url="https://example.com/docker-install.sh"
this_script_name="Docker Installation Script"
formatter_url="https://git.hhf.technology/hhf/TaskFormatter/raw/branch/main/bash_task_formatter/task_formatter.sh"
scriptname=$0
@ -101,26 +101,42 @@ install_dependencies() {
# Function to setup Docker repository
setup_docker_repo() {
# Create directory for keyrings
# Create directory for keyrings if it doesn't exist
sudo install -m 0755 -d /etc/apt/keyrings
# Download Docker's official GPG key
curl -fsSL https://download.docker.com/linux/$ID/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$ID \
$VERSION_CODENAME stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
if [ $? -eq 0 ]; then
echo -e "Docker repository setup completed $CHECK_MARK"
return 0
else
echo -e "Docker repository setup failed $CROSS_MARK"
# Download Docker's official GPG key with error handling
if ! curl -fsSL "https://download.docker.com/linux/$ID/gpg" -o /tmp/docker.gpg; then
echo -e "Failed to download Docker GPG key $CROSS_MARK"
return 1
fi
# Dearmor and store the GPG key with error handling
if ! sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg /tmp/docker.gpg; then
echo -e "Failed to dearmor GPG key $CROSS_MARK"
rm -f /tmp/docker.gpg
return 1
fi
rm -f /tmp/docker.gpg
# Set proper permissions
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Create the repository configuration with error handling
local repo_config="deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$ID $VERSION_CODENAME stable"
if ! echo "$repo_config" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null; then
echo -e "Failed to create repository configuration $CROSS_MARK"
return 1
fi
# Verify the repository file exists and has content
if [ ! -s /etc/apt/sources.list.d/docker.list ]; then
echo -e "Repository configuration file is empty or missing $CROSS_MARK"
return 1
fi
echo -e "Docker repository setup completed $CHECK_MARK"
return 0
}
# Function to install Docker