Cross-platform—/bin/sh; cmd.exe—scripts 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
OS support for:
- Windows
- Linux (Debian, Alpine, &etc.); inside/outside of Docker
- macOS
- FreeBSD
- [coming soon!] *BSDs [NetBSD, OpenBSD]
- [coming soon!] SunOS and derivatives | forks such as illumos
- [coming soon!] Other UNIX's like: IBM's z/OS; and HP's Unix (HP/UX).
- [coming soon!] Android
- [coming soon!] iOS
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.
Care is taken to use open-source alternatives. For example: Valkey [and Garnet for Windows] over Redis; and FerretDB over MongoDB.
| Name | Parameters |
|---|---|
| Node.js | NODEJS_VERSION* |
| Python | PYTHON_VERSION* |
| Rust | RUST_VERSION* |
- required
| Name | Parameters |
|---|---|
| etcd | ETCD_VERSION† |
| PostgreSQL | POSTGRESQL_VERSION†; POSTGRES_USER†; POSTGRES_PASSWORD‡; POSTGRES_PASSWORD_FILE‡; POSTGRES_HOST; POSTGRES_DB† |
| Valkey [Redis fork] |
- † required
- ‡ needs one-and-only-one
| Name | Parameters |
|---|---|
| nginx | VARS‡ |
| kubernetes (thw) | VARS |
| kubernetes (k0) | VARS |
- ‡
VARS—if provided—must includeSERVER_NAMEand:NGINX_FRAGMENT_CONF; xorWWWROOTwith optionalWWWROOT_AUTOINDEX; xorPROXY_PASSwith optional (PROXY_WEBSOCKETSwith optionalPROXY_WEBSOCKETS_ADVANCED).
- First version was written in Python (59+ repos with "off" prefix) for mostly Linux (Ubuntu) with a bit of work for Debian support;
- Second version being written in
/bin/sh[this repo] targeting macOS; Linux (.deb, .rpm, .apk (Alpine Linux) distributions); SunOS; *BSDs; andcmd.exefor Windows; - Third version being written in C [C89], targeting all the above + DOS and OS/360. libacquire will become the base of this.
- Linux variants are useful in Docker, other image types [e.g., see Packer, Unikernels], and natively;
- macOS variant is useful primarily natively;
- [coming soon!] *BSDs [NetBSD, FreeBSD, OpenBSD] are useful in jails or natively;
- Windows is useful for Windows Containers, other image types, and natively;
- [coming soon!] SunOS / illumos are useful for native usage on mainframes, both native and in virtualised / zones / container systems like SmartOS;
- [coming soon!] IBM's z/OS [coming soon!] useful in mainframes and for testing OS/360 (from the 1960s); and
- [coming soon!] HP's Unix (HP/UX) [coming soon!] (also specifically useful in mainframes).
Generally these scripts are extremely portable and could be used to benchmark and security-audit any:
- Platform virtualization software: https://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software
- OS-level virtualization software: https://en.wikipedia.org/wiki/OS-level_virtualization#IMPLEMENTATIONS
- μ-kernel: https://en.wikipedia.org/wiki/Microkernel
- Unikernel: https://en.wikipedia.org/wiki/Unikernel
- Any other kernel: https://en.wikipedia.org/wiki/Comparison_of_operating_system_kernels
All the aforementioned advantages, plus:
- OS/360 useful natively (expected as a proof-of-concept only);
- DOS useful natively (expected as a proof-of-concept only).
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.
To simplify usage, a JSON file format is provided. See ./install.json for an example.
$ ./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 textWhich will create these files:
Default environment. When nothing preexists in your env, this sets everything to install.
False environment. This sets everything to not install.
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}"Parallel version of the above installation script. Execute same way.
For example, set POSTGRES_PASSWORD to null in the json like so:
{
"name": "POSTGRES",
"version": "18",
"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.
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}" .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$ ./build_docker_images.sh -o ./tmp
$ cd ./tmp && sh ./docker_builder.sh
# or docker_builder_parallel.sh ^First install Vagrant. Then, for example, deploy the debian Vagrant box with:
cd libscript/vagrant/debian12
vagrant upDeploy PostgreSQL:
vagrant ssh -c '. ${LIBSCRIPT_ROOT_DIR}/env.sh && ${LIBSCRIPT_ROOT_DIR}/_lib/_storage/postgres/setup.sh'Test whether the deployment succeeded:
vagrant ssh -c '. ${LIBSCRIPT_ROOT_DIR}/env.sh && ${LIBSCRIPT_ROOT_DIR}/_lib/_storage/postgres/test.sh'Run the official REPL, connected to this newly deployed PostgreSQL:
vagrant ssh -c 'psql "postgres://rest_user:rest_pass@localhost/rest_db"'Licensed under any of:
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
- CC0 license (LICENSE-CC0 or https://creativecommons.org/publicdomain/zero/1.0/legalcode)
at your option.
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.