#!/bin/bash error_exit() { echo "Error: $1" exit 1 } #source ../.apikey || error_exit "Cannot find apikey" d=`date +%Y%m%d` #mv "missing.mcl" "missing_old.mcl" fromdate=$(ls -1 *_latest.mcl |grep -Eo '[[:digit:]]{8}') || error_exit "cannot latest mcl file" #fromdate2=$(date -d $fromdate +%Y-%m-%d) #d2=`date +%Y-%m-%d` #TEMP="${fromdate}" #TEMP+="_latest.mcl " #TEMP+="${d}" #TEMP+=".mcl " #TEMP+="${api_key} " #TEMP+="${fromdate2} " #TEMP+="${d2}" python2 update_missing.py mv "$d"".mcl" "$d""_latest.mcl" || error_exit "cannot cp $d to latest" mv "$fromdate""_latest.mcl" "archive/""$fromdate"".mcl" || error_exit "cannot mv to archive" git add "$d""_latest.mcl" "archive/" || error_exit "cannot git add" git commit -m "Updated $d" || error_exit "cannot git commit" git push origin master || error_exit "cannot git push"