Skip to content

S0AndS0/Jekyll_Admin

Repository files navigation

Build Status means that tests defined within the travis.yml configuration file either passed or failed as of Last Commit.


Collection of Bash scripts for Jekyll and Git server administration and interaction via ssh or git command-line tools.

Unless otherwise stated both documentation and Bash scripts are shared under License (version 3) by default, a full copy of which is available under master:LICENSE

Documentation provides rendered documentation for this project; the source code modifications and raw doc-files of which can be found under the gh-pages branch. Installation, and Update instructions are currently featured along with usage examples for Administrators and Git/Jekyll clients.

Pull Requests freindly, however, please review GitHub's Fork help page, and the Contributing collection of this project for set-up and styling tips. Oh and don't forget to add yourself to the Contributors collection before first Pull Request.

Consider checking Supporting Options for methods of encouraging projects like these.


Requirements

  • Ruby version >= 2.1 for; Jekyll version 3.8.5, and Bundler version 1.17.3

  • Bash version >= 4 for; local -n _ref_one="${1}" and other fanciness at the shell level

  • Debian based Linux or the knowhow to install apt dependencies via another package manager


Quick start

The following should be preformed on a private server, VPS, RPi, etc...

    1. Install DNS and Web Server compatible with this project...
sudo apt-get install nginx unbound

Securing servers is currently outside the scope of this file and documentation for this project.

    1. Elivate to root level permissions and clone within a directory for source installed tools...
sudo su -
cd /usr/local/etc
git clone --recurse-submodules git@github.com:S0AndS0/Jekyll_Admin.git
cd Jekyll_Admin

Note, those that have cloned previously will need to git submodule update --init --recursive --remote --merge to download submodule source code.

    a Install via make if this is a fresh server...
make install-dependencies
make install
  • b ... or update via related make commands if this server is not so fresh...
make update
make install

    a For each group/domain run the jekyll_dnsconf.sh script, for each user run the jekyll_usermod.sh script, and for each repository of each user run the jekyll_wwwconf.sh script.

  • b Organize the list of users based off their shared group within some kind of data structure (in this case an associative array) and loop over it while utilizing project scripts to set-up things...

#!/usr/bin/env bash


declare -A _grouped_users=(
    ['admins']='Joan:Liz'
    ['devs']='Bill:Ted'
)

_key_dir="${HOME}/git_public_keys"
for _domain in "${!_grouped_users[@]}"; do
    for _user in ${_grouped_users[${_domain}]//:/ }; do
        _usermod_args=(
            '--user' "${_user}"
            '--group' "${_domain}"
            '--ssh-pub-key' "${_key_dir}/${_user,,}.pub"
        )
        case "${_domain}" in
            'admins')
                _usermod_args+=('--git-shell-copy-or-link' 'pushable')
            ;;
            *)
                if [[ "${_user,,}" != 'bill' ]]; then
                    _usermod_args+=('--git-shell-copy-or-link' 'pushable')
                fi
            ;;
        esac
        jekyll_usermod.sh "${_usermod_args[@]}"
        jekyll_wwwconf.sh --user "${_user}"\
                        --domain "${_domain}"\
                           --tld 'lan'\
                          --repo "${_user}"\
                        --server 'nginx'\
                       --clobber 'force'
    done
    if ! [ -f "/etc/unbound/unbound.conf.d/${_domain}.lan.conf" ]; then
        jekyll_dnsconf.sh --server 'unbound'\
                       --interface 'eth0'\
                          --domain "${_domain}"\
                             --tld 'lan'
    fi
done

The above will allow git pushes by a user to their own git-shell-commands directory, except for Bill who'll have scripts copied over but not setup with Git tracking; for reasons.

... and perhaps write a cron job script for occasionally adding configuration blocks as repositories are built into pages...

#!/usr/bin/env bash

_home_base='/srv'

declare -A _grouped_users=(
    ['admins']='Joan:Liz'
    ['devs']='Bill:Ted'
)

_wwwconf_args_base=(
    '--clobber' 'update'
    '--interface' 'eth0'
    '--server' 'nginx'
    '--tld' 'lan'
)

for _domain in "${!_grouped_users[@]}"; do
    for _user in ${_grouped_users[${_domain}]//:/ }; do
        _www_dir="${_home_base}/${_user}/www"
        [[ -d "${_www_dir}" ]] || continue
        for _srv_dir in "${_www_dir}/"*; do
            jekyll_wwwconf.sh ${_wwwconf_args_base[*]}\
                                --user "${_user}"\
                              --domain "${_domain}"
        done
    done
done

Note entr and other file system monitoring APIs maybe more efficient than what the above is doing.

    1. Notify Git/Jekyll users that server is ready to utilize git-shell-commands within their respective home directories
    1. If not using a cron job to keep web server configurations updated then use the jekyll_wwwconf.sh script's --clobber append or remove options for the desired results against a given --repo

Download Zip Members Issues Pull Requests

Directories

Administration Scripts

  • jekyll_usermod.sh, adds new user, with ssh-pub-key (git-shell access only), and installs the following to the home directory of the new user;

    • Jekyll, for translating MarkDown to HTML (HyperText Markup Language), just to list one of many things that Jekyll'll do
    • copy or link selected git-shell-command scripts, intended to simplify some of the repetitively redundant tasks involved with Git and Jekyll development
    • and initializes user named repo much like what GitHub makes available.
  • jekyll_dnsconf.sh, adds A records for interface, group/domain, and TLD (Top Level Domain), currently wired for Unbound DNS (Domain Name Server); note, some usage examples have been published for this script

  • jekyll_wwwconf.sh, adds {sub-}domain names to web server for given user/repo, currently wired for Nginx Web Server, check the published usage examples for examples of usage

About

Collection of Bash scripts for setting up private Git servers that emulate GitHub Pages.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published