-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoaipoll
More file actions
executable file
·55 lines (45 loc) · 1.54 KB
/
Copy pathoaipoll
File metadata and controls
executable file
·55 lines (45 loc) · 1.54 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
#!/bin/bash
# Title: oaipoll
# Description: toggles the pollingEnabled value in order to turn on and off
# the OAI polling. Should be used with cron or timer to enable polling only over night
# Author: Peter Reimer <reimer@hbz-nrw.de
# Date: 2026-05-07
MYSQL=/usr/bin/mariadb
# wait some time after turning off oai-pmh before disabling the polling
WAIT=120
usage()
{
echo "This script enables and disables the oai-pmh polling by toggling the flag in the database."
echo "Usage: $0 {enable|disable|status|log}"
exit 1
}
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $scriptdir
. variables.conf
case "$1" in
enable)
echo "set to 1"
$MYSQL -uoaipmh -p$OAIPMH_PASSWORD -e"UPDATE oaipmh.rcAdmin SET pollingEnabled=1;"
;;
disable)
echo "turning off oai-pmh service"
curl -u admin:$REGAL_PASSWORD "http://localhost:8080/manager/html/stop?path=/oai%2Dpmh" -o /dev/null
echo "waiting $WAIT seconds"
sleep $WAIT
echo "setting pollingEnabled to 0"
$MYSQL -uoaipmh -p$OAIPMH_PASSWORD -e"UPDATE oaipmh.rcAdmin SET pollingEnabled=0;"
echo "Resuming oai-pmh service"
curl -u admin:$REGAL_PASSWORD "http://localhost:8080/manager/html/start?path=/oai%2Dpmh" -o /dev/null
;;
status)
$MYSQL -uoaipmh -p$OAIPMH_PASSWORD -e"select pollingEnabled from oaipmh.rcAdmin;" | sed '2!d'
;;
log)
state=`$MYSQL -uoaipmh -p$OAIPMH_PASSWORD -e"select pollingEnabled from oaipmh.rcAdmin;" | sed '2!d'`
timestamp=`date "+%Y-%m-%dT%H:%M:%S"`
echo $timestamp $state
;;
*)
usage
;;
esac