{"id":24333116,"url":"https://github.com/samuelmarks/libscript","last_synced_at":"2025-04-14T13:14:21.690Z","repository":{"id":270248999,"uuid":"909467773","full_name":"SamuelMarks/libscript","owner":"SamuelMarks","description":"Cross-platform—`/bin/sh`; `cmd.exe`—scripts library for: Windows; Linux; Docker; macOS; FreeBSD; SunOS; \u0026etc.","archived":false,"fork":false,"pushed_at":"2025-04-07T04:30:22.000Z","size":673,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T05:26:58.301Z","etag":null,"topics":["batch","batch-script","cross-platform","shell","shell-scripts"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SamuelMarks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-28T19:44:01.000Z","updated_at":"2025-04-07T04:30:26.000Z","dependencies_parsed_at":"2024-12-29T18:26:39.827Z","dependency_job_id":"9b3b56dd-b7da-4b97-bd19-04a66019e7aa","html_url":"https://github.com/SamuelMarks/libscript","commit_stats":null,"previous_names":["samuelmarks/deploy-sh","samuelmarks/libscript"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelMarks%2Flibscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelMarks%2Flibscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelMarks%2Flibscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamuelMarks%2Flibscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SamuelMarks","download_url":"https://codeload.github.com/SamuelMarks/libscript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886331,"owners_count":21177645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["batch","batch-script","cross-platform","shell","shell-scripts"],"created_at":"2025-01-18T03:13:12.217Z","updated_at":"2025-04-14T13:14:21.677Z","avatar_url":"https://github.com/SamuelMarks.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"libscript\n=========\n\n[Cross-platform](https://en.wikipedia.org/wiki/Cross-platform_software)—[`/bin/sh`](https://en.wikipedia.org/wiki/Bourne_shell); [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe)—[scripts library](https://en.wikipedia.org/wiki/Library_(computing)) for: [Windows](https://en.wikipedia.org/wiki/Microsoft_Windows); [Linux](https://en.wikipedia.org/wiki/Linux); [macOS](https://en.wikipedia.org/wiki/MacOS); [FreeBSD](https://en.wikipedia.org/wiki/FreeBSD); [SunOS](https://en.wikipedia.org/wiki/SunOS); \u0026etc.\n\nSee also libscript's: [WHY.md](WHY.md); [ROADMAP.md](ROADMAP.md); and [IDEAS.md](IDEAS.md). For testing see [TEST.md](TEST.md).\n\nFinally, see the official website with generated cross-linked hosted libscript documentation @ https://verMan.io\n\n## Features\n\n[OS](https://en.wikipedia.org/wiki/Operating_system) support for:\n\n  - [Windows](https://en.wikipedia.org/wiki/Microsoft_Windows)\n  - [Linux](https://en.wikipedia.org/wiki/Linux) ([Debian](https://en.wikipedia.org/wiki/Debian), [Alpine](https://en.wikipedia.org/wiki/Alpine_Linux), \u0026etc.); inside/outside of [Docker](https://en.wikipedia.org/wiki/Docker_(software))\n  - [macOS](https://en.wikipedia.org/wiki/MacOS)\n  - [coming soon!] [*BSDs](https://en.wikipedia.org/wiki/Comparison_of_BSD_operating_systems) [[NetBSD](https://en.wikipedia.org/wiki/NetBSD), [FreeBSD](https://en.wikipedia.org/wiki/FreeBSD), [OpenBSD](https://en.wikipedia.org/wiki/OpenBSD)]\n  - [coming soon!] [SunOS](https://en.wikipedia.org/wiki/SunOS) and derivatives | [forks](https://en.wikipedia.org/wiki/Fork_(software_development)) such as [illumos](https://en.wikipedia.org/wiki/Illumos)\n  - [coming soon!] Other [UNIX](https://en.wikipedia.org/wiki/Unix)'s like: [IBM's z/OS](https://en.wikipedia.org/wiki/Z/OS); and [HP's Unix (HP/UX)](https://en.wikipedia.org/wiki/HP-UX).\n  - [coming soon!] [Android](https://en.wikipedia.org/wiki/Android_(operating_system))\n  - [coming soon!] [iOS](https://en.wikipedia.org/wiki/IOS)\n\nRelocatable; no need to [`cd`](https://en.wikipedia.org/wiki/Cd_(command)) into the scripts [directory](https://en.wikipedia.org/wiki/Directory_(computing)).\n\nLibrary [directory structure](https://en.wikipedia.org/wiki/Path_(computing)) is super-readable and [modular](https://en.wikipedia.org/wiki/Modular_programming).\n\nPlenty of [guards](https://en.wikipedia.org/wiki/Include_guard) everywhere—[idempotency style](https://en.wikipedia.org/wiki/Idempotence#Computer_science_meaning)—so scripts can be interdependent—and [rerun](https://en.wikipedia.org/wiki/Pure_function)—without worry.\n\n[**Dockerfiles**](https://en.wikipedia.org/wiki/Docker_(software)#Dockerfile_(example)) are generated. These are well optimised for Docker's cache mechanism.\n\nExample of generated files are found in the [`gen`](./gen) directory.\n\n## Current ‘installables’\n\nCare is taken to use open-source alternatives. For example: [Valkey](https://valkey.io) [and [Garnet](https://github.com/microsoft/garnet) for Windows] over [Redis](https://redis.io); and [FerretDB](https://ferretdb.com) over [MongoDB](https://mongodb.com).\n\n### Toolchains\n\n   | Name                          | Parameters        |\n   |-------------------------------|-------------------|\n   | [Node.js](https://nodejs.org) | `NODEJS_VERSION`* |\n   | [Python](https://python.org)  | `PYTHON_VERSION`* |\n   | [Rust](https://rust-lang.org) | `RUST_VERSION`*   |\n\n* required\n\n### Databases / storage layers\n\n   | Name                                     | Parameters                                                                                                                |\n   |------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|\n   | [PostgreSQL](https://postgresql.org)     | `POSTGRESQL_VERSION`†; `POSTGRES_USER`†; `POSTGRES_PASSWORD`‡; `POSTGRES_PASSWORD_FILE`‡; `POSTGRES_HOST`; `POSTGRES_DB`† |\n   | [Valkey](https://valkey.io) [Redis fork] |                                                                                                                           |\n\n  - † required\n  - ‡ needs one-and-only-one\n\n### Servers\n\n\n   | Name                       | Parameters |\n   |----------------------------|------------|\n   | [nginx](https://nginx.org) | `VARS`‡    |\n\n  - ‡`VARS`—if provided—must include `SERVER_NAME` and: `NGINX_FRAGMENT_CONF`; xor `WWWROOT` with optional `WWWROOT_AUTOINDEX`; xor `PROXY_PASS` with optional (`PROXY_WEBSOCKETS` with optional `PROXY_WEBSOCKETS_ADVANCED`).\n\n## History / roadmap:\n\n  0. First version was written in [Python](https://en.wikipedia.org/wiki/Python_(programming_language)) (59+ [repos](https://en.wikipedia.org/wiki/Software_repository) with [\"off\" prefix](https://github.com/offscale?q=off\u0026language=python)) for mostly [Linux](https://en.wikipedia.org/wiki/Linux) ([Ubuntu](https://en.wikipedia.org/wiki/Ubuntu)) with a bit of work for [Debian](https://en.wikipedia.org/wiki/Debian) support;\n  1. Second version being written in [`/bin/sh`](https://en.wikipedia.org/wiki/Bourne_shell) [this repo] targeting [macOS](https://en.wikipedia.org/wiki/MacOS); [Linux](https://en.wikipedia.org/wiki/Linux) ([.deb](https://en.wikipedia.org/wiki/Deb_(file_format)), [.rpm](https://en.wikipedia.org/wiki/RPM_Package_Manager), [.apk (Alpine Linux)](https://en.wikipedia.org/wiki/Alpine_Linux) distributions); [SunOS](https://en.wikipedia.org/wiki/SunOS); [*BSDs](https://en.wikipedia.org/wiki/Comparison_of_BSD_operating_systems); and [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) for [Windows](https://en.wikipedia.org/wiki/Microsoft_Windows);\n  2. Third version being written in [C](https://en.wikipedia.org/wiki/C_(programming_language)) [[C89](https://en.wikipedia.org/wiki/ANSI_C#C89)], targeting all the above + [DOS](https://en.wikipedia.org/wiki/Comparison_of_DOS_operating_systems) and [OS/360](https://en.wikipedia.org/wiki/OS/360_and_successors). [libacquire](https://github.com/offscale/libacquire) will become the base of this.\n\n## Advantage of this repo\n\n  - [Linux](https://en.wikipedia.org/wiki/Linux) variants are useful in [Docker](https://en.wikipedia.org/wiki/Docker_(software)), other image types [e.g., see [Packer](https://www.packer.io), [Unikernels](https://en.wikipedia.org/wiki/Unikernel)], and natively;\n  - [macOS](https://en.wikipedia.org/wiki/MacOS) variant is useful primarily natively;\n  - [coming soon!] [*BSDs](https://en.wikipedia.org/wiki/Comparison_of_BSD_operating_systems) [[NetBSD](https://en.wikipedia.org/wiki/NetBSD), [FreeBSD](https://en.wikipedia.org/wiki/FreeBSD), [OpenBSD](https://en.wikipedia.org/wiki/OpenBSD)] are useful in jails or natively;\n  - [Windows](https://en.wikipedia.org/wiki/Microsoft_Windows) is useful for [Windows Containers](https://learn.microsoft.com/en-us/virtualization/windowscontainers/about/), other image types, and natively;\n  - [coming soon!] [SunOS](https://en.wikipedia.org/wiki/SunOS) / [illumos](https://en.wikipedia.org/wiki/Illumos) are useful for native usage on mainframes, both native and in virtualised / zones / container systems like [SmartOS](https://en.wikipedia.org/wiki/SmartOS);\n  - [coming soon!] [IBM's z/OS](https://en.wikipedia.org/wiki/Z/OS) [coming soon!] useful in mainframes and for testing [OS/360](https://en.wikipedia.org/wiki/OS/360_and_successors) (from the 1960s); and\n  - [coming soon!] [HP's Unix (HP/UX)](https://en.wikipedia.org/wiki/HP-UX) [coming soon!] (also specifically useful in mainframes).\n\nGenerally these [scripts](https://en.wikipedia.org/wiki/Scripting_language) are extremely portable and could be used to benchmark and security-audit any:\n\n  - Platform virtualization software: https://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software\n  - OS-level virtualization software: https://en.wikipedia.org/wiki/OS-level_virtualization#IMPLEMENTATIONS\n  - μ-kernel: https://en.wikipedia.org/wiki/Microkernel\n  - Unikernel: https://en.wikipedia.org/wiki/Unikernel\n  - Any other kernel: https://en.wikipedia.org/wiki/Comparison_of_operating_system_kernels\n\n## Advantage of C repo(s)\n\nAll the aforementioned advantages, plus:\n\n  - [OS/360](https://en.wikipedia.org/wiki/OS/360_and_successors) useful natively (expected as a proof-of-concept only);\n  - [DOS](https://en.wikipedia.org/wiki/Comparison_of_DOS_operating_systems) useful natively (expected as a proof-of-concept only).\n\n## Usage\n\nNOTE: You might want to manually set `LIBSCRIPT_DATA_DIR`; `LIBSCRIPT_BUILD_DIR`; and `LIBSCRIPT_TOOLS_DIR`.\n\nRun from the same directory as this [README.md](README.md) file.\nAlternatively, set `SCRIPT_NAME` to the correct `install.sh` location and run it anywhere.\n```sh\n$ # Replace `$(pwd)` if not in the 'libscript' directory.\n$ export LIBSCRIPT_ROOT_DIR=\"$(pwd)\"\n$ # Disable all options (everything set to do-*not*-install)\n$ . \"${LIBSCRIPT_ROOT_DIR}\"'/conf-no-all.env.sh'\n$ # Enable installation of *just* Jupyter Hub\n$ export JUPYTERHUB_INSTALL=1\n$ # Set script location.\n$ export SCRIPT_NAME=\"${LIBSCRIPT_ROOT_DIR}\"'/install.sh'\n$ . \"${SCRIPT_NAME}\"\n```\n\nSee [`gen/env.sh`](./gen/env.sh) for options that can be overridden by setting environment variables.\n\n## Usage (JSON)\n\nTo simplify usage, a JSON file format is provided. See [./install.json](./install.json) for an example.\n\n## Usage (JSON) CLI\n\n```sh\n$ ./create_installer_from_json.sh -h\nCreate install scripts from JSON.\n\n  -a whether to install all dependencies (required AND optional)\n  -f filename\n  -o output folder (defaults to ./tmp)\n  -v verbosity (can be specified multiple times)\n  -b base images for docker (space seperated, default: \"alpine:latest debian:bookworm-slim\")\n  -h show help text\n```\n\nWhich will create these files:\n\n### `env.sh` ; `env.cmd`\n\nDefault environment. When nothing preexists in your env, this sets everything to install.\n\n### `false_env.sh` ; `false_env.cmd`\n\nFalse environment. This sets everything to *not* install.\n\n### `install_gen.sh` ; `install_gen.cmd`\n\nThe actual installation script. Execute this like so:\n```sh\n$ # Set script location. Change from `pwd` if 'install_gen.sh' isn't in current dir.\n$ export LIBSCRIPT_ROOT_DIR=\"$(pwd)\"\n$ export SCRIPT_NAME=\"${LIBSCRIPT_ROOT_DIR}\"'/install_gen.sh'\n$ . \"${SCRIPT_NAME}\"\n```\n\n### `install_parallel_gen.sh`\n\nParallel version of the above installation script. Execute same way.\n\n## Secrets / passwords\n\nFor example, set `POSTGRES_PASSWORD` to `null` in the json like so:\n\n```json\n{\n  \"name\": \"POSTGRES\",\n  \"version\": \"17\",\n  \"env\": \"POSTGRES_URL\",\n  \"vars\": {\n    \"POSTGRES_USER\": \"rest_user\",\n    \"POSTGRES_PASSWORD\": null,\n    \"POSTGRES_DB\": \"rest_db\",\n    \"POSTGRES_PASSWORD_FILE\": null\n  }\n}\n```\n\nThen `SET` or `export` it manually before execution of `install_gen.sh`.\n\n## Docker usage\n\nFor debugging, you might want to run something like:\n\n```sh\n$ distro='debian' # or 'alpine'\n$ docker build --file \"${distro}\"'.Dockerfile' --progress='plain' --no-cache --tag \"${PWD##*/}\":\"${distro}\" .\n```\n\n### Docker builder\n\nTo make things more convenient, use this docker builder; setting `-i` to same as `-o` of `./create_installer_from_json.sh`:\n\n```sh\n$ ./create_docker_builder.sh -h\nCreate Docker image builder scripts.\n\n-p prefix ($DOCKER_IMAGE_PREFIX, default: \"deploysh\")\n-s suffix ($DOCKER_IMAGE_SUFFIX, default: \"-latest\")\n-i input directory (`cd`s if provided, defaults to current working directory; adds scripts here also)\n-v verbosity (can be specified multiple times)\n-h show help text\n```\n\n#### Example\n\n```sh\n$ ./build_docker_images.sh -o ./tmp\n$ cd ./tmp \u0026\u0026 sh ./docker_builder.sh\n# or docker_builder_parallel.sh ^\n```\n\n## Vagrant usage\n\nFirst install [Vagrant](https://vagrantup.com). Then, for example, deploy the debian Vagrant box with:\n```sh\ncd libscript/vagrant/debian12\nvagrant up\n```\n\n### Example (PostgreSQL)\n\nDeploy PostgreSQL:\n\n```sh\nvagrant ssh -c '. ${LIBSCRIPT_ROOT_DIR}/env.sh \u0026\u0026 ${LIBSCRIPT_ROOT_DIR}/_lib/_storage/postgres/setup.sh'\n```\n\nTest whether the deployment succeeded:\n\n```sh\nvagrant ssh -c '. ${LIBSCRIPT_ROOT_DIR}/env.sh \u0026\u0026 ${LIBSCRIPT_ROOT_DIR}/_lib/_storage/postgres/test.sh'\n```\n\nRun the official REPL, connected to this newly deployed PostgreSQL:\n\n```sh\nvagrant ssh -c 'psql \"postgres://rest_user:rest_pass@localhost/rest_db\"'\n```\n\n\u003chr/\u003e\n\n## License\n\nLicensed under any of:\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or \u003chttps://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttps://opensource.org/licenses/MIT\u003e)\n- CC0 license ([LICENSE-CC0](LICENSE-CC0) or \u003chttps://creativecommons.org/publicdomain/zero/1.0/legalcode\u003e)\n\nat your option.\n\n### Contribution\n\nUnless 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelmarks%2Flibscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelmarks%2Flibscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelmarks%2Flibscript/lists"}