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-Assignment-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
156 lines (141 sloc)
4.29 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 SCRIPT | |
# run this script to install all the required tools and packages. | |
red=`tput setaf 1` | |
green=`tput setaf 2` | |
reset=`tput sgr0` | |
echo "SETUP SCRIPT FOR CODIO DYNAMIC WEBSITE ASSIGNMENT TEMPLATE" | |
echo "This installer will delete all the files currently in your Codio Box." | |
echo | |
if [ -v CODIO_HOSTNAME ] | |
then | |
echo "Codio box detected" | |
echo "continuing setup" | |
else | |
echo "no Codio box detected" | |
echo "exiting setup" | |
exit 0 | |
fi | |
sudo chown -R codio:codio . | |
sudo chmod -R 775 . | |
echo | |
echo "============== ${green}DELETING${reset} OLD FILES ===================" | |
rm -rf * | |
rm -rf .* | |
rm -rf .guides | |
echo | |
echo "============== CLONING ${green}REPOSITORY${reset} ===================" | |
git clone https://github.coventry.ac.uk/web/Codio-Assignment-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 | |
echo "============== UPDATING ${green}DEBIAN${reset} TOOLS ===============" | |
sudo add-apt-repository -y ppa:git-core/ppa | |
sudo apt update -y | |
sudo apt upgrade -y | |
echo | |
echo "============= INSTALLING ${green}DEBIAN${reset} TOOLS ==============" | |
sudo apt install -y psmisc lsof tree sqlite3 sqlite3-doc build-essential gcc g++ make git | |
git --version | |
echo | |
echo "============== CHANGING ${green}BASH PROMPT${reset} ================" | |
echo "PS1='$ '" >> ~/.profile | |
source ~/.profile | |
echo "=============== INSTALLING ${green}ACT${reset} TOOL ================" | |
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash | |
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 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 "=========== SETTING THE ${green}FILE PERMISSIONS${reset} ===========" | |
sudo chown -R codio:codio . | |
sudo chmod -R 775 . | |
echo | |
echo "============== RUNNING THE ${green}UNIT TESTS${reset} ==============" | |
npm test | |
echo | |
echo "================ RUNNING THE ${green}LINTER${reset} ================" | |
npm run linter | |
echo | |
echo "===== CHECKING THE VERSION OF ${green}NODEJS${reset} INSTALLED =====" | |
node -v | |
echo | |
echo "================= CONFIGURING ${green}GIT${reset} ==================" | |
git config core.hooksPath .githooks | |
git config --global merge.commit no | |
git config --global merge.ff no | |
echo | |
echo "============ INSTALLING LOGGER TOOL ============" | |
curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.7.1 | |
mv -f /home/codio/workspace/logger.sh /home/codio/logger.sh | |
chmod +x /home/codio/logger.sh | |
mv -f /home/codio/workspace/stats.js /home/codio/stats.js | |
chmod +x /home/codio/stats.js | |
touch /home/codio/log.csv | |
sudo chown codio:codio /home/codio/log.csv | |
sudo chmod 775 /home/codio/log.csv | |
touch /home/codio/reset_history.csv | |
sudo chown codio:codio /home/codio/reset_history.csv | |
sudo chmod 775 /home/codio/reset_history.csv | |
sudo -s <<EOF | |
(crontab -l ; echo "*/5 * * * * /home/codio/logger.sh")| crontab - | |
EOF | |
sudo service cron reload | |
TIMESTAMP=`date +"%s"` | |
DATE=`date +"%D"` | |
TIME=`date +"%T"` | |
LOG="$TIMESTAMP,$DATE,$TIME" | |
echo $LOG >> /home/codio/reset_history.csv | |
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 | |
if grep TMPDIR ~/.profile | |
then | |
echo "temp directory set correctly" | |
else | |
echo "need to set temp directory" | |
echo "export TMPDIR=/home/codio/workspace/tmp/" >> ~/.profile | |
fi | |
source ~/.profile | |
echo | |
echo "================= ${green}SETUP COMPLETED ${reset} =================" |