c5838f458a8818998e28aed5e0d908bbbe6428d5
[matches/honours.git] / update.sh
1 #!/bin/bash
2
3 # Script to update all the honours stuff on a regular basis
4 # Called by cron(8)
5 # Sam Moore 2012
6
7 # Need to cd to the directory, otherwise nothing will work
8 directory="/home/sam/Documents/University/honours/"
9 cd "$directory" 
10
11 # Need to do this too. Apparently
12 git="/usr/bin/git"
13 eval $(ssh-agent) 2>/dev/null
14 ssh-add /home/sam/.ssh/honours 2>/dev/null
15
16 # This bit plots any open data files, so I can remotely view them
17 gnuplot="/usr/bin/gnuplot"
18 for data in $(lsof | grep interface | grep $(date +%Y) | awk '{print $NF}'); do
19         $gnuplot -e "set term png; set output \"$data.png\"; plot \"$data\" u 1:3 w lp title \"ADC4\", \"$data\" u 1:5 w lp title \"ADC5\""
20 done
21
22 $git pull git.ucc # This is probably a good thing to do...
23
24 $git add update.sh
25 $git add papers
26 $git add research
27 $git add thesis/proposal/*.tex
28 $git add thesis/proposal/*.pdf
29 $git add thesis/proposal/*.bib
30 $git add thesis/*.tex
31 $git add thesis/*.pdf
32 $git add thesis/*.bib
33 $git add course/semester2
34
35 # This sets a commit message and commits. Commit will only be done if there are changed files.
36 fortune="/usr/games/fortune"
37 message=""
38 if [ "$message" == "" ]; then
39         message=$(echo "Automatic commit. $(date)"; echo ""; $fortune; echo "")
40 fi
41 $git commit -m "$message"
42 if [ "$?" == 0 ]; then
43         echo "Commit at $(date)" >> commits.log
44         $git push git.ucc 2>&1 >> commits.log
45 fi
46
47 kill -9 $SSH_AGENT_PID

UCC git Repository :: git.ucc.asn.au