Created
July 29, 2015 21:22
-
-
Save NanoSmasher/f100ccecfde8240bed63 to your computer and use it in GitHub Desktop.
This script aids in management of a UofT Skule Engineering website domain (*.skule.ca) w/Github & Jekyll. More information in file.
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 | |
# This script aids in management of a UofT Skule Engineering website domain (*.skule.ca) w/Github & Jekyll. | |
# To run it, create a Cron Job with "bash skule.sh >> ~/skule.log 2>&1". | |
# Don't forget to edit the GIT_USER and GIT_REPO variables or else you be using my website! | |
# The script uses Jekyll to build websites hosted by github repository. Jekyll is flexible and easy to use so try it. | |
# The default Ruby version in the linode is 1.8.7 which is not supported by Jekyll. | |
# YAML, Ruby 2.1.1, bundler, and gh-pages are dependancies to get Jekyll working without root or admin priviledges. | |
# When the script is finished, it should create a update.sh file. | |
# Set an interval to run the "bash update.sh >> ~/build.log 2>&1" Cron Job (deleting the skule.sh cron job) | |
# Define Github repository | |
export GIT_USER=NanoSmasher | |
export GIT_REPO=make.skule.ca | |
# Install YAML | |
cd $HOME | |
mkdir libyaml | |
cd libyaml | |
wget --no-check-certificate http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz | |
tar xvzf yaml-0.1.6.tar.gz | |
cd yaml-0.1.6 | |
./configure --prefix=$HOME/libyaml/yaml-0.1.6-install | |
make | |
make install | |
# Install Ruby 2.1.1 | |
cd $HOME | |
mkdir ruby-2.1.1 | |
cd ruby-2.1.1 | |
wget --no-check-certificate https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz | |
tar xvzf ruby-2.1.1.tar.gz | |
cd ruby-2.1.1 | |
./configure --prefix=$HOME/ruby-2.1.1/ruby-2.1.1-install --with-opt-dir=$HOME/libyaml/yaml-0.1.6-install | |
make | |
make install | |
export PATH="$HOME/ruby-2.1.1/ruby-2.1.1-install/bin:$PATH" | |
# Install Jekyll via Bundler and gh-pages | |
cd $HOME | |
gem install bundler | |
echo "source 'https://rubygems.org'" > Gemfile | |
echo "gem 'execjs'" >> Gemfile | |
echo "gem 'therubyracer'" >> Gemfile | |
echo "gem 'github-pages'" >> Gemfile | |
bundle install | |
# Download and host website | |
git clone https://github.com/$GIT_USER/$GIT_REPO.git | |
cd $GIT_REPO | |
bundle exec jekyll build | |
mv $HOME/public_html $HOME/backup_public_html | |
ln -s $HOME/$GIT_REPO/_site $HOME/public_html | |
# Create website update file | |
echo "export GIT_USER=$GIT_USER" > update.sh | |
echo "export GIT_REPO=$GIT_REPO" >> update.sh | |
echo 'export PATH="$HOME/ruby-2.1.1/ruby-2.1.1-install/bin:$PATH"' >> update.sh | |
echo 'cd "$GIT_REPO"' >> update.sh | |
echo 'git pull' >> update.sh | |
echo 'bundle exec jekyll build' >> update.sh | |
# Cleaning up | |
rm $HOME/libyaml/yaml-0.1.6.tar.gz | |
rm -r $HOME/libyaml/yaml-0.1.6 | |
rm $HOME/ruby-2.1.1/ruby-2.1.1.tar.gz | |
rm -r $HOME/ruby-2.1.1/ruby-2.1.1 | |
echo "Finished" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment