summaryrefslogtreecommitdiffstats
path: root/bin/update_dotfiles
blob: 6c45971a51379f08bc190c1808584433235f128d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh -e

dotfiles="$HOME/dotfiles"
epoch_file="$dotfiles/.updated"
epoch_curr=$(date +'%s')
[ -e "$epoch_file" ] && epoch_old=$(<"$epoch_file")
epoch_diff=$(($epoch_curr - ${epoch_old:-0}))
max_time=$((60 * 60 * 24 * 7))

if [ $(($epoch_diff / $max_time)) -ne 0 ]; then
	echo "Updating dotfiles ..."

	cd "$dotfiles"
	git pull --rebase --stat origin master
	echo $epoch_curr > "$epoch_file"
	./install.sh
	cd -

	echo "Finished."
fi