From 8309eb22095c2c7caa680462f7009943b665e272 Mon Sep 17 00:00:00 2001 From: hankhill19580 Date: Thu, 10 Sep 2020 00:05:01 +0000 Subject: [PATCH] make site-updaters that are mtn dependent also work with git. --- etc/update.vars | 5 +++++ findpochanges.sh | 5 ++++- site-updater-i2hq.sh | 38 ++++++++++++++++++++++++++++---------- site-updater.sh | 39 ++++++++++++++++++++++++++------------- 4 files changed, 63 insertions(+), 24 deletions(-) diff --git a/etc/update.vars b/etc/update.vars index 4c3aa5f3..d25e91b5 100644 --- a/etc/update.vars +++ b/etc/update.vars @@ -8,3 +8,8 @@ if [ $(which timeout) ]; then else MTN="mtn" fi + +GITURL="i2pgit.org" +GITBRANCH="i2p.www" + + diff --git a/findpochanges.sh b/findpochanges.sh index aee47fb2..460776f6 100755 --- a/findpochanges.sh +++ b/findpochanges.sh @@ -4,7 +4,10 @@ rm -f $TMP2 touch $TMP2 for i in i2p2www/translations/*/*/*.po do - mtn diff $i | grep '+msgstr' | grep -v '+msgstr ""' > $TMP + if [ -d ./.git ]; then + git diff $i | grep '+msgstr' | grep -v '+msgstr ""' > $TMP + fi + mtn diff $i | grep '+msgstr' | grep -v '+msgstr ""' > $TMP if [ -s $TMP ] then echo $i >> $TMP2 diff --git a/site-updater-i2hq.sh b/site-updater-i2hq.sh index cb15b52d..99f120a0 100755 --- a/site-updater-i2hq.sh +++ b/site-updater-i2hq.sh @@ -8,20 +8,38 @@ cd $(dirname $0) TMP=$(mktemp XXXXXXXXXX) trap 'rm -f $TMP;exit' 0 1 2 15 -mtn pull "mtn://$MTNURL?$MTNBRANCH" -mtn up 2>&1 | tee $TMP +if [ -d ./.git ]; then + git pull origin master | tee $TMP + if grep "i2p2www/translations/" "$TMP" >/dev/null ; then + echo "Translations updated, compiling messages" + ./compile-messages-i2hq.sh + fi -if grep "^mtn: \(add\|patch\|dropp\|updat\)\(ed\|ing\) 'i2p2www/translations/" "$TMP" >/dev/null ; then - echo "Translations updated, compiling messages" - ./compile-messages-i2hq.sh -fi + echo "Git revision: $(git log -n 1 | grep commit | sed 's/commit //' | sed 's/ .*$//')" >./i2p2www/pages/include/mtnversion -echo "Monotone revision: $(mtn log --no-files --no-graph --to h: | grep Revision | sed 's/Revision: //')" >./i2p2www/pages/include/mtnversion + if grep "^git: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" "$TMP" >/dev/null ; then + echo "Python files changed, restarting server" + touch $TOUCHFILE + fi + +else + + mtn pull "mtn://$MTNURL?$MTNBRANCH" + mtn up 2>&1 | tee $TMP + + if grep "^mtn: \(add\|patch\|dropp\|updat\)\(ed\|ing\) 'i2p2www/translations/" "$TMP" >/dev/null ; then + echo "Translations updated, compiling messages" + ./compile-messages-i2hq.sh + fi + + echo "Monotone revision: $(mtn log --no-files --no-graph --to h: | grep Revision | sed 's/Revision: //')" >./i2p2www/pages/include/mtnversion + + if grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" "$TMP" >/dev/null ; then + echo "Python files changed, restarting server" + touch $TOUCHFILE + fi -if grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" "$TMP" >/dev/null ; then - echo "Python files changed, restarting server" - touch $TOUCHFILE fi [ -f ./.pybabel-stamp ] || ./compile-messages.sh diff --git a/site-updater.sh b/site-updater.sh index 29d6d11c..e55fbc79 100755 --- a/site-updater.sh +++ b/site-updater.sh @@ -8,20 +8,33 @@ cd $(dirname $0) TMP=$(mktemp XXXXXXXXXX) trap 'rm -f $TMP;exit' 0 1 2 15 -$MTN pull -k "" "mtn://$MTNURL?$MTNBRANCH" -$MTN up 2>&1 | tee $TMP +if [ -d ./.git ]; then + #$MTN pull -k "" "mtn://$MTNURL?$MTNBRANCH" + git pull origin master 2>&1 | tee $TMP + if grep "i2p2www/translations/" "$TMP" >/dev/null ; then + echo "Translations updated, compiling messages" + ./compile-messages.sh + fi + echo "Git revision: $(git log -n 1 | grep commit | sed 's/commit: //' | sed 's/ .*$//')" >./i2p2www/pages/include/mtnversion -if grep "^mtn: \(add\|patch\|dropp\|updat\)\(ed\|ing\) 'i2p2www/translations/" "$TMP" >/dev/null ; then - echo "Translations updated, compiling messages" - ./compile-messages.sh + if grep "^git: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" "$TMP" >/dev/null ; then + echo "Python files changed, restarting server" + touch $TOUCHFILE + fi +else + $MTN pull -k "" "mtn://$MTNURL?$MTNBRANCH" + $MTN up 2>&1 | tee $TMP + if grep "^mtn: \(add\|patch\|dropp\|updat\)\(ed\|ing\) 'i2p2www/translations/" "$TMP" >/dev/null ; then + echo "Translations updated, compiling messages" + ./compile-messages.sh + fi + + echo "Monotone revision: $(mtn log --no-files --no-graph --to h: | grep Revision | sed 's/Revision: //')" >./i2p2www/pages/include/mtnversion + + if grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" "$TMP" >/dev/null ; then + echo "Python files changed, restarting server" + touch $TOUCHFILE + fi fi - -echo "Monotone revision: $(mtn log --no-files --no-graph --to h: | grep Revision | sed 's/Revision: //')" >./i2p2www/pages/include/mtnversion - -if grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" "$TMP" >/dev/null ; then - echo "Python files changed, restarting server" - touch $TOUCHFILE -fi - [ -f ./.pybabel-stamp ] || ./compile-messages.sh