Skip to content

Instantly share code, notes, and snippets.

@augmt
Last active April 15, 2017 19:31
Show Gist options
  • Save augmt/7dec640ae56ed370a3e64f1e3e60e2c2 to your computer and use it in GitHub Desktop.
Save augmt/7dec640ae56ed370a3e64f1e3e60e2c2 to your computer and use it in GitHub Desktop.
initialize freecodecamp on a fresh chroot
#!/usr/bin/env bash
echo -e '\nInstalling git ...\n'
# install apt-add-repository
sudo apt-get install -y software-properties-common
# get the most current stable version of git
sudo apt-add-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install -y git
echo -e '\nConfiguring git ...\n'
read -p 'Enter your full name: ' name
read -p 'Enter your email address: ' email
git config --global user.name "$name"
git config --global user.email "$email"
git config --global push.default simple
echo -e '\nInstalling Node.js ...\n'
# install curl
sudo apt-get install -y curl
# install node.js via package manager
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
# fix npm permissions
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
sed -i '$ a\\nexport PATH=~/.npm-global/bin:'"$PATH" ~/.profile
source ~/.profile
echo -e '\nInstalling MongoDB ...\n'
MONGODB_VERSION=3.2.11
MONGODB_ARCHIVE=mongodb-linux-x86_64-"$MONGODB_VERSION"
curl https://fastdl.mongodb.org/linux/"$MONGODB_ARCHIVE".tgz | sudo tar -xzf - -C /usr/local
echo -e '\nConfiguring MongoDB ...'
# create a symbolic link to the extracted mongodb directory
sudo ln -s /usr/local/"$MONGODB_ARCHIVE" /usr/local/mongodb
# create a dedicated user to run mongod
sudo groupadd -r mongodb
sudo useradd -r -g mongodb mongodb
sudo mkdir -p /data/db
sudo chown -R mongodb:mongodb /usr/local/"$MONGODB_ARCHIVE" /data/db
echo -e '\nSetting up local Free Code Camp repository ...\n'
# clone the latest revision of the freecodecamp repository
git clone --depth=1 https://github.com/freecodecamp/freecodecamp.git ~/Downloads/freecodecamp
cd ~/Downloads/freecodecamp || exit
# install dependencies
npm install
npm install -g gulp
# copy sample private environment variable file to .env
cp sample.env .env
# initialize freecodecamp
sudo -bu mongodb /usr/local/mongodb/bin/mongod
npm run only-once
sudo pkill mongod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment