thgtoa/script/serve-as-user
Sharp-tailed Grouse 7c1762289a
Move scripts to their own dir (aptly named script)
Move scripts to their own directory.
Add `serve` script for serving locally (from internal build repo).

Rename:
- clean.sh -> script/clean
- make.sh -> script/make

Now you can type `make serve` to serve the guide locally.

$ make <TAB>
all    clean  guide  serve

Requirements are still included in the `serve` file.

Signed-off-by: Sharp-tailed Grouse <sharptail@riseup.net>
2022-10-24 10:08:01 -04:00

49 lines
1.4 KiB
Bash

#!/bin/bash
# Prerequisites:
# 1. git
# 2. ruby
# 3. ruby-dev
#
# Script MUST be in the root of the git clone directory of your choice.
# You MUST execute it with elevated privileges.
#
# When done you can execute these commands:
# $ bundle exec jekyll serve --livereload (will build and serve the project locally)
# $ bundle exec jekyll build (will build the site in _site folder)
function pause()
{
read -p "$*"
}
echo add the following to your non-root .profile:
echo '''export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"'''
echo '''export PATH="$PATH:$GEM_HOME/bin"'''
pause 'Press [Enter] key to continue...'
sudo gem update # Errors are safely ignored.
gem install bundler --user-install # Speaks for itself.
gem install jekyll --user-install # Speaks for itself.
rm -f Gemfile* # Out with the old..
bundle init # ..and in with the new.
rm -rf ./vendor/ # In case `bundle init` above does anything weird.
# Creating the Gemfile we want
cat <<EOF >Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
# gem "rails"
# gem "jekyll", "~> 4.2"
gem "github-pages", group: :jekyll_plugins
gem "jekyll-optional-front-matter", group: :jekyll_plugins
gem "webrick", "~> 1.7"
EOF
bundle install --user-install # this will install gems and create a new Gemfile.lock
echo "Now you can test locally: "
echo "$ bundle exec jekyll serve --livereload"