forked from Surgo/redmine_reposearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreposearch-update.sh
executable file
·77 lines (70 loc) · 2.46 KB
/
reposearch-update.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
73
74
75
76
77
#!/bin/bash
#
# This scripts updates the full text index for reposearch,
# the full text search plugin for redmine.
#
# Author: Jostein Elvaker Haande <[email protected]>
#
# INSTALLATION
# - copy the script to your desired location
# - edit the settings below
# - enable 'reposearcher' for your desired project(s)
# - set up a crontab to run the script
# i.e: */10 * * * * /path/to/update-reposearch.sh
# This will run the update process every ten minutes
#
# reposearch-update.sh - BASH script to update your repos for reposearch
# Copyright (C) 2012 - Jostein Elvaker Haande <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
NAME="RepoSearchUpdate"
# Here we specify the path to the curl binary, the URL to your redmine
# instllation as well as your API key.
CURLPATH="/usr/bin/curl"
REDMINEURL="http://redmine.yourdomain.tld/repoindexer/crawl/"
APIKEY="xxxxxxxxxxxxxx"
# List of the repositories we want to keep up to date with the
# reposearch full text indexer. Separated by spaces!
# You find the name by looking under your projects settings, and
# the setting 'identifier'.
# Make sure that you've enabled 'reposearcher' under the project
# settings, or else repoindexer will fail.
REPOS="repo1 repo2 repo3"
# Do we want to log to syslog
SYSLOG=1
# Do *NOT* touch these. For internal book keeping during script execution
ERROR=0
ERRORSTR=""
for repo in $REPOS
do
COMMAND=$($CURLPATH -s $REDMINEURL$repo?key=$APIKEY)
if (( $? )) || [ "$COMMAND" != "Successfully indexed!" ] ; then
if [ "$SYSLOG" -eq "1" ] ; then
logger -t $NAME "Error updating repository $repo"
fi
ERROR=1
ERRORSTR="$ERRORSTRError updating repository $repo\n"
fi
done
if [ "$ERROR" -eq "1" ] ; then
echo -e "### Reposearch repository updater ###"
echo -e ""
echo -e "An error was encountered on $(date)"
echo -e ""
echo -e "ERROR:"
echo -e "$ERRORSTR"
exit 1
else
exit 0
fi