-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreateWebpage.sh
More file actions
executable file
·77 lines (68 loc) · 2.47 KB
/
createWebpage.sh
File metadata and controls
executable file
·77 lines (68 loc) · 2.47 KB
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
73
74
75
76
77
#!/bin/bash
# Legt eine Webpage anhand von URL, vorläufigem Titel und ggfs. Intervall an.
# Für TOS-1178 (UB Bonn 800 Webpages)
# Änderungshistorie
#+------------------------------+----------------------------------------------------------------------------------------
#| Bearbeiter | Datum | Grund
#+------------------------------+----------------------------------------------------------------------------------------
#| Ingolf Kuss | 21.01.2025 | Neuanlage
#| Ingolf Kuss | 10.02.2025 | Parameter PID (von - bis) hinzugefügt
#| Ingolf Kuss | 16.01.2026 | Parameter crawlSubdomains (true oder false) hinzugefügt
#+------------------------------+----------------------------------------------------------------------------------------
set -o nounset
source funktionen.sh
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $scriptdir
source variables.conf
usage() {
cat <<EOF
Erstellt einen Webarchivierung Datensatz (Webpage)
Beispielaufruf: $0 Titel URL Intervall
Optionen:
- h Hilfe (dieser Text)
- s silent off (nicht still), Standardwert: $silent_off
- v verbose (gesprächig), Standardwert: $verbose
EOF
exit 0
}
# Default-Werte
silent_off=1
verbose=0
# Auswertung der Optionen und Kommandozeilenparameter
OPTIND=1 # Reset in case getopts has been used previously in the shell.
while getopts "h?sv" opt; do
case "$opt" in
h|\?) usage
;;
s) silent_off=0
;;
v) verbose=1
;;
esac
done
shift $((OPTIND-1))
[ "${1:-}" = "--" ] && shift
title=$1
url=$2
intervall=$3
pid=$4
crawlSubdomains=$5
# Beginn der Hauptverarbeitung
curlopts=""
if [ $silent_off != 1 ]; then
curlopts="$curlopts -s"
fi
if [ $verbose == 1 ]; then
curlopts="$curlopts -v"
fi
url_encoded=$(urlencode $url)
title_encoded=$(urlencode "$title")
intervall_encoded=$(urlencode "$intervall")
echo "curl $curlopts -XPOST \"$BACKEND/resource/$NAMESPACE/createWebpage?url=$url_encoded&title=$title_encoded&interval=$intervall_encoded&pid=$pid&crawlSubdomains=$crawlSubdomains\""
resultat=`curl $curlopts -u$ADMIN_USER:$PASSWORD -H"content-type:application/json" -XPOST -d"{\"contentType\":\"webpage\"}" "$BACKEND/resource/$NAMESPACE/createWebpage?url=$url_encoded&title=$title_encoded&interval=$intervall_encoded&pid=$pid&crawlSubdomains=$crawlSubdomains"`
echo $resultat
id=`echo $resultat | jq ".[\"@id\"]"`
id=$(stripOffQuotes "$id")
echo
echo "Webpage mit pid erzeugt: $id"
exit 0