A collection of useful scripts for various Linux distributions
Will compile each script into a single distributable file with all dependencies included within.
python3 compile.py
Most of the metadata is collected from the file header.
To ensure rendering, please ensure all file headers start with #
,
and separating lines contain a #
.
Header scanning will stop as soon as an empty line is encountered.
Example, this will not see the "Supports" section as a header field, and thus will not include it.
#!/bin/bash
#
# Some title
# Supports:
# Debian 12
Correct form includes a '#' to ensure the entire block is seen as the file header.
#!/bin/bash
#
# Some title
#
# Supports:
# Debian 12
The first non-empty line retrieved from the script will be used as the title, (one line only).
Lists how to run the application to the end user, and gets saved in the help icon in TRMM.
#/bin/bash
# ...
# Syntax:
# --option1 - Short description of option 1
# --option2=... - Short description of option 2
#!/usr/bin/env python3
"""
...
Syntax:
--option1 - Short description of option 1
--option2=... - Short description of option 2
"""
(BASH only) Optionally, you can include the destination variable name before each argument
to allow for dynamic generation of the argument parsing via compile:argparse
.
In this example, passing --noninteractive
will set the variable NONINTERACTIVE
to 1
.
(The compiler will filter out the prefix)
#/bin/bash
# ...
# Syntax:
# NONINTERACTIVE=--noninteractive - Run in non-interactive mode, (will not ask for prompts)
# VERSION=--version=... - Version of Zabbix to install DEFAULT=7.0
# ZABBIX_SERVER=--server=... - Hostname or IP of Zabbix server
# ZABBIX_AGENT_HOSTNAME=--hostname=... - Hostname of local device for matching with a Zabbix host entry
# ...
# compile:argparse
Generates:
#/bin/bash
# ...
# Syntax:
# --noninteractive - Run in non-interactive mode, (will not ask for prompts)
# --version=... - Version of Zabbix to install DEFAULT=7.0
# --server=... - Hostname or IP of Zabbix server
# --hostname=... - Hostname of local device for matching with a Zabbix host entry
# ...
# Parse arguments
NONINTERACTIVE="0"
VERSION="7.0"
ZABBIX_SERVER=""
ZABBIX_AGENT_HOSTNAME=""
while [ "$#" -gt 0 ]; do
case "$1" in
--noninteractive) NONINTERACTIVE=1; shift 1;;
--version=*) VERSION="${1#*=}"; shift 1;;
--server=*) ZABBIX_SERVER="${1#*=}"; shift 1;;
--hostname=*) ZABBIX_AGENT_HOSTNAME="${1#*=}"; shift 1;;
-h|--help) usage;;
esac
done
if [ -z "$SOURCE" ]; then
usage
fi
Lists the default arguments and their values to be used when running the script in TRMM.
DOES support TRMM variable replacement for site, client, and agent.
To use these, wrap the variable in double curly braces, like so: {{client.zabbix_hostname}}
#/bin/bash
# ...
# TRMM Arguments:
# --option1
# --option2=something
#!/usr/bin/env python3
"""
...
Syntax:
--option1 - Short description of option 1
--option2=... - Short description of option 2
"""
Behaves the same as TRMM Arguments, but is used for environment variables.
#/bin/bash
# ...
# TRMM Environment:
# VAR1=something
# VAR2={{client.zabbix_hostname}}
#!/usr/bin/env python3
"""
...
TRMM Environment:
VAR1=something
VAR2={{client.zabbix_hostname}}
"""
Lists the OS support for the script.
#/bin/bash
# ...
# Supports:
# Debian 12
# Ubuntu 24.04
#!/usr/bin/env python3
"""
...
Supports:
Debian 12
Ubuntu 24.04
"""
Distros can be listed individually, or one of the group declarations for multiple distros.
- Linux-All - All Linux-based distros (completely os-agnostic script)
- Debian-All - Any Debian-based distro (Debian, Ubuntu, Mint, etc)
- RHEL-All - Any Red Hat-based distro (RHEL, CentOS, Fedora, etc)
- ArchLinux / arch
- CentOS
- Debian
- Fedora
- LinuxMint
- RedHat / RHEL
- Rocky / RockyLinux
- SuSE / OpenSuSE
- Ubuntu
- Windows
#/bin/bash
# ...
# Author:
# Some Name <[email protected]>
alternative syntax:
#/bin/bash
# ...
# @AUTHOR Some Name <[email protected]>
#!/usr/bin/env python3
"""
...
@AUTHOR Some Name <[email protected]>
"""
#/bin/bash
# ...
# Category:
# Some Category
alternative syntax:
#/bin/bash
# ...
# @CATEGORY Some Category
#!/usr/bin/env python3
"""
...
Category:
Some Category
"""
#/bin/bash
# ...
# @TRMM-TIMEOUT 120
#!/usr/bin/env python3
"""
...
@TRMM-TIMEOUT 120
"""
Set to true to skip finalizing of the script. The script will still be generated to dist/, but will not be recorded in the README and TRMM metafile.
#/bin/bash
# ...
# Draft:
# True
#!/usr/bin/env python3
"""
...
Draft:
True
"""
The compiler can generate dynamic code based on script comments, notably for usage and arguments
Will generate a "usage()" function with the description and syntax arguments.
# compile:usage