Last active
August 31, 2018 02:57
-
-
Save disulfidebond/c0c5d7c633a0f5c530d9c95d439e6bec to your computer and use it in GitHub Desktop.
Script that automates labkey setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo 'WARNING!! THIS SETUP IS NOT INTENDED' | |
echo 'FOR A PRODUCTION ENVIRONMENT IN ANY CAPACITY!!!' | |
sleep 3 | |
STARTDIR=$(PWD) | |
mkdir installspacepg | |
cd ./installspacepg | |
# install subversion | |
echo 'Beginning setup' | |
sudo apt-get update | |
sudo apt-get install subversion | |
# install and configure tomcat | |
echo 'setting up tomcat' | |
sudo groupadd tomcat | |
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat | |
echo 'This link has been hardcoded and may not work...' | |
sleep 1 | |
wget http://www-eu.apache.org/dist/tomcat/tomcat-8/v8.5.33/bin/apache-tomcat-8.5.33.tar.gz | |
filename=$(ls | grep tomcat.*.tar.gz) | |
file_size_kb=`du -k "$filename" | cut -f1` | |
if ((file_size_kb < 7000)) ; then echo 'WARNING! tomcat file possible corrupted! Exiting...' ; exit 1 ; fi | |
echo 'A cursory check did not reveal any problems with the tomcat download.' | |
echo 'However, if you would like to verify the checksum, stop the script and do so' | |
echo 'Otherwise, installation will continue in 5 seconds...' | |
sleep 7 | |
if [ ! -d /opt/tomcat ] ; then | |
sudo mkdir /opt/tomcat | |
sudo tar xzvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1 | |
else | |
echo 'WARNING! It looks like tomcat has already been installed!' | |
echo 'Please verify it has not, and that the directory /opt/tomcat does not exist' | |
echo 'Exiting...' | |
exit 2 | |
fi | |
cd /opt/tomcat/ | |
sudo chgrp -R tomcat /opt/tomcat | |
sudo chmod -R g+r conf | |
sudo chmod g+x conf | |
sudo chown -R tomcat webapps/ work/ temp/ logs/ | |
sudo cp tomcat.service tomcat.bk # in case things go...poorly | |
JAVA_HOME=$(sudo update-java-alternatives -l | rev | cut -d\ -f1 | rev) | |
JHOME=$(echo "$JAVA_HOME" | sed 's#/#\\/#g') | |
# hat trick: use alternative syntax to format the string in sed as \/usr\/local | |
# thus when variable expansion occurs, sed will write /usr/local | |
sed -i -e "s/JAVA_HOME=.*/JAVA_HOME=$JHOME/g" tomcat.service | |
# finish setup | |
sudo systemctl daemon-reload | |
sudo systemctl start tomcat | |
CHECKTOMCAT=$(sudo systemctl status tomcat | grep Active | cut -d: -f1 | tr -d '\ ') | |
if [[ "$CHECKTOMCAT" = 'Active' ]] ; then echo 'Tomcat running' ; else echo 'WARNING! Tomcat does not appear to be active. Exiting...' ; exit 3 ; fi | |
sudo ufw allow 8080 | |
echo 'enabling Tomcat to always run on startup' | |
sudo systemctl enable tomcat | |
# postgresql setup | |
sudo apt-get install postgresql postgresql-contrib | |
PGRESCONF=$(sudo find /etc/postgresql -name 'pg_hba.*' -print) | |
sudo sed -i '1s/^/local postgres postgres peer/' file | |
sudo service postgresql restart | |
echo 'In the resulting prompt, type the following, replacing $PASSWORDSTRING with your desired password' | |
echo 'followed by pressing the return key:' | |
echo '' | |
echo "ALTER USER postgres PASSWORD 'PASSWORDSTRING'; \q" # note: this has not been tested, alternative is to press Ctrl-D | |
sleep 1 | |
sudo -u postgres psql | |
sleep 2 | |
echo 'reverting postgresql' | |
sed -i.bak '1d' sedTest.txt | |
sudo service postgresql restart | |
# other env variables | |
echo 'export CATALINA_HOME=$HOME/apps/tomcat' >> ${HOME}/.bashrc | |
echo 'export LABKEY_HOME=$HOME/labkey/trunk' >> ${HOME}/.bashrc | |
echo 'export LABKEY_GWT_USER_OVERRIDE="gwt-user-firefox"' >> ${HOME}/.bashrc | |
echo 'export PATH=$LABKEY_HOME/build/deploy/bin:$PATH' >> ${HOME}/.bashrc | |
# NOTE: if using LabKey < 18.2, also complete the Node.js and npm steps | |
echo 'Setup complete. Please open a new bash window' | |
echo 'and complete the steps for Gradle Configuration at' | |
echo 'https://www.labkey.org/Documentation/wiki-page.view?name=devMachine' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment