[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [translation-tools/master] Add a simple pidfile mechanic to update_translations



commit 7bfa0f6af76d035c98579e81527202b94e0a8ece
Author: Sebastian Hahn <sebastian@xxxxxxxxxxxxxx>
Date:   Sat Sep 3 16:47:29 2011 +0200

    Add a simple pidfile mechanic to update_translations
---
 config              |    2 ++
 update_translations |   21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/config b/config
index e98d644..1366e69 100644
--- a/config
+++ b/config
@@ -8,3 +8,5 @@ TRANSLATION_REPO=/srv/translation.torproject.org/translations/
 TX=/srv/translation.torproject.org/transifex-client/bin/tx
 
 PROJECTS="bridgedb gettor orbot vidalia vidalia_help vidalia_installer"
+
+PIDFILE=/srv/translation.torproject.org/run/update_translations.pid
diff --git a/update_translations b/update_translations
index 6a9ae44..15692f7 100755
--- a/update_translations
+++ b/update_translations
@@ -4,6 +4,18 @@ cd `dirname $0`
 
 source config
 
+SCRIPT=`basename $0`
+
+if [ -f ${PIDFILE} ]; then
+  OLDPID=`cat ${PIDFILE}`
+  STILL_RUNNING=`ps -ef | grep ${OLDPID} | grep ${SCRIPT}`
+  if [ -n "${STILL_RUNNING}" ]; then
+    exit 2
+  fi
+fi
+PID=`ps -ef | grep ${SCRIPT} | head -n1 | awk ' {print $2;} '`
+echo ${PID} > ${PIDFILE}
+
 # Prepare the repository by making sure it is up to date.
 cd $TRANSLATION_REPO
 
@@ -13,13 +25,22 @@ cd $TRANSLATION_REPO
 for project in $PROJECTS; do
 
   cd $project;
+
+  # Fetch new translations for this project ...
   $TX pull -a -s > /dev/null;
 
+  # ... add them to git ...
   git add . > /dev/null;
   git commit -qm "Update translations for $project" > /dev/null || test $? = 1;
 
+  # ... and push them live.
   git push origin $project;
 
   cd ..;
 done
 
+# Remove the pidfile again
+if [ -f ${PIDFILE} ]; then
+  rm ${PIDFILE}
+fi
+

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits