diff options
author | Jon Clausen <jac@nordu.net> | 2018-12-06 15:40:04 +0100 |
---|---|---|
committer | Jon Clausen <jac@nordu.net> | 2018-12-06 15:40:04 +0100 |
commit | 94184765b075e0afef0846c3e187e6b1d1759078 (patch) | |
tree | 82569e6fe6dcec8faa0c90f10e9bbf4692ee90a0 | |
parent | 828ca202f73d2eb6aeb21ba118a0b79eb2ccdd9d (diff) |
added vlanscrape-wrapper
-rwxr-xr-x | code/vlanscrape-wrapper | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/code/vlanscrape-wrapper b/code/vlanscrape-wrapper new file mode 100755 index 0000000..250d477 --- /dev/null +++ b/code/vlanscrape-wrapper @@ -0,0 +1,56 @@ +#!/bin/sh +# +# simple script to call the 'vlanscrape' script, check if there are changes +# in the output directory, and `git add . ; git commit -m "msg" ; git push` +# if there are + +# call the script +/usr/local/bin/vlanscrape + +cd /home/vlanscrape/git/git.nordu.net/vlanscrape-data + +TmpFile=$(mktemp) +if [ -z $TmpFile ] +then + echo "cannot create temp file, giving up on versioning vkanscrape data" + exit 1 +fi + +git status --porcelain=1 >$TmpFile + +FilesAdded=$(grep -E '^??' $TmpFile | wc -l) +FilesAdded=$(echo $FilesAdded | cut -f 1 -d \ ) +FilesModified=$(grep -E '^ M' $TmpFile | wc -l) +FilesModified=$(echo $FilesModified | cut -f 1 -d \ ) +Something=$(wc -l $TmpFile) +Something=$(echo $Something | cut -f 1 -d \ ) + +if [ $Something -ne 0 ] +then + if [ $FilesAdded -ne 0 ] + then + CommitMsg = "File addition" + fi + if [ $FilesModified -ne 0 ] + then + if [ -z $CommitMsg ] + then + CommitMsg = "File modification" + else + CommitMsg = "$CommiMsg and modification" + fi + fi + if [ -z $CommitMsg ] + then + CommitMsg = "something changed" + fi +fi + +if [ -z $CommitMsg ] +then + exit 0 +fi + +git add . +git commit -m "$CommitMsg" +git push |