forked from artefactual/archivematica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev-helper
executable file
·245 lines (225 loc) · 7.39 KB
/
dev-helper
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/bin/bash
# This file is part of Archivematica.
#
# Copyright 2010-2013 Artefactual Systems Inc. <http://artefactual.com>
#
# Archivematica is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Archivematica 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 Archivematica. If not, see <http://www.gnu.org/licenses/>.
# @package Archivematica
# @author Joseph Perry <[email protected]>
# @version svn: $Id$
cd `dirname $0`
fn_exists()
{
type $1 2>/dev/null | grep -q 'is a function'
}
colour () { "$@" 2>&1>&3|sed 's,.*,\x1B[31m&\x1B[0m,'>&2;} 3>&1
function git-pull() {
part="git pull"
echo -n "\"Would you like to ${part}?\" (y/N) "
read a
if [[ $a == "Y" || $a == "y" ]]; then
echo "Doing ${part} ..."
echo "Cleaning up..."
cd localDevSetup/
colour ./cleanup.sh
cd ..
currentBranch=`git status | grep '# On branch ' | awk '{print $4}'`
gitDiff=`git diff`
if [ -z "$gitDiff" -a "${gitDiff+xxx}" = "xxx" ]; then
echo "No changes to store."
else
echo "Storing changes (to be restored with 'git stash pop'), viewed with git-diff."
git stash
fi
colour git pull --rebase origin ${currentBranch}
colour git submodule init
colour git submodule update
if [ -z "$gitDiff" -a "${gitDiff+xxx}" = "xxx" ]; then
echo "No changes to restore"
else
echo "Restoring changes"
git stash pop
fi
echo "Integrating into environment..."
cd localDevSetup/
colour ./createLocalDevDirectories.sh
cd ..
echo "Updating FPR admin..."
# this will do nothing if you are in a branch with no submodules
git submodule init
git submodule update
if [ -d src/dashboard/src/fpr ]; then
echo "entering fpr admin module"
cd src/dashboard/src/fpr
git checkout 1.x
git pull
cd ../../../../
fi
else
echo "not going to ${part}"
fi
}
function package-update() {
part="update/install package requirements"
echo -n "\"Would you like to ${part}?\" (y/N) "
read a
if [[ $a == "Y" || $a == "y" ]]; then
echo "Going to ${part} ..."
cd localDevSetup/
colour sudo apt-get update
colour sudo ./installDependsFromDebianFile.py ./../src/archivematicaCommon/debian/control
#colour sudo ./installDependsFromDebianFile.py ./../src/createDublinCore/debian/control
colour sudo ./installDependsFromDebianFile.py ./../src/dashboard/debian/control
#./installDependsFromDebianFile.py ./../src/easy-extract/debian/control
colour sudo ./installDependsFromDebianFile.py ./../src/MCPClient/debian/control
colour sudo ./installDependsFromDebianFile.py ./../src/MCPrpcCLI/debian/control
colour sudo ./installDependsFromDebianFile.py ./../src/MCPServer/debian/control
colour sudo pip install -r ../src/dashboard/src/requirements/production.txt
cd ..
else
echo "Not going to ${part}."
fi
}
function recreate-db() {
part="recreate the databases"
echo -n "\"Would you like to ${part}?\" (y/N) "
read a
if [[ $a == "Y" || $a == "y" ]]; then
echo "Going to ${part} ..."
cd localDevSetup/
sudo stop archivematica-mcp-server
sudo stop archivematica-mcp-client
sudo apache2ctl stop
colour ./recreateDB.sh
cd ..
sudo start archivematica-mcp-server
sudo start archivematica-mcp-client
sudo apachectl start
else
echo "Not going to ${part}."
fi
}
function erase-indexes() {
part="erase the ElasticSearch indexes"
echo -n "\"Would you like to ${part}?\" (y/N) "
read a
if [[ $a == "Y" || $a == "y" ]]; then
localDevSetup/eraseElasticSearchIndexes.py -f
else
echo "Not going to ${part}."
fi
}
function clear-storage() {
part="clear transfer backlog, uploaded DIPs, and AIP & DIP storage"
echo -n "\"Would you like to ${part}?\" (y/N) "
read a
if [[ $a == "Y" || $a == "y" ]]; then
set -x
sudo rm -rf /var/archivematica/sharedDirectory/www/AIPsStore/transferBacklog/originals/*
sudo rm -rf /var/archivematica/sharedDirectory/watchedDirectories/uploadedDIPs/*
sudo rm -rf /var/archivematica/sharedDirectory/www/AIPsStore/????
sudo rm -rf /var/archivematica/sharedDirectory/www/DIPsStore/*
set +x
else
echo "Not going to ${part}"
fi
}
function restart() {
part="restart archivematica services"
echo -n "\"Would you like to ${part}?\" (y/N) "
read a
if [[ $a == "Y" || $a == "y" ]]; then
echo "Going to ${part} ..."
sudo stop archivematica-mcp-server
sudo stop archivematica-mcp-client
sudo /etc/init.d/gearman-job-server stop
sudo /etc/init.d/elasticsearch stop
sleep 1
if [ -e "/tmp/archivematicaMCPServerPID" ]
then
sudo kill -9 `cat /tmp/archivematicaMCPServerPID`
fi
sleep 3
sudo /etc/init.d/elasticsearch start
sudo /etc/init.d/gearman-job-server start
sudo rm /var/log/archivematica/*
sudo rm /var/log/archivematica/dashboard/*
sudo rm /var/log/archivematica/MCPClient/*
sudo rm /var/log/archivematica/MCPServer/*
colour sudo start archivematica-mcp-server
colour sudo start archivematica-mcp-client
colour sudo apache2ctl restart
else
echo "Not going to ${part}."
fi
}
function update-sampledata() {
part="update sample data in $HOME/archivematica-sampledata"
echo -n "\"Would you like to ${part}?\" (y/N) "
read a
if [[ $a == "Y" || $a == "y" ]]; then
if [ ! -d ~/archivematica-sampledata ]; then
cd
colour git clone https://github.com/artefactual/archivematica-sampledata.git
else
cd ~/archivematica-sampledata
colour git pull
fi
cd `dirname $0`
else
echo "Not going to ${part}."
fi
}
function export-sampledata() {
part="export sample data from $HOME/archivematica-sampledata"
echo -n "\"Would you like to ${part}?\" (y/N) "
read a
if [[ $a == "Y" || $a == "y" ]]; then
cd ~/archivematica-sampledata
DATE=`date +%Y-%m-%d-%H-%M-%S`
exportDir="$HOME/archivematica-sampledata-$DATE"
echo exporting to "${exportDir}"
mkdir "${exportDir}"
git archive master | tar -x -C "${exportDir}"
git submodule foreach "cd ~/archivematica-sampledata &&
cd \"\$path\" &&
git archive master | tar -x -C \"${exportDir}/\$path\""
cd `dirname $0`
else
echo "Not going to ${part}."
fi
}
function example() {
part="example"
echo -n "\"Would you like to ${part}?\" (y/N) "
read a
if [[ $a == "Y" || $a == "y" ]]; then
echo "Going to ${part} ..."
else
echo "Not going to ${part}"
fi
}
# Run only one function if given
if [ ! -z ${1} ]; then
${1}
exit
fi
git-pull
package-update
recreate-db
erase-indexes
clear-storage
restart
update-sampledata
export-sampledata