source: trunk/linkchecker.sh @ 76

Last change on this file since 76 was 75, checked in by pinsard, 16 years ago

comments in shell scripts in ReStructured? Text

  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1#! /bin/sh
2#+
3# NAME
4# ====
5#
6# linkchecker.sh -  check links of a given directory or url
7#
8# SYNOPSYS
9# ========
10#
11# ::
12#
13#  $ linkchecker.sh -d dircheck -u url
14#
15#
16# DESCRIPTION
17# ===========
18#
19# check links of a given directory or url
20# cf. install.sh
21#
22#
23# EXAMPLES
24# ========
25#
26#
27# FILES
28# =====
29#
30# original location
31# ~~~~~~~~~~~~~~~~~
32#
33# /usr/home/fplod/src/superbib_ws/linkchecker.sh sur aedon.locean-ipsl.upmc.fr
34#
35# EVOLUTIONS
36# ==========
37#
38# ++ linkchecker ne voit pas les erreurs !!
39#
40# ++ dirpublish forme fplod@cerbere.locean-ipsl.upmc.fr:./WWW/ par example
41# donc pas http
42#
43# + ajouter la possibilite de faire une carte du site avec raphiz
44#
45# exemple syntaxe
46#
47# ::
48#
49#  $ linkchecker -odot -v http://www.lodyc.jussieu.fr/NEMO/general/biblio_new/   | dot -Tps > sitemap.ps
50#
51#
52# remove "set -u" because I don't know how to test if there is at least
53# one directory AND one url to be checked without this option
54#
55# !! ++ must be restore ASAP
56#
57# $Id$
58#
59# - fplod 2008-09-16T15:28:34Z aedon.locean-ipsl.upmc.fr (Darwin)
60#
61#   * comment in ReStructured Text
62#
63# - fplod 2007-10-12T07:32:08Z aedon.locean-ipsl.upmc.fr (Darwin)
64#
65#   * add -u pour url
66#   * add multiple -d and suppression of interactivity
67#   * replace -w by -d (more generic)
68#   * use rather checklink than linkchecker because the first one exist either
69#     on Mac and Unix, and because the second one exists only on Mac and
70#     does'nt seem to detect every problem
71#
72# - fplod 2007-10-11T15:31:25Z aedon.locean-ipsl.upmc.fr (Darwin)
73#
74#   * parametrization
75#   * merge with checklink.sh ++ choisir entre les deux
76#
77# - fplod 2007-06-19T09:26:04Z aedon.locean-ipsl.upmc.fr (Darwin)
78#
79#   * création
80#-
81system=$(uname)
82case "${system}" in
83 AIX|IRIX64)
84  echo " www : no specific posix checking"
85 ;;
86 *)
87  set -o posix
88 ;;
89esac
90command=$(basename ${0} .sh)
91log_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
92log=/tmp/${command}.log.${log_date}
93#
94usage=" Usage : ${command} -d dircheck -u url"
95#
96minargcount=2
97#echo " narg ${#}"
98if [ ${#} -lt ${minargcount} ]
99then
100  echo "eee : not enought arguments"
101  echo "${usage}"
102  exit 1
103fi
104#
105idircheck=0
106iurl=0
107while [ ! -z "${1}" ]
108do
109 case ${1} in
110 -d)
111  idircheck=$(( ${idircheck} + 1 ))
112  dircheck[${idircheck}]=${2}
113  shift
114 ;;
115 -u)
116  iurlcheck=$(( ${iurlcheck} + 1 ))
117  urlcheck[${iurlcheck}]=${2}
118  shift
119 ;;
120 esac
121 shift # next flag
122done
123#
124# +++ remove temporarily
125# +++ set -u
126#
127# ++ check directories or URL
128#
129# choose the command to be used
130#
131commandcheck=checklink
132#
133if [ ${commandcheck} = "linkchecker" ]
134then
135   # test if linkchecker is available
136   type ${commandcheck} 1> /dev/null 2>&1
137   status=${?}
138   if [ ${status} -ne 0 ]
139   then
140    echo "${command} : eee : ${commandcheck} unavailable"
141    exit 1
142   fi
143   optcheck="--anchors --recursion-level=-1"
144fi
145#
146if [ ${commandcheck} = "checklink" ]
147then
148   # test if checklink is available
149   type ${commandcheck} 1> /dev/null 2>&1
150   status=${?}
151   if [ ${status} -ne 0 ]
152   then
153      echo "${command} : eee : ${commandcheck} unavailable"
154      exit 1
155   fi
156#
157   optcheck="--summary --recursive"
158fi
159#
160# loop on directories to be checked
161dirchecksize=${#dircheck[@]} # ++ pb set -u
162if [ ${dirchecksize} -gt 0 ]
163then
164   idircheck=1
165   while [ ${idircheck} -le ${dirchecksize} ]
166   do
167      echo "iii : beginning of check of ${dircheck[${idircheck}]}" 1>>${log}
168      fverif="file://"${dircheck[${idircheck}]}
169      echo "iii : check of ${fverif}"
170      ${commandcheck} ${optcheck} ${fverif} 1>>${log} 2>&1
171      idircheck=$(( ${idircheck} + 1 ))
172   done
173fi
174#
175# loop on urls to be checked
176urlchecksize=${#urlcheck[@]} # ++ pb set -u
177if [ ${urlchecksize} -gt 0 ]
178then
179   iurlcheck=1
180   while [ ${iurlcheck} -le ${urlchecksize} ]
181   do
182      echo "iii : beginning of check of ${urlcheck[${iurlcheck}]}" 1>>${log}
183      # ++ test si urlcheck commence par http ou pas
184      fverif=${urlcheck[${iurlcheck}]}
185      echo "iii : check of ${fverif}"
186      ${commandcheck} ${optcheck} ${fverif} 1>>${log} 2>&1
187      iurlcheck=$(( ${iurlcheck} + 1 ))
188   done
189fi
190#
191echo "iii : log in ${log}"
192# end
193exit
Note: See TracBrowser for help on using the repository browser.