#!/bin/bash crontabSetupAllAppBackups() { local show_header=$1 local ISCRON=$( (sudo -u $sudo_user_name crontab -l) 2>/dev/null ) # Check to see if installed if [[ "$ISCRON" == *"command not found"* ]]; then isNotice "Crontab is not found. Unable to set up backups." fi # Check to see if crontab is not installed if ! sudo -u $sudo_user_name crontab -l 2>/dev/null | grep -q "cron is set up for $sudo_user_name" > /dev/null 2>&1; then isNotice "Crontab is not set up, skipping until it's found." fi # Check if the database file exists if [ ! -f "$docker_dir/$db_file" ]; then isNotice "Database file not found: $docker_dir/$db_file" fi if [[ $show_header != "false" ]]; then isHeader "Backup Crontab Install" fi local app_names=() while IFS= read -r name; do local app_names+=("$name") done < <(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;") # Check if sqlite3 is available if ! command -v sudo sqlite3 &> /dev/null; then isNotice "sqlite3 command not found. Make sure it's installed." fi # Remove crontab entries for applications with status = 0 (uninstalled) while IFS= read -r name; do local uninstalled_apps+=("$name") done < <(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 0;") for name in "${uninstalled_apps[@]}"; do removeBackupCrontabAppFolderRemoved $name done # Setup crontab entries for installed applications for name in "${app_names[@]}"; do checkBackupCrontabApp $name done crontabClean; isSuccessful "Setting up Crontab backups for application(s) completed." }