/[dehs]/trunk/dehs.sh
ViewVC logotype

Contents of /trunk/dehs.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 138 - (hide annotations) (download) (as text)
Sun Jun 1 23:13:30 2008 UTC (4 years, 11 months ago) by atomo64-guest
File MIME type: application/x-sh
File size: 2075 byte(s)
Do not try to update the web pages more than 50 times
1 atomo64-guest 46 #!/bin/bash
2    
3 atomo64-guest 49 set -e
4    
5 atomo64-guest 46 #PATH="/var/lib/gforge/chroot/home/users/evaso-guest/projects/dehs:$PATH"
6     export BASEDIR=/org/home/groups/dehs
7     export WORKDIR=$BASEDIR/dehs_prj/dehs
8     LOCK=$BASEDIR/run.lock
9 atomo64-guest 94 BNAME=$(basename "$0")
10 atomo64-guest 46
11 atomo64-guest 94 attempts=0
12     maxattempts=30
13 atomo64-guest 46
14 atomo64-guest 94 while true; do
15     if [ -e $LOCK ]; then
16     PID=$(cat $LOCK)
17     if [ ! -n "$PID" ] || ! ps -p "$PID" | grep "$BNAME" &>/dev/null; then
18     echo "Removing stale lock file"
19     rm $LOCK
20     else
21     if [ $attempts -eq $maxattempts ]; then
22     echo "Max number of attempts ($maxattempts) to run reached, surrending to a forever running instance" >&2
23     exit 1
24     fi
25     # lock file is okay, dehs.sh running
26     # let's wait ten minutes and try again
27     sleep $((10 * 60)) || exit 1
28     attempts=$(($attempts + 1))
29     fi
30     else
31     break
32     fi
33     done
34    
35 atomo64-guest 46 echo $$ > $LOCK
36    
37 atomo64-guest 65 run_type="-update_all"
38 atomo64-guest 122 update_www=1
39 atomo64-guest 65
40 atomo64-guest 68 if [ ! -z "$1" ]; then
41     case $1 in
42 atomo64-guest 65 all)
43 atomo64-guest 68 run_type="-update_all"
44 atomo64-guest 65 ;;
45     new)
46 atomo64-guest 68 run_type="-update_new"
47 atomo64-guest 65 ;;
48     bogus)
49 atomo64-guest 68 run_type="-update_bogus"
50 atomo64-guest 65 ;;
51 atomo64-guest 72 wwiz)
52     run_type="-wwiz"
53     ;;
54 atomo64-guest 122 popcon)
55     run_type="-dl_popcon -db_popcon"
56     ;;
57     bugs)
58     run_type="-db_up_error"
59     update_www=0
60     ;;
61     db)
62     run_type="-dehsqa_db"
63     update_www=0
64     ;;
65 atomo64-guest 68 *)
66     echo "Unknown run-type: $1" >&2
67     exit 1
68     ;;
69 atomo64-guest 65 esac
70     fi
71    
72 atomo64-guest 46 cd /tmp/
73     if svn export svn://svn/devscripts/trunk/scripts/uscan.pl 1>/dev/null; then
74 atomo64-guest 49 sed -i "s/###VERSION###/DEHS-SVN/g" uscan.pl
75 atomo64-guest 46 if ! diff $WORKDIR/uscan.pl ./uscan.pl; then
76     echo "New uscan.pl available" >&2
77     fi
78     rm -f uscan.pl
79     fi
80    
81 atomo64-guest 122 for rt in $run_type; do
82     $WORKDIR/dehs_pg.php $rt >$WORKDIR/logs/stdout.log
83     done
84 atomo64-guest 46
85 atomo64-guest 138 c=0
86 atomo64-guest 122 if [ $update_www -gt 0 ]; then
87 atomo64-guest 138 while ! $WORKDIR/update_wwwal.sh >/dev/null && [ $c -lt 50 ]; do
88 atomo64-guest 130 sleep 5
89 atomo64-guest 138 ((c++))
90 atomo64-guest 130 done
91 atomo64-guest 122 fi
92    
93 atomo64-guest 68 rm $LOCK

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5