deploy.sh 1.94 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#!/bin/sh
# Running as the 'gliders' user, fetch and deploy the
# backend tools and website. This script will download
# all our logs from various dockservers and
# migrates data (such as users) from the old gliders
# website database.

# Generate a SSH key
# We want passwordless authentication when logging into
# dockservers from scripts etc.
ssh-keygen

13 14 15 16 17
echo "Please copy the public key on your gitlab account with the name gliders"
cat /home/gliders/.ssh/id_rsa.pub
echo "Plese press return when you are done"
read

18 19 20
#We need to go to the gliders home directory first
cd /home/gliders

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
# Install Composer
mkdir -p /home/gliders/bin
curl -sS https://getcomposer.org/installer | php -- --install-dir=bin
ln -s /home/gliders/bin/composer.phar /home/gliders/bin/composer

# Set up python environment and directories
mkdir -p /home/gliders/code
mkdir -p /home/gliders/pythonenv
mkdir -p /var/gliders/www /var/gliders/www_dev /var/gliders/logs
virtualenv /home/gliders/pythonenv --system-site-packages
echo 'source /home/gliders/pythonenv/bin/activate' >> /home/gliders/.bash_profile
source /home/gliders/pythonenv/bin/activate

cd /home/gliders/code
# Add contents of /home/gliders/.ssh/id_rsa.pub to GitLab, then:
git clone git@gitlab.noc.soton.ac.uk:owanes/gliders-tools.git
git clone git@gitlab.noc.soton.ac.uk:owanes/gliders-website.git

# Install the gliders DB and parser python libraries,
# then fetch all our log files and parse them!
cd gliders-tools
python setup.py install

44 45 46 47 48
echo "please enter your mysql root user password"
read -s pass
mysql -u root -p$pass < new_schema.sql
echo "CREATE USER 'gliders'@'%' IDENTIFIED BY '"$pass"' ;" | mysql -u root -p$pass
echo "GRANT ALL ON gliders.* TO 'gliders'@'%';" | mysql -u root -p$pass
49
cd bin
50
sh migrate_data.sh
51

Owain Jones's avatar
Owain Jones committed
52 53 54
# Set up a GitHub API key and add it to .bash_profile
# export API_KEY=...

55 56
# Deploy the website
cd /home/gliders/code/gliders-website
57
sh bin/deploy.sh /var/gliders/www_dev dev
Owain Jones's avatar
Owain Jones committed
58
sh bin/deploy.sh /var/gliders/www prod