Skip to content
Permalink
808edbd4d2
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 139 lines (113 sloc) 3.63 KB
#!/bin/bash
# SETUP HEROKU DEPLOYMENT TUTORIAL
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
echo
echo "======= CHECKING WE ARE ON A CODIO BOX ======="
if [ -v CODIO_HOSTNAME ]
then
echo "Codio box detected"
echo "continuing setup"
else
echo "no Codio box detected"
echo "exiting setup"
exit 1
fi
type=${CODIO_TYPE:-assignment}
if [ $type = "lab" ];
then
echo "YOU ARE TRYING TO RUN THIS IN A CODIO **LAB**"
echo "script should only be run in your box"
exit 1
fi
echo
echo "============== ${green}DELETING${reset} OLD FILES ==================="
sudo chown -R codio:codio .
sudo chmod -R 775 .
rm -rf *
rm -rf .*
rm -rf .guides
echo
echo "============== CLONING ${green}REPOSITORY${reset} ==================="
git clone https://github.coventry.ac.uk/web/Codio-Deno-Dynamic-Website-Template.git .
chmod +x .githooks/*
git remote rm origin
rm -rf install.sh # delete this script so it can't be run from inside the project!
rm .codio
mv codio.json .codio
echo
echo "============= DELETING ${green}TEMPORARY FILES${reset} =============="
rm -rf *.db # delete any old database files
rm -rf package-lock.json
rm -rf .settings
rm -rf .sqlite_history
rm -rf .bash_history
rm -rf .git # delete the repository we have cloned (if any)
echo "=============== CONFIGURING ${green}GIT${reset} ====================="
git init
git config core.hooksPath .githooks/
git config branch.master.mergeoptions "--no-ff"
echo
echo "============ INSTALLING PACKAGES ============"
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt update -y
sudo apt upgrade -y
sudo apt install -y psmisc lsof tree build-essential gcc g++ make jq curl git unzip
sudo apt autoremove -y
echo "============= INSTALLING MYSQL =============="
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password p455w0rd'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password p455w0rd'
sudo apt -y install mysql-server mysql-client
FILENAME="/etc/mysql/mysql.conf.d/mysqld.cnf"
SEARCH="127.0.0.1"
REPLACE="0.0.0.0"
sudo sed -i "s/$SEARCH/$REPLACE/gi" $FILENAME
# disable secure file privileges (so we can import a csv file)
echo 'secure_file_priv=""' | sudo tee -a /etc/mysql/mysql.conf.d/mysqld.cnf
mysql -u root -pp455w0rd website -e "DROP DATABASE IF EXISTS website; DROP USER IF EXISTS websiteuser;"
mysql -u root -pp455w0rd -e "create database website";
mysql -u root -pp455w0rd website < setup.sql
FILENAME="/etc/mysql/mysql.conf.d/mysqld.cnf"
SEARCH="127.0.0.1"
REPLACE="0.0.0.0"
sudo sed -i "s/$SEARCH/$REPLACE/gi" $FILENAME
# disable secure file privileges (so we can import a csv file)
echo 'secure_file_priv=""' | sudo tee -a /etc/mysql/mysql.conf.d/mysqld.cnf
echo
echo "====== INSTALLING ${green}DENO${reset} ======"
curl -fsSL https://deno.land/x/install/install.sh | sh
echo
echo "=============== INSTALLING ${green}HEROKU${reset} TOOL ================"
curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
echo
echo "=============== INSTALLING THE ${green}AWS${reset} TOOL ================"
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
rm awscliv2.zip
rm -rf aws/
echo
echo "========= CUSTOMISING SHELL PROMPT =========="
if grep PS1 ~/.profile
then
echo "correct prompt found"
else
echo "prompt needs updating"
echo "PS1='$ '" >> ~/.profile
fi
if grep deno ~/.profile
then
echo "path to deno executable found"
else
echo "path to deno executable needs adding"
echo "PATH='$PATH:$HOME/.deno/bin'" >> ~/.profile
fi
if grep clear ~/.profile
then
echo "clear prompt found"
else
echo "clear prompt needs adding"
echo "clear" >> ~/.profile
fi
source ~/.profile