libscriptOpen on GitHub

Cross-platform/bin/sh; cmd.exescripts library for: Windows; Linux; macOS; FreeBSD; SunOS; &etc.

See also libscript’s: WHY.md; ROADMAP.md; and IDEAS.md. For testing see TEST.md.

Finally, see the official website with generated cross-linked hosted libscript documentation @ https://verMan.io

Features

OS support for:

Relocatable; no need to cd into the scripts directory.

Library directory structure is super-readable and modular.

Plenty of guards everywhere—idempotency style—so scripts can be interdependent—and rerun—without worry.

Dockerfiles are generated. These are well optimised for Docker’s cache mechanism.

Example of generated files are found in the gen directory.

Current ‘installables’

Care is taken to use open-source alternatives. For example: Valkey [and Garnet for Windows] over Redis; and FerretDB over MongoDB.

Toolchains

Name Parameters
Node.js NODEJS_VERSION*
Python PYTHON_VERSION*
Rust RUST_VERSION*

Databases / storage layers

Name Parameters
PostgreSQL POSTGRESQL_VERSION†; POSTGRES_USER†; POSTGRES_PASSWORD‡; POSTGRES_PASSWORD_FILE‡; POSTGRES_HOST; POSTGRES_DB
Valkey [Redis fork]

Servers

Name Parameters
nginx VARS

History / roadmap:

  1. First version was written in Python (59+ repos with “off” prefix) for mostly Linux (Ubuntu) with a bit of work for Debian support;
  2. Second version being written in /bin/sh [this repo] targeting macOS; Linux (.deb, .rpm, .apk (Alpine Linux) distributions); SunOS; *BSDs; and cmd.exe for Windows;
  3. Third version being written in C [C89], targeting all the above + DOS and OS/360. libacquire will become the base of this.

Advantage of this repo

Generally these scripts are extremely portable and could be used to benchmark and security-audit any:

Advantage of C repo(s)

All the aforementioned advantages, plus:

Usage

NOTE: You might want to manually set LIBSCRIPT_DATA_DIR; LIBSCRIPT_BUILD_DIR; and LIBSCRIPT_TOOLS_DIR.

Run from the same directory as this README.md file. Alternatively, set SCRIPT_NAME to the correct install.sh location and run it anywhere.

$ # Replace `$(pwd)` if not in the 'libscript' directory.
$ export LIBSCRIPT_ROOT_DIR="$(pwd)"
$ # Disable all options (everything set to do-*not*-install)
$ . "${LIBSCRIPT_ROOT_DIR}"'/conf-no-all.env.sh'
$ # Enable installation of *just* Jupyter Hub
$ export JUPYTERHUB_INSTALL=1
$ # Set script location.
$ export SCRIPT_NAME="${LIBSCRIPT_ROOT_DIR}"'/install.sh'
$ . "${SCRIPT_NAME}"

See gen/env.sh for options that can be overridden by setting environment variables.

Usage (JSON)

To simplify usage, a JSON file format is provided. See ./install.json for an example.

Usage (JSON) CLI

$ ./create_installer_from_json.sh -h
Create install scripts from JSON.

  -a whether to install all dependencies (required AND optional)
  -f filename
  -o output folder (defaults to ./tmp)
  -v verbosity (can be specified multiple times)
  -b base images for docker (space seperated, default: "alpine:latest debian:bookworm-slim")
  -h show help text

Which will create these files:

env.sh ; env.cmd

Default environment. When nothing preexists in your env, this sets everything to install.

false_env.sh ; false_env.cmd

False environment. This sets everything to not install.

install_gen.sh ; install_gen.cmd

The actual installation script. Execute this like so:

$ # Set script location. Change from `pwd` if 'install_gen.sh' isn't in current dir.
$ export LIBSCRIPT_ROOT_DIR="$(pwd)"
$ export SCRIPT_NAME="${LIBSCRIPT_ROOT_DIR}"'/install_gen.sh'
$ . "${SCRIPT_NAME}"

install_parallel_gen.sh

Parallel version of the above installation script. Execute same way.

Secrets / passwords

For example, set POSTGRES_PASSWORD to null in the json like so:

{
  "name": "POSTGRES",
  "version": "17",
  "env": "POSTGRES_URL",
  "vars": {
    "POSTGRES_USER": "rest_user",
    "POSTGRES_PASSWORD": null,
    "POSTGRES_DB": "rest_db",
    "POSTGRES_PASSWORD_FILE": null
  }
}

Then SET or export it manually before execution of install_gen.sh.

Docker usage

For debugging, you might want to run something like:

$ distro='debian' # or 'alpine'
$ docker build --file "${distro}"'.Dockerfile' --progress='plain' --no-cache --tag "${PWD##*/}":"${distro}" .

Docker builder

To make things more convenient, use this docker builder; setting -i to same as -o of ./create_installer_from_json.sh:

$ ./create_docker_builder.sh -h
Create Docker image builder scripts.

-p prefix ($DOCKER_IMAGE_PREFIX, default: "deploysh")
-s suffix ($DOCKER_IMAGE_SUFFIX, default: "-latest")
-i input directory (`cd`s if provided, defaults to current working directory; adds scripts here also)
-v verbosity (can be specified multiple times)
-h show help text

Example

$ ./build_docker_images.sh -o ./tmp
$ cd ./tmp && sh ./docker_builder.sh
# or docker_builder_parallel.sh ^

License

Licensed under any of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

📧