#!/bin/bash
readonly APP=/home/sergio/code/bashscript/skyscraper_system.sh
readonly LOG=/home/sergio/cronjobs/cronjobs.log
readonly SYSTEMS_COMPUTERS="amstradcpc amiga atarist c64"
readonly SYSTEMS_OTHER="dreamcast gc nds pcengine psp psx saturn segacd"
TODAY=$(date +"%d-%m-%Y")
readonly TODAY

printf "\n%s (%s, %s)\n" "$(basename "${0}")" "${TODAY}" "$(date +%A)" >>"${LOG}"

# /home/sergio/roms/computer
for SYSTEM in $SYSTEMS_COMPUTERS; do
    NOW=$(date +"%T")
    START=$(date -u +"%s")
    printf "  %-12s %s" "${SYSTEM}:" "${NOW}" >>"${LOG}"

    ${APP} scrap /home/sergio/roms/computer "${SYSTEM}"
    END=$(date -u +"%s")

    ELAPSED=$((END - START))
    E=$(date -ud @$ELAPSED +'%H:%M:%S')

    printf " (%s)\n" "${E}" >>"${LOG}"
done

# /home/sergio/roms/skyscraper
for SYSTEM in $SYSTEMS_OTHER; do
    NOW=$(date +"%T")
    START=$(date -u +"%s")
    printf "  %-12s %s" "${SYSTEM}:" "${NOW}" >>"${LOG}"

    ${APP} scrap /home/sergio/roms/skyscraper "${SYSTEM}"
    END=$(date -u +"%s")

    ELAPSED=$((END - START))
    E=$(date -ud @$ELAPSED +'%H:%M:%S')

    printf " (%s)\n" "${E}" >>"${LOG}"
done

NOW=$(date +"%T")
printf "  end:         %s\n" "${NOW}" >>"${LOG}"
