1 | #! /bin/sh |
---|
2 | # |
---|
3 | # module : |
---|
4 | # check links of acmo before and after installation |
---|
5 | # cf. install.sh |
---|
6 | # |
---|
7 | # original location : |
---|
8 | # /usr/home/fplod/locean/acmo/doc/linkchecker.sh sur aedon.locean-ipsl.upmc.fr |
---|
9 | # |
---|
10 | # update : |
---|
11 | # ++ linkchecker ne voit pas les erreurs !! |
---|
12 | # ++ dirpublish forme fplod@cerbere.locean-ipsl.upmc.fr:./WWW/ par example |
---|
13 | # donc pas http |
---|
14 | # + ajouter la possibilite rde faire une carte du site avec |
---|
15 | # graphiz |
---|
16 | # exemple synatxe = |
---|
17 | # $ linkchecker -odot -v http://www.lodyc.jussieu.fr/NEMO/general/biblio_new/ | dot -Tps > sitemap.ps |
---|
18 | # |
---|
19 | # remove "set -u" because I don't know how to test if there is at least |
---|
20 | # one directory AND one url to be checked without this option |
---|
21 | # !! ++ must be restore ASAP |
---|
22 | # $Id$ |
---|
23 | # fplod 2007-10-12T07:32:08Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
24 | # add -u pour url |
---|
25 | # add multiple -d and suppression of interactivity |
---|
26 | # replace -w by -d (more generic) |
---|
27 | # use rather checklink than linkchecker because the first one exist either |
---|
28 | # on Mac and Unix, and because the second one exists only on Mac and |
---|
29 | # does'nt seem to detect every problem |
---|
30 | # fplod 2007-10-11T15:31:25Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
31 | # parametrization |
---|
32 | # merge with checklink.sh ++ choisir entre les deux |
---|
33 | # fplod 2007-06-19T09:26:04Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
34 | # création |
---|
35 | # |
---|
36 | set -o posix |
---|
37 | command=$(basename ${0} .sh) |
---|
38 | log_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") |
---|
39 | log=/tmp/${command}.log.${log_date} |
---|
40 | # |
---|
41 | usage=" Usage : ${command} -d dircheck -u url" |
---|
42 | # |
---|
43 | minargcount=2 |
---|
44 | #echo " narg ${#}" |
---|
45 | if [ ${#} -lt ${minargcount} ] |
---|
46 | then |
---|
47 | echo "eee : not enought arguments" |
---|
48 | echo "${usage}" |
---|
49 | exit 1 |
---|
50 | fi |
---|
51 | # |
---|
52 | idircheck=0 |
---|
53 | iurl=0 |
---|
54 | while [ ! -z "${1}" ] |
---|
55 | do |
---|
56 | case ${1} in |
---|
57 | -d) |
---|
58 | idircheck=$(( ${idircheck} + 1 )) |
---|
59 | dircheck[${idircheck}]=${2} |
---|
60 | shift |
---|
61 | ;; |
---|
62 | -u) |
---|
63 | iurlcheck=$(( ${iurlcheck} + 1 )) |
---|
64 | urlcheck[${iurlcheck}]=${2} |
---|
65 | shift |
---|
66 | ;; |
---|
67 | esac |
---|
68 | shift # next flag |
---|
69 | done |
---|
70 | # |
---|
71 | # +++ remove temporarily |
---|
72 | # +++ set -u |
---|
73 | # |
---|
74 | # ++ check directories or URL |
---|
75 | # |
---|
76 | # choose the command to be used |
---|
77 | # |
---|
78 | commandcheck=checklink |
---|
79 | # |
---|
80 | if [ ${commandcheck} = "linkchecker" ] |
---|
81 | then |
---|
82 | # test if linkchecker is available |
---|
83 | type ${commandcheck} 1> /dev/null 2>&1 |
---|
84 | status=${?} |
---|
85 | if [ ${status} -ne 0 ] |
---|
86 | then |
---|
87 | echo "${command} : eee : ${commandcheck} unavailable" |
---|
88 | exit 1 |
---|
89 | fi |
---|
90 | optcheck="--anchors --recursion-level=-1" |
---|
91 | fi |
---|
92 | # |
---|
93 | if [ ${commandcheck} = "checklink" ] |
---|
94 | then |
---|
95 | # test if checklink is available |
---|
96 | type ${commandcheck} 1> /dev/null 2>&1 |
---|
97 | status=${?} |
---|
98 | if [ ${status} -ne 0 ] |
---|
99 | then |
---|
100 | echo "${command} : eee : ${commandcheck} unavailable" |
---|
101 | exit 1 |
---|
102 | fi |
---|
103 | # |
---|
104 | optcheck="--summary --recursive" |
---|
105 | fi |
---|
106 | # |
---|
107 | # loop on directories to be checked |
---|
108 | dirchecksize=${#dircheck[@]} # ++ pb set -u |
---|
109 | if [ ${dirchecksize} -gt 0 ] |
---|
110 | then |
---|
111 | idircheck=1 |
---|
112 | while [ ${idircheck} -le ${dirchecksize} ] |
---|
113 | do |
---|
114 | echo "iii : beginning of check of ${dircheck[${idircheck}]}" 1>>${log} |
---|
115 | fverif="file://"${dircheck[${idircheck}]} |
---|
116 | echo "iii : check of ${fverif}" |
---|
117 | ${commandcheck} ${optcheck} ${fverif} 1>>${log} 2>&1 |
---|
118 | idircheck=$(( ${idircheck} + 1 )) |
---|
119 | done |
---|
120 | fi |
---|
121 | # |
---|
122 | # loop on urls to be checked |
---|
123 | urlchecksize=${#urlcheck[@]} # ++ pb set -u |
---|
124 | if [ ${urlchecksize} -gt 0 ] |
---|
125 | then |
---|
126 | iurlcheck=1 |
---|
127 | while [ ${iurlcheck} -le ${urlchecksize} ] |
---|
128 | do |
---|
129 | echo "iii : beginning of check of ${urlcheck[${iurlcheck}]}" 1>>${log} |
---|
130 | # ++ test si urlcheck commence par http ou pas |
---|
131 | fverif=${urlcheck[${iurlcheck}]} |
---|
132 | echo "iii : check of ${fverif}" |
---|
133 | ${commandcheck} ${optcheck} ${fverif} 1>>${log} 2>&1 |
---|
134 | iurlcheck=$(( ${iurlcheck} + 1 )) |
---|
135 | done |
---|
136 | fi |
---|
137 | # |
---|
138 | echo "iii : log in ${log}" |
---|
139 | # end |
---|
140 | exit |
---|