-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall-jobsworth.sh
197 lines (160 loc) · 6.64 KB
/
install-jobsworth.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
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
#!/bin/bash
#This file is part of the jobsworth-installer program
#https://github.com/frank-orellana/jobsworth-installer
#Copyright (C) 2017 Franklin Orellana
#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, write to the Free Software Foundation,
#Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#WARNING:
#-This scrpit will overwrite info you may have on the jobsworth
echo "Starting installation..."
pushd `dirname $0` > /dev/null
mydir=`pwd`
popd > /dev/null
logfile="$mydir/install.log"
echo "* logfile: $logfile"
if (( $EUID != 0 )); then
echo 'ERROR: You dont have sudo rights. Execute the file like this: sudo install-jobsworth.sh' | tee $logfile
exit
else
echo '* Starting process...' | tee $logfile
fi
if [ -z "$NO_UPD_REP" ]; then
echo "* Updating system repositories. This might take several minutes..." | tee -a $logfile
echo "* (If you prefer not to update, set the env variable NO_UPD_REP=1)"
apt-get -qq update
fi
if [ -z "$NO_DB_SERVER" ]; then
echo "* Installing mysql (MariaDB)" | tee -a $logfile
echo "** If it is not already installed it might ask you for a new password for "
echo "** the ROOT user. DON'T FORGET THAT PASSWORD!!!"
echo "** It will be asked later to create the default database"
echo "** If no password is requested the default password is blank"
echo "** (If you prefer not to install it, set the env variable NO_DB_SERVER=1)"
echo "** Downloading MariaDB..."
apt-get -qqy install mariadb-server | tee -a $logfile
else
echo "** DB Server installation skipped" | tee -a $logfile
fi
if [ -z "$NO_DB" ]; then
echo "** Creating Jobsworth database."
echo "** Executing create-database.sql script... Enter mysql root password if asked" | tee -a $logfile
mysql -u root -p < installer-resources/create-database.sql
echo
echo "******************************************************************************"
echo "** Jobsworth database created. To access it you can type 'mysql -u jobsworth -p'" | tee -a $logfile
echo "******************************************************************************"
else
echo "** DB creation skipped" | tee -a $logfile
fi
echo
if [ -z "$NO_JDK" ]; then
if [ -z "$JDK" ]; then
echo "* Installing JAVA 8 JRE" | tee -a $logfile
jre=openjdk-8-jre
else
echo "* Installing JAVA 8 JDK" | tee -a $logfile
jre=openjdk-8-jdk
fi
JHF=$(update-java-alternatives -l | grep -o '/.*jvm/java-1.[89].*$')
if [ -z "$JHF" ]; then
java_available=$(apt-cache search $jre)
if [ -z "$java_available" ]; then
echo "** JAVA package not available. Adding source http://http.debian.net/debian jessie-backports main" | tee -a $logfile
echo deb http://http.debian.net/debian jessie-backports main >> /etc/apt/sources.list
echo "** Updating repositories..." | tee -a $logfile
apt-get -qq update
echo "** Repositories updated" | tee -a $logfile
echo "** Installing java $jre..." | tee -a $logfile
apt-get -qq -y install -t jessie-backports openjdk-8-jre-headless ca-certificates-java $jre
else
echo "** $jre is available to install"
echo "** Installing java $jre..." | tee -a $logfile
apt-get -qq -y install openjdk-8-jre-headless ca-certificates-java $jre | tee -a $logfile
fi
echo "** $jre installed..." | tee -a $logfile
JHF=$(update-java-alternatives -l | grep -o '/.*jvm/java-1.[89].*$')
if [ -z "$JHF" ]; then
echo "* ERROR: JAVA_HOME Not Found. Exiting" | tee -a $logfile
update-java-alternatives -l | tee -a $logfile
exit
else
echo "* JAVA_HOME FOUND: $JHF" | tee -a $logfile
JHF=$JHF/jre
fi
else
echo "** JAVA JRE 8 or 9 is already installed in $JHF" | tee -a $logfile
JHF=$JHF/jre
fi
else
echo "** JRE Installation skipped" | tee -a $logfile
fi
if [ -z "$NO_TOMCAT" ]; then
groupadd tomcat
useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat | tee -a $logfile
echo "* Downloading TOMCAT..." | tee -a $logfile
cd $mydir
wget --continue -nv http://archive.apache.org/dist/tomcat/tomcat-8/v8.5.23/bin/apache-tomcat-8.5.23.tar.gz | tee -a $logfile
echo "* TOMCAT dowloaded" | tee -a $logfile
mkdir -p /opt/tomcat | tee -a $logfile
tar -xzf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
echo "* TOMCAT extracted" | tee -a $logfile
echo "* Configuring TOMCAT..." | tee -a $logfile
cd /opt/tomcat
chgrp -R tomcat /opt/tomcat
chmod -R g+r conf
chmod g+x conf
chown -R tomcat webapps/ work/ temp/ logs/
chmod 775 -R conf/ logs/ webapps/
cd conf
find . -type f -exec chmod 664 -- {} +
cd ../webapps
find . -type f -exec chmod 664 -- {} +
cd $mydir
chmod +x installer-resources/configure-tomcat.sh | tee -a $logfile
. ./installer-resources/configure-tomcat.sh
echo "* TOMCAT has been installed. Please check its installation visiting http://localhost:8008 OR HTTP://<THIS_COMPUTER_IP>:8080 before continuing"
read -n 1 -s -p "Press ENTER to continue"
else
echo "** TOMCAT Installation skipped" | tee -a $logfile
fi
echo
echo "* Stopping TOMCAT"
systemctl stop tomcat
echo "* Downloading and Installing Jobsworth" | tee -a $logfile
cd /var
mkdir -p jobsworth/assets | tee -a $logfile
chown -R tomcat jobsworth
chgrp -R tomcat jobsworth
chmod -R 775 jobsworth
cd /opt/tomcat
rm -rf webapps/ROOT
echo "* Downloading WAR" | tee -a $logfile
cd $mydir
wget --continue -nv https://github.com/ari/jobsworth/releases/download/5.0b2/ROOT.war | tee -a $logfile
echo "* WAR Downloaded" | tee -a $logfile
cp ROOT.war /opt/tomcat/webapps
cd /opt/tomcat/webapps
chown tomcat ROOT.war
chgrp tomcat ROOT.war
systemctl start tomcat
echo "* TOMCAT STATUS:" | tee -a $logfile
systemctl status tomcat | grep Active: | tee -a $logfile
chmod 664 /opt/tomcat/logs/*
echo
echo "******************************************************************************"
echo "******************************************************************************"
echo "JOBSWORTH HAS BEEN INSTALLED" | tee -a $logfile
echo "THE INSTALLATION IS COMPLETE TYPE HTTP://LOCALHOST:8080 in the browser from "
echo "this computer OR HTTP://<THIS_COMPUTER_IP>:8080 FROM ANY OTHER"
echo "******************************************************************************"
echo "******************************************************************************"
echo