A bash library and framework to expedite Nanobox engine development.
No installation is required, Nanobox build containers have Nos pre-installed.
To use Nos, simply source the common.sh script and initialize the framework.
#!/bin/bash
# source the Nos framework
. /opt/nos/common.sh
# initialize Nos with the original arguments
nos_init $@
For an overview of how and when to use Nos, please refer to the Nanobox Common Tasks guide.
- Payload
- Validation
- Printing Output
- Installing Packages
- Running Commands
- Environment Variables
- Templates
$1 = key
A simple getter for fetching a payload value
$1 = field
Validate that a field exists within the boxfile payload and has a value.
If the check fails, a fatal error will be printed an a non-zero exit
will be forced.
$1 = field
$2 = possible values
Validates that if a field exists, the value present falls within a range
of acceptable options.
$1 = field
$2 = possible values
Validates that if a field exists, the value present falls does not fall
within a range of options.
$1 = label
Print a header, formatted to 70 characters, with the label
Example:
nos_print_header "headline here"
would produce:
::::::::::::::::::::::::::: HEADLINE HERE :::::::::::::::::::::::::::
$1 = label
Print a header indicating the start of a process.
Example:
nos_print_process_start "installing ruby-2.2"
would produce:
INSTALLING RUBY-2.2 ------------------------------------------------>
Creates a hard delineation after a process
$1 = message
Print a line item in the form of a bullet point
Example:
nos_print_bullet "Language Detected : Ruby"
would produce:
+ Language Detected : Ruby
$1 = message
Print a line item as followup info to a bullet point
Example:
nos_print_bullet_info "Language Detected : Ruby"
would produce:
Language Detected : Ruby
$1 = message
Print a line item as a sub or followup item to a bullet point
Example:
nos_print_bullet_sub "Language Detected : Ruby"
would produce:
- Language Detected : Ruby
$1 = message
Print a warning message, formatted to a 70 character block paragraph
Example:
nos_print_warning "We've detected you may be using... (abbreviated for clarity)"
would produce:
----------------------------- WARNING -----------------------------
We've detected you may be using sessions in a way that could cause
unexpected behavior. Feel free to review the following guide for
more information : bit.ly/2sA9b
$1 = title
$2 = message
Example:
nos_print_fatal "deploy stream disconnected", "Oh snap... (abbreviated for clarity)"
would produce:
! DEPLOY STREAM DISCONNECTED !
Oh snap the deploy stream just disconnected. No worries, you can
visit the dashboard to view the complete output stream.
$1 = message
Print a message formatted as a block of text, wrapped at 70 characters
Example:
nos_print_block "We've detected you may be using... (abbreviated for clarity)"
would produce:
We've detected you may be using sessions in a way that could cause
unexpected behavior. Feel free to review the following guide for
more information : bit.ly/2sA9b
$1 = package name
A simple expressive shortcut to install a pkgsrc package via pkgin
$1 = package name
A simple expressive shortcut to uninstall a pkgsrc package via pkgin
$1 = process label
$2 = command
A helper to run a process and format the output according to the styleguide
$1 = process label
$2 = command
A helper to run a subprocess and format the output according to the styleguide
$1 = key
$2 = value
Sets an environment variable in the running process
$1 = key
$2 = value
Persists an environment variable which will be available to the process that
the code runs in after a successful deploy.
$1 = source
$2 = destination
$3 = JSON|YAML payload
Renders a mustache template from the templates directory and persists the
result at (destination). The payload provided is passed to mustache.
$1 = source
$2 = destination
Copies a file from the files directory to the specified destination.