-
Notifications
You must be signed in to change notification settings - Fork 1
/
provisioning.sh
113 lines (88 loc) · 3.93 KB
/
provisioning.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
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
#!/bin/bash
# ___ ___ ___ ___
# /\ \ /\ \ /\__\ /\ \
# /::\ \ /::\ \ /:/ / /::\ \
# /:/\ \ \ /:/\:\ \ /:/ / /:/\:\ \
# _\:\~\ \ \ /:/ \:\ \ /:/ / /::\~\:\ \
# /\ \:\ \ \__\ /:/__/ \:\__\ /:/__/ /:/\:\ \:\__\
# \:\ \:\ \/__/ \:\ \ /:/ / \:\ \ \/_|::\/:/ /
# \:\ \:\__\ \:\ /:/ / \:\ \ |:|::/ /
# \:\/:/ / \:\/:/ / \:\ \ |:|\/__/
# \::/ / \::/ / \:\__\ |:| |
# \/__/ \/__/ \/__/ \|__|
#
# Assumption we are using Ubuntu Trusty 64 bits (14.04)
# Apache Solr 4.10.2
# Vagrant provisioning script
# Author: Patrick van Efferen
# Variables.
solr_version="4.10.2"
tomcat_version="tomcat7"
logging_location="/usr/share/solr"
# First we update apt
echo "Updating apt"
sudo apt-get update && sudo apt-get upgrade -y
# Install tomcat
echo "Installing Tomcat"
sudo apt-get install tomcat7 tomcat7-admin -y
# Download Solr in the the directory and extract install.
if [ ! -f "/usr/share/solr/solr.war" ]; then
cd /tmp
# Download Solr
wget http://archive.apache.org/dist/lucene/solr/$solr_version/solr-$solr_version.tgz
tar xf solr-$solr_version.tgz
fi
# Check for solr base directory, if not create it.
if [ ! -d "/usr/share/solr" ]; then
# Create the Solr base directory.
sudo mkdir -p /usr/share/solr
# Copy all default cores and settings to the Solr base directory.
sudo cp -r solr-$solr_version/example/multicore/* /usr/share/solr
# All Solr file need to be owned by the Tomcat user.
sudo chown -R $tomcat_version /usr/share/solr
fi
# # Install Solr if it is not yet installed.
# if [ ! -f "/usr/share/tomcat7/webapps/solr.war" ]; then
# echo "Install Solr"
# # Copy the Solr webapp and the example multicore configuration files:
# sudo mkdir /usr/share/tomcat6/webapps
# sudo cp /tmp/solr-4.3.1/dist/solr-4.3.1.war /usr/share/tomcat6/webapps/solr4.war
# # sudo cp -R /tmp/solr-4.3.1/example/multicore/* /var/solr/
# # Copy other solr files to solr base directory.
# sudo cp -R /tmp/solr-4.3.1/* /usr/share/solr4/
# # Copy Log4J libraries.
# sudo cp /tmp/solr-4.3.1/example/lib/ext/* /usr/share/tomcat6/lib/
# fi
if [ ! -f "/usr/share/solr/solr.war" ]; then
sudo cp /tmp/solr-$solr_version/example/webapps/solr.war /usr/share/solr
# From the Apache Solr lib, copy all the jar files to the tomcat lib.
sudo cp -r /tmp/solr-$solr_version/example/lib/ext/* /usr/share/$tomcat_version/lib
sudo cp -r /tmp/solr-$solr_version/example/resources/log4j.properties /usr/share/$tomcat_version/lib
# Set the logging base direcotry to the solr direcotry. (todo change to var.)
sudo sed -i '/solr\.log/ c\solr.log=/usr/share/solr' /usr/share/$tomcat_version/lib/log4j.properties
fi
# Add configuration to settings file.
echo "Configuring Solr"
sudo echo "<Context docBase=\"/usr/share/solr/solr.war\" debug=\"0\" privileged=\"true\"
allowLinking=\"true\" crossContext=\"true\">
<Environment name=\"solr/home\" type=\"java.lang.String\"
value=\"/usr/share/solr\" override=\"true\" />
</Context>" > /etc/$tomcat_version/Catalina/localhost/solr.xml
# Set filepermissions
echo "Set filepermissions"
# sudo chmod -R 2755 /usr/share/solr4
# sudo chmod -R 2775 /usr/share/solr4/triquanta/multicore/
# sudo chmod -R o+x /usr/share/tomcat6/lib
# # Configure log4j logging
# echo "Configure log4j loggin"
# sudo cp /usr/share/solr4/triquanta/resources/log4j.properties /usr/share/tomcat6/lib
# sudo chown tomcat6:tomcat6 /usr/share/tomcat6/lib/log4j.properties
# Setup Tomcat user.
echo "Setup Tomcat user."
sudo echo "<tomcat-users>
<role rolename=\"manager-gui\"/>
<user username=\"admin\" password=\"secret\" roles=\"manager-gui\"/>
</tomcat-users>" > /etc/$tomcat_version/tomcat-users.xml
# Restart Tomcat server
sudo service $tomcat_version restart
echo "Ubuntu, $tomcat_version and solr-$solr_version have been installed."