update
This commit is contained in:
parent
7e8a24f699
commit
dbf509646d
1 changed files with 17 additions and 1 deletions
|
@ -164,14 +164,21 @@ setup_docker_repo() {
|
|||
# Set proper permissions
|
||||
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
||||
|
||||
# Remove any existing Docker repository file
|
||||
sudo rm -f /etc/apt/sources.list.d/docker.list
|
||||
|
||||
# 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"
|
||||
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
|
||||
|
||||
# Display the repository configuration for verification
|
||||
echo "Created repository configuration:"
|
||||
cat /etc/apt/sources.list.d/docker.list
|
||||
|
||||
# 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"
|
||||
|
@ -219,6 +226,14 @@ setup_docker_user() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Function to clean up in case of failure
|
||||
cleanup_repo() {
|
||||
echo "Cleaning up repository files..."
|
||||
sudo rm -f /etc/apt/sources.list.d/docker.list
|
||||
sudo rm -f /etc/apt/keyrings/docker.gpg
|
||||
echo -e "Repository cleanup completed $CHECK_MARK"
|
||||
}
|
||||
|
||||
# Remove the script itself
|
||||
remove_script() {
|
||||
if [ -f "$0" ]; then
|
||||
|
@ -264,6 +279,7 @@ if ! format_output install_dependencies "Installing Dependencies"; then
|
|||
fi
|
||||
|
||||
if ! format_output setup_docker_repo "Setting up Docker Repository"; then
|
||||
format_output cleanup_repo "Cleaning up failed repository setup"
|
||||
success=1
|
||||
exit $success
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue