diff --git a/scripts-download.sh b/scripts-download.sh index b526ca7..578a77d 100644 --- a/scripts-download.sh +++ b/scripts-download.sh @@ -146,30 +146,30 @@ echo -e "${GREY}[i] Setting up crontab..." # Add crontabs for FILE in "${FILES[@]}"; do if crontab -l 2>/dev/null | grep -q $FILE; then - echo -e "${LIGHT_BLUE}[i] [$FILE] Crontab already exists. Skipping.${NC}" - else - echo -e "${LIGHT_BLUE}[i] [$FILE] Adding crontab...${NC}" - - if [ "$FILE" == "clean.sh" ]; then - (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE > /dev/null") | crontab - - elif [ "$FILE" == "backup.sh" ]; then - (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE > /dev/null") | crontab - - elif [ "$FILE" == "docker-updater.sh" ]; then - (crontab -l 2>/dev/null; echo "0 3 */4 * * ${CURRENT_WORKDIR}/$FILE > /dev/null") | crontab - - else - echo -e "${YELLOW}[w] [$FILE] Warning: Crontab specific schedule not setup.${NC}" >&2 - (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE" > /dev/null) | crontab - - fi - - echo -e "${GREEN}[✓] [$FILE] Crontab added, double-checking set up...${NC}" - - if ! crontab -l | grep -q $FILE; then - echo -e "${RED}[x] [$FILE] Error: Crontab was not set up.${NC}" >&2 - exit 1 - fi - - echo -e "${GREEN}[✓] [$FILE] Crontab confirmed.${NC}" + echo -e "${LIGHT_BLUE}[i] [$FILE] Crontab already exists. Removing...${NC}" + crontab -l | grep -v $FILE | crontab - fi + echo -e "${LIGHT_BLUE}[i] [$FILE] Adding crontab...${NC}" + + if [ "$FILE" == "clean.sh" ]; then + (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE > /tmp/clean.log") | crontab - + elif [ "$FILE" == "backup.sh" ]; then + (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE > /tmp/backup.log") | crontab - + elif [ "$FILE" == "docker-updater.sh" ]; then + (crontab -l 2>/dev/null; echo "0 3 */4 * * ${CURRENT_WORKDIR}/$FILE > /tmp/docker-updater.log") | crontab - + else + echo -e "${YELLOW}[w] [$FILE] Warning: Crontab specific schedule not setup.${NC}" >&2 + (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE" > /tmp/$FILE.log) | crontab - + fi + + echo -e "${GREEN}[✓] [$FILE] Crontab added, double-checking set up...${NC}" + + if ! crontab -l | grep -q $FILE; then + echo -e "${RED}[x] [$FILE] Error: Crontab was not set up.${NC}" >&2 + exit 1 + fi + + echo -e "${GREEN}[✓] [$FILE] Crontab confirmed.${NC}" done echo -e "${GREEN}[✓] Crontabs all set up.${NC}"