Non-initialized variable fix.
[openlib.git] / check-upload.sh
1 #!/bin/sh
2
3 PIDFILE=/var/run/openlib.pid
4
5 if [ -e "$PIDFILE" ] ; then
6     # our pidfile exists, let's make sure the process is still running though
7     PID=`/bin/cat "$PIDFILE"`
8     if /bin/kill -0 "$PID" > /dev/null 2>&1 ; then
9         # indeed it is, i'm outta here!
10         /bin/echo 'Previous instance running...'
11         exit 0
12     fi
13  fi
14
15 # create or update the pidfile
16 /bin/echo "$$" > $PIDFILE
17
18 . /etc/openlib.conf
19
20 cd $upload
21 find $upload -type f -name "*.zip" -mmin +10 -exec sh -c 'unzip $1 && rm $1' _ {} \; 
22 find $upload -type f -name "*.fb2" ! -user www-data -exec chown www-data:users {} \;
23 find $upload -type f -name "*.fb2" -user www-data -mmin +10 -exec mv {} $temp \;
24
25 cd /opt/openlibrary
26 /opt/openlibrary/fb2_process.py
27
28 /bin/rm -f "$PIDFILE"
29
30 exit 0