Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A bash script to automate the installation/setup of repl.it on local system.
#!/bin/bash
#
## @file setup-local-replit.sh
## @author Amber Jain
## @section DESCRIPTION A bash script to automate the installation/setup of repl.it on local system
## @section LICENSE ISC
#################
# Documentation #
#################
#
# This script automates the global installation and setup of:
# repl.it (https://github.com/replit/repl.it)
# on your local system for offline usage.
#
# Tested on:
# Ubuntu 12.04
#
# To run this script, change to the directory containing this script using 'cd'
# and then run the following commands on terminal:
# chmod +x setup-local-replit.sh
# ./setup-local-replit.sh
################################
# Setting up pretty print/echo #
################################
SELF_NAME=$(basename $0)
# Prints warning/error $MESSAGE in red foreground color
#
# For e.g. You can use the convention of using RED color for [E]rror messages
red_message() {
echo -e "\e[1;31m[E] $SELF_NAME: $MESSAGE\e[0m"
}
# Prints success/info $MESSAGE in green foreground color
#
# For e.g. You can use the convention of using GREEN color for [S]uccess messages
green_message() {
echo -e "\e[1;32m[S] $SELF_NAME: $MESSAGE\e[0m"
}
# Prints $MESSAGE in blue foreground color
#
# For e.g. You can use the convetion of using BLUE color for [I]nfo messages
# that require special user attention (especially when script requires input from user to continue)
blue_message() {
echo -e "\e[1;34m[I] $SELF_NAME: $MESSAGE\e[0m"
}
simple_blue_message() {
echo -e "\e[1;34m$MESSAGE\e[0m"
}
MESSAGE="Updating DEB package sources..." ; blue_message
sudo apt-get --assume-yes update
##############################
# Setup package manger stuff #
##############################
MESSAGE="Setting up system's package manager" ; blue_message
# For 'add-apt-repository'
sudo apt-get -y install python-software-properties
# CHECK: According to Ubuntu instructions at https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
# 'software-properties-common' is needed for 'add-apt-repository' in 12.10
#sudo apt-get -y install software-properties-common
MESSAGE="Adding official node.js PPA to /etc/apt/sources.list..." ; blue_message
# For node.js stable (https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager)
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get --assume-yes update
###########################################
# Get the repl.it source code from Github #
###########################################
# Install 'git'
MESSAGE="Installing 'git'..." ; blue_message
sudo apt-get -y install git
MESSAGE="Downloading repl.it source code..." ; blue_message
MESSAGE="This might take some time depending upon your network speed." ; blue_message
# ~1.5MB (as of March 2013)
git clone git://github.com/replit/repl.it.git
cd repl.it
# ~54MB (as of March 2013)
git submodule update --init --recursive
################################
# Install repl.it dependencies #
################################
# Install node.js
MESSAGE="Installing 'nodejs', 'npm' and 'nodejs-dev'..." ; blue_message
sudo apt-get -y install nodejs
sudo apt-get -y install npm
sudo apt-get -y install nodejs-dev
# Install CoffeeScript (using npm):
MESSAGE="Installing 'coffee-script' using npm..." ; blue_message
sudo npm install -g coffee-script
# Install Pygments:
MESSAGE="Installing 'Pygments' using easy_install..." ; blue_message
# Using easy_install:
sudo easy_install Pygments
# Alternative: Using pip:
#MESSAGE="Installing 'Pygments' using pip..." ; blue_message
#pip install Pygments
###############################################################
# OPTIONAL! Uncomment any of following lines if you need them #
###############################################################
# Install web browser (for using locally-installed repl.it's web interface)
#sudo apt-get -y install chromium-browser
# Install lightweight GUI IDE 'geany':
#sudo apt-get -y install geany
###################
# Running repl.it #
###################
# Update paths for global node.js installation:
MESSAGE="Setting/Updating environment variable NODE_PATH..." ; blue_message
export NODE_PATH=/usr/lib/node:/usr/lib/node_modules
MESSAGE="You might want to add the following line to ~/.bashrc :" ; blue_message
MESSAGE=" export NODE_PATH=/usr/lib/node:/usr/lib/node_modules" ; simple_blue_message
echo ; echo
# repl.it comes bundled with a static node HTTP file server and a CoffeeScript file watcher & (re)-compiler:
MESSAGE="Almost done!" ; simple_blue_message
MESSAGE="Now to start/run repl.it locally, run:" ; simple_blue_message
MESSAGE=" ./server.js 8888" ; simple_blue_message
MESSAGE="If all went well, repl.it can be opened in your web browser at:" ; simple_blue_message
MESSAGE=" http://localhost:8888/index.html" ; simple_blue_message
MESSAGE="Finished!" ; green_message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.