Permalink
Cannot retrieve contributors at this time
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?
Codio-API-Template/install.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
105 lines (91 sloc)
2.71 KB
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/bash | |
# SETUP RESTful API TEMPLATE | |
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 | |
sudo chown -R codio:codio . | |
# destructive section start | |
echo | |
echo "============== ${green}DELETING${reset} OLD FILES ===================" | |
rm -rf * | |
rm -rf .* | |
rm -rf .guides | |
rm -rf .git | |
echo | |
echo "============== CLONING ${green}REPOSITORY${reset} ===================" | |
git clone https://github.coventry.ac.uk/web/Codio-API-Template.git . | |
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) | |
# end of distructive section | |
echo | |
echo "========= CONFIGURING MYSQL ACCOUNT ==========" | |
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password CHANGEME' | |
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password CHANGEME' | |
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 | |
sudo apt -y install mysql-server mysql-client | |
sudo apt autoremove -y | |
echo | |
echo "========= INSTALLING NODE USING ${green}NODESOURCE${reset} =========" | |
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - | |
sudo apt install -y nodejs | |
echo | |
echo "=============== INSTALLING ${green}API-TEST${reset} ================" | |
curl -LJO https://raw.githubusercontent.com/subeshb1/api-test/master/api-test.sh | |
chmod +x api-test.sh | |
sudo mv api-test.sh /usr/local/bin/api-test | |
api-test --version | |
echo | |
echo "=========== INSTALLING THE ${green}NODE PACKAGES${reset} ===========" | |
echo | |
rm -rf node_modules | |
rm -rf package-lock.json | |
npm install | |
npm install --save-dev eslint ava # we WILL ensure these are installed! | |
npm audit fix | |
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 restart ~/.profile | |
then | |
echo "database restart command found" | |
else | |
echo "database restart command needs adding" | |
echo "sudo /etc/init.d/mysql restart" >> ~/.profile | |
fi | |
echo | |
echo "=========== CREATING DATABASE ==============" | |
mysql -u root -pCHANGEME < install.sql | |
rm -rf install.sql | |
source ~/.profile |