[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

r10288 - in /man-cgi/extractor: config generate-indexes.sh generate-manpages-archive.sh



Author: jfs
Date: Wed Oct 30 01:17:33 2013
New Revision: 10288

URL: http://svn.debian.org/wsvn/?sc=1&rev=10288
Log:
Add external configuration file for variables to prevent script editing when switching location. Also add lockfile support to generate-manpages-archive.sh, which is run through cron to prevent two tasks from running simultaneously.

Added:
    man-cgi/extractor/config
Modified:
    man-cgi/extractor/generate-indexes.sh
    man-cgi/extractor/generate-manpages-archive.sh

Added: man-cgi/extractor/config
URL: http://svn.debian.org/wsvn/man-cgi/extractor/config?rev=10288&op=file
==============================================================================
--- man-cgi/extractor/config	(added)
+++ man-cgi/extractor/config	Wed Oct 30 01:17:33 2013
@@ -0,0 +1,18 @@
+
+# Configuration file for the manpage extraction software
+
+# This is where the mirror resides
+MIRRORDIR=/srv/mirrors/debian
+
+# This is where the files will be extracted
+EXTRACTORDIR=/srv/manpages.debian.org/extractor/
+
+# The logfile
+LOGDIR=$EXTRACTORDIR/logs
+
+# The location of manpages for each distribution
+MANDIR=$EXTRACTORDIR/manpages-dists/
+
+# Define tmpdir to prevent creating cruft in /tmp (default TMPDIR)
+TMPDIR=$EXTRACTORDIR/work
+

Modified: man-cgi/extractor/generate-indexes.sh
URL: http://svn.debian.org/wsvn/man-cgi/extractor/generate-indexes.sh?rev=10288&op=diff
==============================================================================
--- man-cgi/extractor/generate-indexes.sh	(original)
+++ man-cgi/extractor/generate-indexes.sh	Wed Oct 30 01:17:33 2013
@@ -1,13 +1,14 @@
 #!/bin/sh
 
-EXTRACTEDIR=manpages-dists/
 
-if [ ! -d $EXTRACTEDIR ] ; then
-    echo "The directory $EXTRACTEDIR does not exist"
+. ./config
+
+if [ ! -d "$MANDIR" ] ; then
+    echo "The directory '$MANDIR' does not exist"
     exit 1
 fi
 
-for dir in $EXTRACTEDIR/*; do
+for dir in $MANDIR/*; do
     if [ -d $dir -a -d $dir/usr/share/man ] ; then
         MANPATH=$dir/usr/share/man/:$dir/usr/X11R6/man/ \
             man -k . >$dir/usr/share/man/whatis.db

Modified: man-cgi/extractor/generate-manpages-archive.sh
URL: http://svn.debian.org/wsvn/man-cgi/extractor/generate-manpages-archive.sh?rev=10288&op=diff
==============================================================================
--- man-cgi/extractor/generate-manpages-archive.sh	(original)
+++ man-cgi/extractor/generate-manpages-archive.sh	Wed Oct 30 01:17:33 2013
@@ -5,10 +5,10 @@
 #
 # It can be setup as a cron script at the system where man.cgi is installed
 
-# Change this to suit to your needs
-EXTRACTORDIR=/srv/manpages.debian.org/extractor/
-MIRRORDIR=/srv/ftp.debian.org/ftp
-LOGDIR=$EXTRACTORDIR/logs
+
+# Source the configuration file
+. ./config
+export TMPDIR
 
 if [ ! -d "$EXTRACTORDIR" ] ; then
         echo "Cannot find the directory $EXTRACTORDIR with the scripts!" >&2
@@ -19,10 +19,28 @@
         exit 1
 fi
 if [ ! -d "$EXTRACTORDIR/logs" ] ; then
-        mkdir "${EXTRACTORDIR}/logs"
+        mkdir "${EXTRACTORDIR}/logs" || { echo "ERROR: Cannot create ${EXTRACTORDIR}/logs " >&2; exit 1; }
+fi
+if [ ! -d "$EXTRACTORDIR/work" ] ; then
+        mkdir "${EXTRACTORDIR}/work"
+        mkdir "${EXTRACTORDIR}/work" || { echo "ERROR: Cannot create ${EXTRACTORDIR}/work " >&2; exit 1; }
+fi
+if [ ! -d "$MANDIR" ] ; then
+        mkdir "$MANDIR" || { echo "ERROR: Cannot create $MANDIR " >&2; exit 1; }
 fi
 
 DIR=`pwd`
+
+# Check if an update is in progress and lock otherwise
+LOCK="$MANDIR/UPDATE_IN_PROGRESS"
+if [ -e "$LOCK" ]; then
+        echo "ERROR: Update is currently running"
+        echo "Lock: $LOCK"
+        cat "$LOCK"
+        exit 1
+fi
+trap "rm -f $LOCK 2>/dev/null || true" EXIT HUP INT QUIT TERM
+date > $LOCK || { echo "ERROR: Cannot create lockfile $LOCK " >&2 ; exit 1; }
 
 
 cd $EXTRACTORDIR


Reply to: