Created
November 24, 2023 00:27
-
-
Save r0mdau/eb56d512022047a3df6b51a75d41f113 to your computer and use it in GitHub Desktop.
Revisions
-
r0mdau created this gist
Nov 24, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ #!/bin/bash # Enable debug mode set -x # Log function log() { echo "[INFO] $1" } logexit() { echo "[ERROR] $1 Exiting..." exit 1 } # Trap cleanup() { log "Cleaning up temporary files..." rm -f /tmp/website } # Trap the EXIT signal and call the cleanup function trap cleanup EXIT # Check if curl is installed log "Checking if curl is installed..." if ! command -v curl &> /dev/null; then logexit "curl command is not installed." fi # Download the website log "Downloading the website..." curl -s -o /tmp/website/index.html https://cv.romaindauby.fr # Check if the download was successful log "Checking if the download was successful..." if [ $? -ne 0 ]; then logexit "An error occurred while downloading the website." fi # Exit with success log "Script completed successfully." exit 0