forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·157 lines (117 loc) · 4.09 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·157 lines (117 loc) · 4.09 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
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
#!/bin/bash
set -e
#JAVA_OPTS="JAVA_OPTS=-Xmx1024m"
#ANT_OPTS="-q"
#MVN_OPTS="-q"
MVN_PROFILES=\!dspace-jspui,\!dspace-rdf,\!dspace-sword,\!dspace-swordv2
#,\!dspace-rest
# -Dhttp.proxyHost=10.1.0.27 -Dhttp.proxyPort=3128 -Dhttps.proxyHost=10.1.0.27 -Dhttps.proxyPort=3128"
cwd=`pwd`
DSPACE_SRC=$(dirname $(readlink -f $0))
DSPACE_DIR=$DSPACE_SRC/install
DSPACE_USER=`whoami`
TOMCAT="tomcat8"
PG_SRV="localhost"
#/var/dspace/source
#/var/dspace/install
install() {
if [ -d "$DSPACE_DIR" ] ; then
read -n 1 -p "El directorio de instalacion ( $DSPACE_DIR ) ya existe, desea eliminarlo [YySs]? "
if [[ ! $REPLY =~ ^[YySs]$ ]]; then
exit 1
fi
rm -fr $DSPACE_DIR
fi
mkdir $DSPACE_DIR
#si ya existe una instalacion vieja
#if db exists
#test:
psql -h $PG_SRV -Udspace_cic -W
dropdb --username=pg_root --host=$PG_SRV dspace_cic --if-exists -i
#endif
createdb --username=pg_root --encoding=UNICODE --owner=dspace_cic --host=$PG_SRV dspace_cic
#En caso que sea una versión snapshot, se compila en el nivel base de dspace-src para que maven encuentre las dependencias
cd $DSPACE_SRC
mvn install clean $MVN_OPTS -P $MVN_PROFILES
cd $DSPACE_SRC/dspace
mvn package $MVN_OPTS -P $MVN_PROFILES
sudo /etc/init.d/$TOMCAT stop
cd $DSPACE_SRC/dspace/target/dspace-installer/
ant fresh_install $ANT_OPTS
#importación de metadatos CIC
$DSPACE_DIR/bin/dspace dsrun org.dspace.administer.MetadataImporter -f $DSPACE_DIR/config/registries/cic-types.xml
$DSPACE_DIR/bin/dspace create-administrator
#if --deploy
rm -r /var/lib/$TOMCAT/webapps/ROOT
ln -s $DSPACE_DIR/webapps/xmlui/ /var/lib/$TOMCAT/webapps/ROOT
ln -s $DSPACE_DIR/webapps/solr/ /var/lib/$TOMCAT/webapps/solr
#endif
sudo /etc/init.d/$TOMCAT start
#Inicialización de los índices de discovery
./dspace index-discovery
}
update()
{
show_message "Actualizando la instalacion de DSpace. Esta operación suele demorar un par de minutos."
show_message "Actualizamos el código fuente de github"
cd $DSPACE_SRC
git stash && git pull --rebase && git stash pop
if [ "$1" = "--full" ]; then
show_message "Instalamos los recursos"
$JAVA_OPTS mvn install $MVN_OPTS -P $MVN_PROFILES
cd dspace
else
show_message "Empaquetamos dspace"
cd dspace
$JAVA_OPTS mvn package $MVN_OPTS -P $MVN_PROFILES
fi
show_message "Paramos el tomcat"
sudo /etc/init.d/$TOMCAT stop
#Limpiar cache XMLUI/Cocoon
#sudo rm /var/lib/$TOMCAT/work/Catalina/localhost/_/cache-dir/cocoon-ehcache.data
#sudo rm /var/lib/$TOMCAT/work/Catalina/localhost/_/cache-dir/cocoon-ehcache.index
show_message "actualizamos los sources"
cd target/dspace-installer
#TODO reusar el /var/dspace/install/config/GeoLiteCity.dat
$JAVA_OPTS ant update $ANT_OPTS
show_message "eliminamos directorios de bkp viejos"
ant clean_backups -Ddspace.dir=$DSPACE_SRC
#rm -r $DSPACE_DIR/bin.bak-* $DSPACE_DIR/etc.bak-* $DSPACE_DIR/lib.bak-* $DSPACE_DIR/webapps.bak-*
cd $DSPACE_SRC
$JAVA_OPTS mvn clean
show_message "iniciamos tomcat"
sudo /etc/init.d/$TOMCAT start
show_message "Se hicieron los siguientes reemplazos en la configuración"
find $DSPACE_DIR/config/ -name "*.old"
show_message "Se actualizó correctamente dspace"
cd $cwd
}
show_message()
{
echo "#################################################################################################"
echo "#################################################################################################"
echo "# $1 #"
echo "#################################################################################################"
echo "#################################################################################################"
}
if [ "`whoami`" != "$DSPACE_USER" ]; then
show_message "You must run this script using dspace user $DSPACE_USER"
exit 1
fi
case "$1" in
install)
install
;;
update)
if [ "$#" -gt 1 ] && [ "$2" != "--full" ]; then
show_message "Argumento invalido: $2"
exit 5
fi
update "$2"
;;
*)
echo "Usage: $0 {install|update [--full]}" >&2
exit 3
;;
esac
exit 0