#!/bin/bash d=`date +%Y%m%d` log2file() { echo "sh: $1" >> "log/$d.log" } error_exit() { log2file "Error: $1" exit 1 } touch "log/$d.log" echo "log: $d" >> "log/$d.log" log2file "Starting update.sh" fromdate=$(ls -1 *_latest.mcl |grep -Eo '[[:digit:]]{8}') || error_exit "cannot latest mcl file" 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/" "*" >> "log/$d.log" || error_exit "cannot git add" git commit -m "Updated $d" >> "log/$d.log" || error_exit "cannot git commit" git push origin master >> "log/$d.log" || error_exit "cannot git push"