Skip to content

Instantly share code, notes, and snippets.

@slickplaid
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slickplaid/1b6ff37e6ea907cbd187 to your computer and use it in GitHub Desktop.
Save slickplaid/1b6ff37e6ea907cbd187 to your computer and use it in GitHub Desktop.
Install Payroll Managers
#!/bin/bash
if [[ $EUID -eq 0 ]]; then
error "This script should not be run using sudo or as the root user."
exit 1
fi
command -v curl >/dev/null 2>&1 || { echo >&2 "Curl is required to install NVM. Install it using 'sudo apt-get install curl' on Ubuntu. Aborting."; exit 1; }
command -v git >/dev/null 2>&1 || { echo >&2 "Git is required to clone the code structure. Install it using 'sudo apt-get install git' on Ubuntu. Aborting."; exit 1; }
getAndRun() {
echo "Clone https://github.com/slickplaid/pm-accounthub"
DIRECTORY="pm-accounthub"
git clone https://github.com/slickplaid/pm-accounthub
if [ ! -d "$DIRECTORY" ]; then
echo "Failed to clone git repository. Make sure your shell has the appropriate permissions. Aborting. https://help.github.com/articles/generating-ssh-keys";
exit 1;
fi
echo "Install Node using NVM https://github.com/creationix/nvm"
curl https://raw.githubusercontent.com/creationix/nvm/v0.12.1/install.sh | bash
source ~/.nvm/nvm.sh
nvm install v0.10.29
nvm alias default v0.10.29
nvm use default
echo "Move into the directory and try to get all dependencies of pm-accounthub"
cd pm-accounthub
npm install
echo "Install forever, a node daemon manager. https://github.com/nodejitsu/forever"
npm install -g forever
echo ""
echo "Payroll Managers is now installed in `pwd`."
echo "You should be able to run the application now using"
echo "'cd pm-accounthub' and then running 'node app.js' or"
echo "run it as a daemon with 'forever start app.js'"
echo ""
exit 0;
}
# Make sure you want to run this script
printf "\033c"
echo "Install Payroll Managers"
echo ""
echo "Make sure you have
echo ""
echo " redis (http://redis.io/)"
echo " couchdb (http://couchdb.apache.org/)"
echo ""
echo "installed before continuing."
echo ""
echo "This will install the following:"
echo ""
echo " pm-accounthub - https://github.com/slickplaid/pm-accounthub"
echo " node/npm - http://nodejs.org/"
echo " nvm - https://github.com/creationix/nvm"
echo " forever - https://github.com/nodejitsu/forever"
echo ""
echo "It will be installed in a sub-directory relative to the folder you are currently in."
echo ""
echo " Directory: `pwd`/pm-accounthub"
echo ""
read -r -p "Are you sure you want to do this? [y/N] " response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y)$ ]]; then
getAndRun
else
echo "Aborting"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment