-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.sh
executable file
·72 lines (61 loc) · 1.78 KB
/
check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# This script should be placed in the root directory on the HTTP
# server from where TrEd reads its extensions. It checks the integrity
# of the configuration and reports any duplicates, missing files or
# broken references.
set -eu
echo % Common files:
comm -12 <(ls core) <(ls external) \
| grep -vE '^(extensions\.lst~?|index\.html)$' || :
echo
echo % Common extensions in lists:
comm -12 <(sort core/extensions.lst) <(sort external/extensions.lst)
echo
echo % Zip files with no links:
for dir in core external ; do
sed 's/$/.zip/' "$dir"/extensions.lst \
| grep -vFf- <(ls "$dir") \
| sed -n '/.zip$/ { s=^='"$dir/"'=;s/\.zip$//; p}'
done
echo
echo % Listed non-existent:
for dir in core external ; do
while read ext ; do
dir_found=0
[[ -d $dir/$ext ]] && dir_found=1
zip_found=0
[[ -f $dir/$ext.zip ]] && zip_found=1
if (( ! dir_found || ! zip_found )) ; then
echo $dir/$ext dir: $dir_found zip: $zip_found
fi
done < "$dir"/extensions.lst
done
echo
echo % Missing files:
for dir in core external ; do
for subdir in "$dir"/*/ ; do
[[ -f "$subdir"package.xml ]] || echo "$subdir"package.xml
[[ -f ${subdir%/}.zip ]] || echo ${subdir%/}.zip
done
done
echo
echo % Package link broken:
for dir in core external ; do
grep -o '<repository[^>]*' "$dir"/*/package.xml | grep -v "<repository.*$dir" || :
done
echo
echo % Dependency links broken:
for dir in core external ; do
for p in "$dir"/*/package.xml ; do
grep '<extension' "$p" \
| grep -oE '/(core|external)/[^"]+' \
| sed 's=/==;s=$=.zip=' \
| xargs ls > /dev/null \
|| echo "$p"
done
done
echo
echo % Insufficient permissions:
find core external \! -perm -g+w -ls || :
echo
echo % Done.