site-updater updates

- no unneccesary uses of cat
- create tempfile with mktemp and cleanup with a trap
- simplify regex
This commit is contained in:
kytv
2013-08-31 23:52:07 +00:00
parent 7e086fd2e7
commit ba651ceafb
2 changed files with 8 additions and 14 deletions

View File

@ -1,18 +1,15 @@
#!/bin/sh
TMP=tmp
TMP=$(mktemp XXXXXXXXXX)
trap 'rm -f $TMP;exit' 0 1 2 15
mtn update 2>&1 | tee $TMP
cat $TMP | grep "^mtn: adding 'i2p2www/translations/\|^mtn: dropping 'i2p2www/translations/\|^mtn: updating 'i2p2www/translations/" >/dev/null
if [ $? -eq 0 ]; then
if grep "^mtn: \(add\|dropp\|updat\)ing 'i2p2www/translations/" "$TMP" >/dev/null; then
echo "Translations updated, compiling messages"
./compile-messages-i2hq.sh
fi
cat $TMP | grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" >/dev/null
if [ $? -eq 0 ]; then
if grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" >/dev/null; then
echo "Python files changed, restarting server"
touch /tmp/2fcd2f17-c293-4f77-b4c9-9b266ba70daa
fi
rm $TMP

View File

@ -1,18 +1,15 @@
#!/bin/sh
TMP=tmp
TMP=$(mktemp XXXXXXXXXX)
trap 'rm -f $TMP;exit' 0 1 2 15
mtn update 2>&1 | tee $TMP
cat $TMP | grep "^mtn: adding 'i2p2www/translations/\|^mtn: dropping 'i2p2www/translations/\|^mtn: updating 'i2p2www/translations/" >/dev/null
if [ $? -eq 0 ]; then
if grep "^mtn: \(add\|dropp\|updat\)ing 'i2p2www/translations/" "$TMP" >/dev/null ; then
echo "Translations updated, compiling messages"
./compile-messages.sh
fi
cat $TMP | grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" >/dev/null
if [ $? -eq 0 ]; then
if grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" "$TMP" >/dev/null ; then
echo "Python files changed, restarting server"
touch /tmp/2fcd2f17-c293-4f77-b4c9-9b266ba70daa
fi
rm $TMP