Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # List of dependencies
- dependencies=("yt-dlp" "jq")
- # Temporary file to store timestamps
- timestamp_file="dependency_timestamps.txt"
- # Function to check and install dependencies
- check_and_install() {
- for dep in "${dependencies[@]}"; do
- if ! command -v $dep &> /dev/null; then
- echo "$dep is not installed. Installing..."
- if [ "$dep" == "yt-dlp" ]; then
- sudo apt install yt-dlp -y
- elif [ "$dep" == "jq" ]; then
- sudo apt install jq -y
- fi
- else
- echo "$dep is already installed."
- fi
- done
- }
- # Function to update dependencies
- update_dependencies() {
- echo "Updating Dependencies..."
- sudo apt update && sudo apt upgrade -y
- }
- # Check if the timestamp file exists
- if [ ! -f "$timestamp_file" ]; then
- echo "Timestamp file not found. Creating..."
- touch "$timestamp_file"
- date +%s > "$timestamp_file"
- update_dependencies
- check_and_install
- else
- last_update=$(cat "$timestamp_file")
- current_time=$(date +%s)
- time_diff=$((current_time - last_update))
- # Update dependencies if more than a week has passed (604800 seconds)
- if [ $time_diff -gt 604800 ]; then
- update_dependencies
- check_and_install
- date +%s > "$timestamp_file"
- else
- echo "Dependencies were updated recently. No need to update now."
- fi
- fi
- # Check and install dependencies
- echo "Dependency check and update process completed!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement