Mobrovac has submitted this change and it was merged.

Change subject: Add a script to check for git changes and rebuild the deps if 
needed
......................................................................


Add a script to check for git changes and rebuild the deps if needed

The script checks for new, committed changes and pulls them in. If
package.json changes as well, the node dependencies are rebuilt and the
service is restarted.

The script is meant to be run by cron every couple of minutes, so keep
the git tree in labs clean!

Change-Id: Ic0897cce30aef1d450fc975d96389e5983756657
---
A scripts/puller.sh
1 file changed, 38 insertions(+), 0 deletions(-)

Approvals:
  Mobrovac: Verified; Looks good to me, approved



diff --git a/scripts/puller.sh b/scripts/puller.sh
new file mode 100755
index 0000000..c8f496f
--- /dev/null
+++ b/scripts/puller.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+
+# ensure we are in the right dir
+cd $(dirname $0)/..;
+
+# check for a git dir
+if [[ ! -e .git ]]; then
+    echo "No .git directory here, exiting" >&2;
+    exit 1;
+fi
+
+# be on master and get the updates
+git checkout master;
+git fetch origin;
+
+# inspect what has changed
+flist=$(git diff --name-only origin/master);
+
+if [[ -z "${flist}" ]]; then
+    # no changes, we are done
+    exit 0;
+fi
+
+# there are updates, do them
+git pull;
+
+if echo -e "${flist}" | grep -i package.json > /dev/null; then
+    # package.json has been changed, need to rebuild the modules
+    rm -rf node_modules;
+    npm install;
+fi
+
+# now, restart the service
+systemctl restart mobileapps;
+
+exit $?;
+

-- 
To view, visit https://gerrit.wikimedia.org/r/201429
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic0897cce30aef1d450fc975d96389e5983756657
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mobrovac <mobro...@wikimedia.org>
Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: Mobrovac <mobro...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to