• Stars
    star
    172
  • Rank 213,684 (Top 5 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple templating engine based on shell.

ESH – Embedded SHell

Build Status

esh (embedded shell) is a templating engine for evaluating shell commands embedded in arbitrary templates. It’s like ERB (Embedded RuBy) for shell, intended to be used for templating configuration files. Unlike ERB it provides support for including one ESH template into another (since version 0.2.0).

The template processing consists of two phases: conversion to a shell script and evaluation of that script. You can even run just the conversion phase: esh -d will dump a shell script that you can execute directly by a shell (even on a system without esh installed). However, in that case, you will not get error messages source-mapped to point to the locations in the template file.

esh is implemented in ~290 lines (LoC) of shell and awk.

Requirements

  • POSIX-sh compatible shell (e.g. Busybox ash, dash, ZSH, bash, …)

  • common Unix userland with awk and sed (e.g. from Busybox, GNU, …)

  • (Asciidoctor to build a man page)

Installation

Packaging status

Alpine Linux

Install package esh from the Alpine’s community repository:

apk add esh

Fedora

dnf install esh

Void Linux

xbps-install esh

On CI

You can add esh as a submodule into your repository or download it on demand, e.g.:

wget https://raw.githubusercontent.com/jirutka/esh/v0.3.2/esh \
    && echo '9084e3e8e70e4ea81c40cd1cf85559196c0fa2cc  esh' | sha1sum -c \
    || exit 1

Manually

  1. Download and unpack release tarball:

    wget https://github.com/jirutka/esh/archive/v0.3.2/esh-0.3.2.tar.gz
    tar -xzf esh-0.3.2.tar.gz
    cd esh-0.3.2
  2. Run tests:

    make test
  3. Build a man page and install esh:

    make install prefix=/usr/local DESTDIR=/

    or just copy esh whether you want, it’s a plain shell script.

Usage

Read man page esh(1).

Examples

http {
    access_log <%= $logs_dir/access.log %> main;

    resolver <%= $(sed -En 's/^nameserver ([^#]+)/\1/p' /etc/resolv.conf) %>;

    <% if nginx -V 2>&1 | grep -q lua-nginx-module; then -%>
    lua_package_path '<%= $(pkg-config --variable=INSTALL_LMOD lua) %>/?.lua';
    <% fi -%>

    <%+ ./http-common.esh %>

    <%# The rest of the config is omitted %>
}

Credits

ESH template syntax is based on ERB (Embedded Ruby).

Tests and some concepts are inspired by shellcat.

License

This project is licensed under MIT License. For the full text of the license, see the LICENSE file.

More Repositories

1

rsql-parser

Parser for RSQL / FIQL – query language for RESTful APIs
Java
685
star
2

spring-rest-exception-handler

A convenient Spring MVC exception handler for RESTful APIs.
Java
354
star
3

maven-badges

Badge for Maven Central
Ruby
240
star
4

ssh-ldap-pubkey

Utility to manage SSH public keys stored in LDAP.
Python
217
star
5

ldap-passwd-webui

Very simple web interface for changing password stored in LDAP or Active Directory (Samba 4 AD).
Python
198
star
6

luapak

Easily build a standalone executable for any Lua program
Lua
175
star
7

ngx-oauth

OAuth 2.0 proxy for nginx written in Lua.
Lua
156
star
8

validator-collection

The easiest way to validate collections of basic types using Bean Validation.
Java
120
star
9

smlar

PostgreSQL extension for an effective similarity search || mirror of git://sigaev.ru/smlar.git || see https://www.pgcon.org/2012/schedule/track/Hacking/443.en.html
C
110
star
10

tty-copy

Copy content to system clipboard via TTY and terminal using ANSI OSC52 sequence
C
89
star
11

setup-alpine

Easily use Alpine Linux on GitHub Actions, with support for QEMU user emulator
Shell
89
star
12

zsh-shift-select

Select text in Zsh command line using Shift, as in many text editors and GUI programs
Shell
88
star
13

validator-spring

Bean Validator utilizing Spring Expression Language (SpEL)
Java
84
star
14

asciidoctor-html5s

Semantic HTML5 converter (backend) for Asciidoctor
HTML
79
star
15

luasrcdiet

Compresses Lua source code by removing unnecessary characters (updated fork of http://luasrcdiet.luaforge.net/)
Lua
64
star
16

apk-autoupdate

Automatic updates for Alpine Linux and other systems using apk-tools
Shell
45
star
17

embedmongo-spring

Spring Factory Bean for “Embedded” MongoDB
Java
44
star
18

otf2bdf

OpenType to BDF Converter (unofficial mirror)
C
42
star
19

apcupsd-snmp

Apcupsd module for Net-SNMP
Perl
41
star
20

njs-typescript-starter

A starting template for developing njs (NGINX JavaScript) scripts for NGINX server in TypeScript.
JavaScript
40
star
21

nginx-binaries

Nginx and njs binaries for Linux (x86_64, aarch64, ppc64le), macOS and Windows. Linux binaries are static so works on every Linux.
TypeScript
35
star
22

doas-sudo-shim

sudo shim for doas
Shell
34
star
23

qemu-openrc

OpenRC init script for QEMU/KVM (for Gentoo and Alpine Linux)
Shell
30
star
24

rake-jekyll

Rake tasks for Jekyll as a gem.
Ruby
30
star
25

corefines

💎 A collection of refinements for Ruby core classes with a compatibility mode for older Rubies and a convenient syntactic sugar.
Ruby
26
star
26

user-aports

My Alpine Linux aports that are not in official repository yet or don’t adhere to Alpine polices (bundles)
Shell
26
star
27

akms

Alpine Kernel Module Support – aka DKMS for Alpine Linux
Shell
26
star
28

sh-parser

Parser of POSIX Shell Command Language
Lua
25
star
29

ipynb2html

Convert Jupyter (IPython) Notebooks to static HTML
TypeScript
24
star
30

asciidoctor-highlight.js

Asciidoctor.js extension for highlighting code in build time using Highlight.js
JavaScript
21
star
31

nginx-testing

Support for integration/acceptance testing of nginx configuration in TypeScript/JavaScript.
TypeScript
19
star
32

zzz

A simple program to suspend or hibernate your computer 💤
C
19
star
33

efi-mkuki

EFI Unified Kernel Image Maker
Shell
18
star
34

asciidoctor-rouge

Rouge code highlighter support for Asciidoctor (OBSOLETE)
Ruby
18
star
35

opensmtpd-filter-rewrite-from

OpenSMTPD 6.6+ filter for rewriting From address
Awk
17
star
36

asciidoctor-katex

Asciidoctor extension for converting latexmath using KaTeX at build time
Ruby
17
star
37

ssh-getkey-gitlab

A simple script to be used as AuthorizedKeysCommand in OpenSSH server to look up user’s public keys in GitLab or GitHub.
Shell
17
star
38

babel-preset-njs

A Babel preset for njs - NGINX JavaScript
JavaScript
16
star
39

unidecode

Transliteration from Unicode to US-ASCII and ISO 8859-2.
Java
14
star
40

haste-client

CLI client for haste-server (hastebin.com) written in Python
Python
13
star
41

ts-transformer-inline-file

A TypeScript custom transformer for inlining files
TypeScript
12
star
42

swaylockd

A dumb launcher to spawn swaylock and ensure it runs no matter what
C
11
star
43

ssh-getkey-ldap

A simple script to be used as AuthorizedKeysCommand in OpenSSH server to look up user’s public keys in LDAP.
Lua
11
star
44

alpine-zsh-config

A sensible system-wide Zsh configuration for Alpine Linux
Shell
11
star
45

argp

Rust derive-based argument parsing optimized for code size and flexibility
Rust
11
star
46

stunnel-static

stunnel built as a fully static binary
Shell
10
star
47

ansible-gentoo-roles

A curated list of Ansible roles for Gentoo Linux.
10
star
48

asciidoctor-include-ext

Asciidoctor’s standard include processor reimplemented as an extension
Ruby
9
star
49

rsql-hibernate

This project is outdated. Use https://github.com/tennaito/rsql-jpa instead.
Java
8
star
50

github-pr-closer

GitHub webhook handler for closing pull requests that have been merged using rebase etc.
Python
8
star
51

sloci-image

Simple script for creating single-layer OCI images.
Shell
8
star
52

dokuwiki2adoc

Converter from DokuWiki to AsciiDoc formatted text files.
Shell
8
star
53

brieflz.lua

Lua binding for BriefLZ compression library
C
7
star
54

spring-boot-openrc

OpenRC init script for Java applications based on Spring Boot
Shell
7
star
55

asciidoctor-interdoc-reftext

Asciidoctor extension providing implicit (automatic) reference text (label) for inter-document cross references
Ruby
7
star
56

muacme

A convenient wrapper for the ACMEv2 client uacme
Shell
6
star
57

rsub-client

Open and edit files from a remote machine in your local Sublime Text or TextMate 2.
Python
6
star
58

git-metafile

Store and restore files metadata (mode, owner, group) in a git repository
Rust
6
star
59

unboundid-spring

Spring Factory Beans for UnboundID LDAP SDK
Java
6
star
60

emscripten-travis-example

How to easily use Emscripten on Travis CI or any other CI
C
5
star
61

efi-mkkeys

Script to easily generate self-signed UEFI keys for Secure Boot
Shell
5
star
62

cesnet-tcs-cli

CLI client utility for CESNET TCS API
Shell
5
star
63

slava-ukrajine

Слава Україні! / Sláva Ukrajině! – grafika
4
star
64

alpkit

Rust library and CLI tool for reading Alpine Linux’s apk package format and APKBUILD
Rust
4
star
65

asciidoctor-templates-compiler

Compile templates-based Asciidoctor converter (backend) into a single Ruby file
Ruby
4
star
66

spring-http-client-cache

A very simple HTTP cache for the Spring’s RestTemplate.
4
star
67

one-context

OpenNebula contextualization scripts for Alpine Linux and Gentoo
Shell
4
star
68

uidmapshift

Shift UIDs/GIDs of directory entries recursively by some offset
Lua
4
star
69

yaml-env-tag

Custom YAML tag for referring environment variables in YAML documents
Ruby
3
star
70

mtype

An enhanced Lua type() function that looks for __type metafield
Lua
3
star
71

CSFD-parser

Parser for movie pages and search on CSFD.cz
Python
3
star
72

commons-hibernate

My collection of reusable Java classes for Hibernate.
Java
3
star
73

apk-deploy-tool

Tool for easily deploying applications or configuration packaged in APK packages via SSH
Shell
3
star
74

collectd-apk

Collectd plugin for apk-tools
C
2
star
75

tash

WIP
Shell
2
star
76

acpi-utils

ACPI utilities for use in scripts and one-liners
Shell
2
star
77

gversion.lua

Lua library for Gentoo-style versioning format
Lua
2
star
78

jabber-migrate

Tool for migration of a roster from one Jabber server to another.
Java
2
star
79

alpine-git-mirror-syncd

Lua script that listens on MQTT and synchronizes Git mirrors when notified about changes
Lua
2
star
80

spring-modular

Modularize Spring applications simply!
Java
2
star
81

spring-security-oauth-samples

Modified samples from Spring Security OAuth project
Java
2
star
82

virt-init

Provisioning scripts for Alpine Linux VMs
Shell
2
star
83

collectd-openrc

Collectd plugin for OpenRC
C
2
star
84

macos-init

Simplified cloud-init for macOS
Shell
2
star
85

com.meetfranz.Franz

Flatpak for Franz
1
star
86

prebackup

Pre/post backup scripts
Shell
1
star
87

slim-htag

Slim filter providing a heading tag with parametrized (dynamic) level (h1-h6)
Ruby
1
star
88

nginx-oidc-njs

OpenID Connect and OAuth 2.0 module for NGINX written in njs.
TypeScript
1
star
89

beuri-parser

Parser of Boolean Expressions in URI
Java
1
star
90

my-void-packages

My package templates for Void Linux
Shell
1
star
91

ts-transformer-export-default-name

TypeScript AST transformer that assigns name to anonymous functions and classes exported as default
TypeScript
1
star
92

ansible-modules

Some unofficial Ansible modules.
Python
1
star
93

roundcube-virtuser_ldap

A Roundcube plugin for LDAP based User-to-Email and Email-to-User lookup
PHP
1
star
94

sublimedsl

Simple pythonic DSL for generating Sublime Text configs.
Python
1
star
95

shaj

C
1
star
96

atom-jaxb

Custom JAXB classes for Atom Syndication Format
Java
1
star
97

maven-support

Parent POMs for my OSS projects.
1
star
98

connman-resolvconf

ConnMan integration with resolvconf(8)
Rust
1
star
99

redmine_agile

Archive of redmine_agile plugin downloaded from https://www.redmineup.com/pages/plugins/agile
Ruby
1
star
100

guacamole-dotool

A command-line Guacamole client and JS library for headless scripting (just like vncdotool, but over Guacamole)
TypeScript
1
star