]> git.donarmstrong.com Git - bin.git/blob - update_git_repos
add reset usb bus command
[bin.git] / update_git_repos
1 #!/bin/bash
2
3 if [ "x$1" == "xdoit" ]; then
4     # fetch everything
5     git fetch;
6     # figure out if we should pull
7     # 1. no modified files
8     if [ -n "$(git status --porcelain -u no)" ]; then
9         # 2. Not detached head
10         if [ -n "$(git symbolic-ref HEAD)" ]; then
11             # 3. no commits which are not in origin
12             if [ -n "$(git rev-list \"^$(git remote|head -n 1)\" HEAD)" ]; then
13                 # 3. machine is currently inactive for more than 1 hour
14                 if [ "$IDLE_TIME" -gt 3600 ]; then
15                     git pull;
16                 fi;
17             fi;
18         fi;
19     fi;
20
21             
22 else
23     IDLE_TIME=0
24     if which xprintidle >/dev/null 2>&1; then
25         IDLE_TIME=$(($(xprintidle) / 1000 ));
26     fi;
27     IDLE_TIME="$IDLE_TIME" mr -d ~ -j5 run update_git_repos doit;
28 fi;