-
Notifications
You must be signed in to change notification settings - Fork 6
/
find-links-broken-by-relaunch.sh
executable file
·36 lines (32 loc) · 1.39 KB
/
find-links-broken-by-relaunch.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
#!/bin/bash
# Annahmen des Skripts:
# * Eine Kopie der alten LUGA-Seite befindet sich in $1.
# * Die neue Seite ist auf http://luga-dummy/ erreichbar.
# Ausgabe des Skripts:
# * Redirect-Direktiven für Apache für verschobene Inhalte
# * Traurige Smileys für nicht wiedergefundende Inhalte
cd -- "$1"
find . | while read; do
curl -Lsf http://luga-dummy/"$REPLY" >/dev/null || echo "$REPLY"
done | egrep -v "/LUGA_Logo|corner_tr|/onepixel|/corner_top|/line_t|/edge_top|/corner_bl|/Pinguin|/corner_tl|/corner_br" | while read; do
REPLY="${REPLY:2}"
REPLY="${REPLY%.1}" # von wget ergänzte Suffixe
REPLY="${REPLY%.2}"
basename="$(basename "$REPLY")"
ohneindexhtml="${REPLY%index.html}"
if curl -Lsf http://luga-dummy/"$REPLY" >/dev/null; then
# alles gut: Dann sind wir von einem von wget ergänzten Suffix wie ".1"
# oder ".2" in die Irre geleitet worden.
:
elif curl -Lsf http://luga-dummy/download/Vortraege/"$basename" >/dev/null; then
echo "Redirect permanent /$REPLY https://www.luga.de/download/$basename"
elif curl -Lsf http://luga-dummy/"$ohneindexhtml" >/dev/null; then
echo "Redirect permanent /$REPLY https://www.luga.de/$ohneindexhtml"
elif curl -Lsf http://luga-dummy/"$REPLY"/ >/dev/null; then
# Sollte niemals eintreten
echo "Huh? $REPLY"
exit 1
else
echo "# :-( $REPLY"
fi
done