#!/usr/bin/env bash # This script was generated by bashly 1.0.2 (https://bashly.dannyb.co) # Modifying it manually is not recommended if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then printf "bash version 4 or higher is required\n" >&2 exit 1 fi version_command() { echo "$version" } lmu_usage() { if [[ -n $long_usage ]]; then printf "lmu - Leffler.Media Utils\n" echo else printf "lmu - Leffler.Media Utils\n" echo fi printf "%s\n" "Usage:" printf " lmu COMMAND\n" printf " lmu [COMMAND] --help | -h\n" printf " lmu --version | -v\n" echo printf "%s\n" "Commands:" printf " %s install lmu\n" "install " printf " %s install log2ram\n" "log2ram " printf " %s Customize systems\n" "customize " printf " %s Scripts to configure monitoring\n" "monitoring " printf " %s Scripts to configure logging\n" "logging " printf " %s Scripts to configure remote support\n" "remote " printf " %s Scripts to configure users\n" "users " printf " %s Misc system scripts\n" "system " printf " %s Application installers\n" "applications" printf " %s commands useful for webservers\n" "webserver " echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo printf " %s\n" "--version, -v" printf " Show version number\n" echo fi } lmu_install_usage() { if [[ -n $long_usage ]]; then printf "lmu install - install lmu\n" echo else printf "lmu install - install lmu\n" echo fi printf "%s\n" "Usage:" printf " lmu install\n" printf " lmu install --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_log2ram_usage() { if [[ -n $long_usage ]]; then printf "lmu log2ram - install log2ram\n" echo else printf "lmu log2ram - install log2ram\n" echo fi printf "%s\n" "Usage:" printf " lmu log2ram\n" printf " lmu log2ram --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_customize_usage() { if [[ -n $long_usage ]]; then printf "lmu customize - Customize systems\n" echo else printf "lmu customize - Customize systems\n" echo fi printf "%s\n" "Usage:" printf " lmu customize COMMAND\n" printf " lmu customize [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s Add IPv4 to /etc/issue file\n" "etc_issue" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_customize_etc_issue_usage() { if [[ -n $long_usage ]]; then printf "lmu customize etc_issue - Add IPv4 to /etc/issue file\n" echo else printf "lmu customize etc_issue - Add IPv4 to /etc/issue file\n" echo fi printf "%s\n" "Usage:" printf " lmu customize etc_issue\n" printf " lmu customize etc_issue --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_monitoring_usage() { if [[ -n $long_usage ]]; then printf "lmu monitoring - Scripts to configure monitoring\n" echo else printf "lmu monitoring - Scripts to configure monitoring\n" echo fi printf "%s\n" "Usage:" printf " lmu monitoring COMMAND\n" printf " lmu monitoring [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s checkmk stuff\n" "checkmk" printf " %s zabbix stuff\n" "zabbix " echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_monitoring_checkmk_usage() { if [[ -n $long_usage ]]; then printf "lmu monitoring checkmk - checkmk stuff\n" echo else printf "lmu monitoring checkmk - checkmk stuff\n" echo fi printf "%s\n" "Usage:" printf " lmu monitoring checkmk COMMAND\n" printf " lmu monitoring checkmk [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s install checkmk\n" "install" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_monitoring_checkmk_install_usage() { if [[ -n $long_usage ]]; then printf "lmu monitoring checkmk install - install checkmk\n" echo else printf "lmu monitoring checkmk install - install checkmk\n" echo fi printf "%s\n" "Usage:" printf " lmu monitoring checkmk install\n" printf " lmu monitoring checkmk install --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_monitoring_zabbix_usage() { if [[ -n $long_usage ]]; then printf "lmu monitoring zabbix - zabbix stuff\n" echo else printf "lmu monitoring zabbix - zabbix stuff\n" echo fi printf "%s\n" "Usage:" printf " lmu monitoring zabbix COMMAND\n" printf " lmu monitoring zabbix [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s install zabbix agent\n" "install" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_monitoring_zabbix_install_usage() { if [[ -n $long_usage ]]; then printf "lmu monitoring zabbix install - install zabbix agent\n" echo else printf "lmu monitoring zabbix install - install zabbix agent\n" echo fi printf "%s\n" "Usage:" printf " lmu monitoring zabbix install\n" printf " lmu monitoring zabbix install --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_logging_usage() { if [[ -n $long_usage ]]; then printf "lmu logging - Scripts to configure logging\n" echo else printf "lmu logging - Scripts to configure logging\n" echo fi printf "%s\n" "Usage:" printf " lmu logging COMMAND\n" printf " lmu logging [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s vector stuff\n" "vector" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_logging_vector_usage() { if [[ -n $long_usage ]]; then printf "lmu logging vector - vector stuff\n" echo else printf "lmu logging vector - vector stuff\n" echo fi printf "%s\n" "Usage:" printf " lmu logging vector COMMAND\n" printf " lmu logging vector [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s install vector\n" "install " printf " %s configure vector\n" "configure" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_logging_vector_install_usage() { if [[ -n $long_usage ]]; then printf "lmu logging vector install - install vector\n" echo else printf "lmu logging vector install - install vector\n" echo fi printf "%s\n" "Usage:" printf " lmu logging vector install\n" printf " lmu logging vector install --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_logging_vector_configure_usage() { if [[ -n $long_usage ]]; then printf "lmu logging vector configure - configure vector\n" echo else printf "lmu logging vector configure - configure vector\n" echo fi printf "%s\n" "Usage:" printf " lmu logging vector configure\n" printf " lmu logging vector configure --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_remote_usage() { if [[ -n $long_usage ]]; then printf "lmu remote - Scripts to configure remote support\n" echo else printf "lmu remote - Scripts to configure remote support\n" echo fi printf "%s\n" "Usage:" printf " lmu remote COMMAND\n" printf " lmu remote [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s Add system into meshcentral\n" "add2mc " printf " %s tailscale stuff\n" "tailscale" printf " %s rathole stuff\n" "rathole " echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_remote_add2mc_usage() { if [[ -n $long_usage ]]; then printf "lmu remote add2mc - Add system into meshcentral\n" echo else printf "lmu remote add2mc - Add system into meshcentral\n" echo fi printf "%s\n" "Usage:" printf " lmu remote add2mc\n" printf " lmu remote add2mc --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_remote_tailscale_usage() { if [[ -n $long_usage ]]; then printf "lmu remote tailscale - tailscale stuff\n" echo else printf "lmu remote tailscale - tailscale stuff\n" echo fi printf "%s\n" "Usage:" printf " lmu remote tailscale COMMAND\n" printf " lmu remote tailscale [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s install tailscale\n" "install" printf " %s authenticate with headscale\n" "auth " echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_remote_tailscale_install_usage() { if [[ -n $long_usage ]]; then printf "lmu remote tailscale install - install tailscale\n" echo else printf "lmu remote tailscale install - install tailscale\n" echo fi printf "%s\n" "Usage:" printf " lmu remote tailscale install\n" printf " lmu remote tailscale install --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_remote_tailscale_auth_usage() { if [[ -n $long_usage ]]; then printf "lmu remote tailscale auth - authenticate with headscale\n" echo else printf "lmu remote tailscale auth - authenticate with headscale\n" echo fi printf "%s\n" "Usage:" printf " lmu remote tailscale auth AUTHKEY [OPTIONS]\n" printf " lmu remote tailscale auth --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--server, -s SERVER" printf " headscale server to auth\n" printf " Default: https://headscale.leffler.network\n" echo printf " %s\n" "--dns" printf " tailscale accept dns\n" echo printf " %s\n" "--routes" printf " tailscale accept routes\n" echo printf " %s\n" "--help, -h" printf " Show this help\n" echo printf "%s\n" "Arguments:" printf " %s\n" "AUTHKEY" printf " authkey for tailscale\n" echo fi } lmu_remote_rathole_usage() { if [[ -n $long_usage ]]; then printf "lmu remote rathole - rathole stuff\n" echo else printf "lmu remote rathole - rathole stuff\n" echo fi printf "%s\n" "Usage:" printf " lmu remote rathole COMMAND\n" printf " lmu remote rathole [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s Install rathole\n" "install " printf " %s Configure rathole\n" "configure" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_remote_rathole_install_usage() { if [[ -n $long_usage ]]; then printf "lmu remote rathole install - Install rathole\n" echo else printf "lmu remote rathole install - Install rathole\n" echo fi printf "%s\n" "Usage:" printf " lmu remote rathole install [OPTIONS]\n" printf " lmu remote rathole install --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--version VERSION" printf " rathole version\n" printf " Default: 0.5.0\n" echo printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_remote_rathole_configure_usage() { if [[ -n $long_usage ]]; then printf "lmu remote rathole configure - Configure rathole\n" echo else printf "lmu remote rathole configure - Configure rathole\n" echo fi printf "%s\n" "Usage:" printf " lmu remote rathole configure LOCAL_SERVICE [OPTIONS]\n" printf " lmu remote rathole configure --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--server, -s SERVER" printf " server for rathole\n" printf " Default: proxy.leffler.network:2332\n" echo printf " %s\n" "--version VERSION" printf " rathole version\n" printf " Default: 0.5.0\n" echo printf " %s\n" "--service_name, -n SERVICE_NAME (required)" printf " name of service passing thru\n" echo printf " %s\n" "--help, -h" printf " Show this help\n" echo printf "%s\n" "Arguments:" printf " %s\n" "LOCAL_SERVICE" printf " local service to pass thru\n" echo fi } lmu_users_usage() { if [[ -n $long_usage ]]; then printf "lmu users - Scripts to configure users\n" echo else printf "lmu users - Scripts to configure users\n" echo fi printf "%s\n" "Usage:" printf " lmu users COMMAND\n" printf " lmu users [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s Script to create ansible user\n" "ansible" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_users_ansible_usage() { if [[ -n $long_usage ]]; then printf "lmu users ansible - Script to create ansible user\n" echo else printf "lmu users ansible - Script to create ansible user\n" echo fi printf "%s\n" "Usage:" printf " lmu users ansible\n" printf " lmu users ansible --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_system_usage() { if [[ -n $long_usage ]]; then printf "lmu system - Misc system scripts\n" echo else printf "lmu system - Misc system scripts\n" echo fi printf "%s\n" "Usage:" printf " lmu system COMMAND\n" printf " lmu system [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s Create swap file\n" "mkswap " printf " %s networking scripts\n" "networking" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_system_mkswap_usage() { if [[ -n $long_usage ]]; then printf "lmu system mkswap - Create swap file\n" echo else printf "lmu system mkswap - Create swap file\n" echo fi printf "%s\n" "Usage:" printf " lmu system mkswap [LOCATION] [OPTIONS]\n" printf " lmu system mkswap --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--size, -s SIZE" printf " Size of swap file in GB\n" printf " Default: 2\n" echo printf " %s\n" "--help, -h" printf " Show this help\n" echo printf "%s\n" "Arguments:" printf " %s\n" "LOCATION" printf " swap file location\n" printf " Default: /swap.file\n" echo fi } lmu_system_networking_usage() { if [[ -n $long_usage ]]; then printf "lmu system networking - networking scripts\n" echo else printf "lmu system networking - networking scripts\n" echo fi printf "%s\n" "Usage:" printf " lmu system networking COMMAND\n" printf " lmu system networking [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s enable IP Forwarding\n" "ipforward" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_system_networking_ipforward_usage() { if [[ -n $long_usage ]]; then printf "lmu system networking ipforward - enable IP Forwarding\n" echo else printf "lmu system networking ipforward - enable IP Forwarding\n" echo fi printf "%s\n" "Usage:" printf " lmu system networking ipforward [OPTIONS]\n" printf " lmu system networking ipforward --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--remove REMOVE" printf " remove ipforwarding\n" echo printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_applications_usage() { if [[ -n $long_usage ]]; then printf "lmu applications - Application installers\n" echo else printf "lmu applications - Application installers\n" echo fi printf "Alias: apps\n" echo printf "%s\n" "Usage:" printf " lmu applications COMMAND\n" printf " lmu applications [COMMAND] --help | -h\n" echo printf "%s\n" "Monitoring Commands:" printf " %s telegraf stuff\n" "telegraf" echo printf "%s\n" "Containers Commands:" printf " %s docker stuff\n" "docker " echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_applications_telegraf_usage() { if [[ -n $long_usage ]]; then printf "lmu applications telegraf - telegraf stuff\n" echo else printf "lmu applications telegraf - telegraf stuff\n" echo fi printf "%s\n" "Usage:" printf " lmu applications telegraf COMMAND\n" printf " lmu applications telegraf [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s install telegraf\n" "install" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_applications_telegraf_install_usage() { if [[ -n $long_usage ]]; then printf "lmu applications telegraf install - install telegraf\n" echo else printf "lmu applications telegraf install - install telegraf\n" echo fi printf "%s\n" "Usage:" printf " lmu applications telegraf install\n" printf " lmu applications telegraf install --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_applications_docker_usage() { if [[ -n $long_usage ]]; then printf "lmu applications docker - docker stuff\n" echo else printf "lmu applications docker - docker stuff\n" echo fi printf "%s\n" "Usage:" printf " lmu applications docker COMMAND\n" printf " lmu applications docker [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s install docker\n" "install" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_applications_docker_install_usage() { if [[ -n $long_usage ]]; then printf "lmu applications docker install - install docker\n" echo else printf "lmu applications docker install - install docker\n" echo fi printf "%s\n" "Usage:" printf " lmu applications docker install\n" printf " lmu applications docker install --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_webserver_usage() { if [[ -n $long_usage ]]; then printf "lmu webserver - commands useful for webservers\n" echo else printf "lmu webserver - commands useful for webservers\n" echo fi printf "%s\n" "Usage:" printf " lmu webserver COMMAND\n" printf " lmu webserver [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s commands for acme.sh\n" "acme.sh" printf " %s commands for php\n" "php " echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_webserver_acme.sh_usage() { if [[ -n $long_usage ]]; then printf "lmu webserver acme.sh - commands for acme.sh\n" echo else printf "lmu webserver acme.sh - commands for acme.sh\n" echo fi printf "%s\n" "Usage:" printf " lmu webserver acme.sh COMMAND\n" printf " lmu webserver acme.sh [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s install and configure acme.sh\n" "install" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_webserver_acme.sh_install_usage() { if [[ -n $long_usage ]]; then printf "lmu webserver acme.sh install - install and configure acme.sh\n" echo else printf "lmu webserver acme.sh install - install and configure acme.sh\n" echo fi printf "%s\n" "Usage:" printf " lmu webserver acme.sh install\n" printf " lmu webserver acme.sh install --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_webserver_php_usage() { if [[ -n $long_usage ]]; then printf "lmu webserver php - commands for php\n" echo else printf "lmu webserver php - commands for php\n" echo fi printf "%s\n" "Usage:" printf " lmu webserver php COMMAND\n" printf " lmu webserver php [COMMAND] --help | -h\n" echo printf "%s\n" "Commands:" printf " %s install php software for wordpress\n" "install" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } lmu_webserver_php_install_usage() { if [[ -n $long_usage ]]; then printf "lmu webserver php install - install php software for wordpress\n" echo else printf "lmu webserver php install - install php software for wordpress\n" echo fi printf "%s\n" "Usage:" printf " lmu webserver php install\n" printf " lmu webserver php install --help | -h\n" echo if [[ -n $long_usage ]]; then printf "%s\n" "Options:" printf " %s\n" "--help, -h" printf " Show this help\n" echo fi } normalize_input() { local arg flags while [[ $# -gt 0 ]]; do arg="$1" if [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then input+=("${BASH_REMATCH[1]}") input+=("${BASH_REMATCH[2]}") elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then input+=("${BASH_REMATCH[1]}") input+=("${BASH_REMATCH[2]}") elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then flags="${BASH_REMATCH[1]}" for ((i = 0; i < ${#flags}; i++)); do input+=("-${flags:i:1}") done else input+=("$arg") fi shift done } inspect_args() { if ((${#args[@]})); then readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort) echo args: for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done else echo args: none fi if ((${#other_args[@]})); then echo echo other_args: echo "- \${other_args[*]} = ${other_args[*]}" for i in "${!other_args[@]}"; do echo "- \${other_args[$i]} = ${other_args[$i]}" done fi if ((${#deps[@]})); then readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort) echo echo deps: for k in "${sorted_keys[@]}"; do echo "- \${deps[$k]} = ${deps[$k]}"; done fi } lmu_install_command() { #!/bin/bash if [ "${EUID}" -eq 0 ]; then root=true install_location=/usr/bin/ else install_location=~/.bin root=false fi get_version () { if which lmu; then new_version=$(bash <(curl -s https://cli.leffler.app) -v) old_version=$(lmu -v) if awk 'BEGIN{exit ARGV[1]>ARGV[2]}' "${new_version}" "${old_version}"; then echo "upgrading ${old_version} to ${new_version}" install_lmu else echo "${old_version} is up to date" fi echo 'lmu not installed, installing now' installing_lmu fi } install_lmu () { echo "installing lmu to ${install_location}/lmu" mkdir -p "${install_location}" curl -o "${install_location}/lmu" https://cli.leffler.app chmod +x "${install_location}/lmu" } get_version } lmu_log2ram_command() { #!/bin/bash apt update apt install -y rsync wget echo "deb [signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian/ bookworm main" | tee /etc/apt/sources.list.d/azlux.list wget -O /usr/share/keyrings/azlux-archive-keyring.gpg https://azlux.fr/repo.gpg apt update apt install -y log2ram } lmu_customize_etc_issue_command() { #!/bin/bash if [ "${EUID}" -ne 0 ]; then echo "Please run as root or sudo" exit 1 fi sed -i 's/ \\l$/\\l \\4{ens18}/' /etc/issue } lmu_monitoring_checkmk_install_command() { #!/bin/bash dlFile=/tmp/check-mk-agent.deb curl -o "${dlFile}" https://checkmk.leffler.support/cmk/check_mk/agents/check-mk-agent_2.0.0p39-1_all.deb dpkg -i "${dlFile}" rm -f "${dlFile}" } lmu_monitoring_zabbix_install_command() { #!/bin/bash apt update apt install -y wget wget -O/tmp/zabbix.deb https://repo.zabbix.com/zabbix/7.2/release/debian/pool/main/z/zabbix-release/zabbix-release_latest_7.2+debian12_all.deb dpkg -i /tmp/zabbix.deb rm -fv /tmp/zabbix.deb apt update apt install -y zabbix-agent2 systemctl enable --now zabbix-agent2 } lmu_logging_vector_install_command() { #!/bin/bash bash -c "$(curl -L https://setup.vector.dev)" apt-get install -y vector rm -rfv /etc/vector/examples } lmu_logging_vector_configure_command() { #!/bin/bash if ! which docker > /dev/null 2>&1; then echo 'Added vector to docker group' usermod -a -G docker vector docker=1 fi if [[ $docker == 1 ]]; then echo 'sources: journald: type: journald docker: type: docker_logs' > /etc/vector/vector.yaml else echo 'sources: journald: type: journald' > /etc/vector/vector.yaml fi if [[ $docker == 1 ]]; then echo 'sinks: vlogs: inputs: - journald - docker' >> /etc/vector/vector.yaml else echo 'sinks: vlogs: inputs: - journald' >> /etc/vector/vector.yaml fi echo \ ' type: elasticsearch endpoints: - api_version: v8 compression: gzip healthcheck: enabled: false query: _msg_field: message _time_field: timestamp _stream_fields: host,container_name' >> /etc/vector/vector.yaml } lmu_remote_add2mc_command() { #!/bin/bash cd /tmp (wget "https://mesh.leffler.support/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh || wget "https://mesh.leffler.support/meshagents?script=1" --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo -E ./meshinstall.sh https://mesh.leffler.support 'F7IWn6jwjIQRBh8cWMLhv9u2Hz2gC@2oQ$39O$XZMy8RJssLdMZxp2CzHSXznY3j' || ./meshinstall.sh https://mesh.leffler.support 'F7IWn6jwjIQRBh8cWMLhv9u2Hz2gC@2oQ$39O$XZMy8RJssLdMZxp2CzHSXznY3j' rm -rfv mesh* } lmu_remote_tailscale_install_command() { #!/bin/bash if [ "${EUID}" -ne 0 ]; then echo "Please run as root or sudo" exit 1 fi check_install () { if which curl; then echo "curl not installed, installing" if which apt; then apt install -y curl || exit 1 elif which yum; then yum install -y curl || exit 1 fi fi } check_install > /dev/null 2>&1 curl -fsSL https://tailscale.com/install.sh | sh } lmu_remote_tailscale_auth_command() { #!/bin/bash login-server="${args[--server]}" authkey="${args[authkey]}" routes="${args[--routes]-}" dns="${args[--dns]-}" if [ "${EUID}" -ne 0 ]; then echo "Please run as root or sudo" exit 1 fi if [ "$dns" ]; then dns="true" else dns="false" fi if [ "$routes" ]; then routes="true" else routes="false" fi tailscale up --login-server "${login-server}" --accept-routes=${routes} --accept-dns=${dns} --authkey "${authkey}" } lmu_remote_rathole_install_command() { #!/bin/bash version="${args[--version]}" service_unit=/etc/systemd/system/rathole.service rathole_config=/opt/rathole/config/config.toml bin_dir=/opt/rathole/bin/current create_user () { echo 'creating user' useradd -rm -d /opt/rathole/home rathole } create_dirs () { mkdir -p /opt/rathole/{bin,bin/current,data,config} chown rathole: -R /opt/rathole } install_rathole () { if ! which sudo > /dev/null 2>&1; then echo 'sudo not installed, installing now' apt install -y sudo fi echo 'installing rathole' mkdir -p "${bin_dir}" cd "${bin_dir}" || exit 1 sudo -u rathole wget -O archive.zip "https://github.com/rathole-org/rathole/releases/download/v0.5.0/rathole-x86_64-unknown-linux-gnu.zip" if ! which unzip > /dev/null 2>&1; then echo 'unzip not installed, installing now' apt install -y unzip fi unzip archive.zip rm -f archive.zip } install_service () { echo 'install rathole service' echo "[Unit]" > "${service_unit}" echo "Description=Rathole" >> "${service_unit}" echo "After=network.target" >> "${service_unit}" echo "" >> "${service_unit}" echo "[Service]" >> "${service_unit}" echo "Type=simple" >> "${service_unit}" echo "User=rathole" >> "${service_unit}" echo "Restart=on-failure" >> "${service_unit}" echo "RestartSec=5s" >> "${service_unit}" echo "LimitNOFILE=1048576" >> "${service_unit}" echo "" >> "${service_unit}" echo "ExecStart=/opt/rathole/bin/current/rathole /opt/rathole/config/config.toml" >> "${service_unit}" echo "" >> "${service_unit}" echo "[Install]" >> "${service_unit}" echo "WantedBy=multi-user.target" >> "${service_unit}" systemctl daemon-reload systemctl enable rathole.service } if [ "${EUID}" -ne 0 ]; then echo "Please run as root or sudo" exit 1 fi if [ -f "${bin_dir}/rathole" ]; then echo 'already installed, exiting' exit 1 fi if ! which wget > /dev/null 2>&1; then echo 'wget not installed, installing now' apt install -y wget fi create_user create_dirs install_rathole install_service } lmu_remote_rathole_configure_command() { echo "# this file is located in 'src/commands/remote/rathole/configure.sh'" echo "# code for 'lmu remote rathole configure' goes here" echo "# you can edit it freely and regenerate (it will not be overwritten)" inspect_args } lmu_users_ansible_command() { #!/bin/bash install_sudo () { apt update apt install sudo -y } add_user () { useradd -rm ansible mkdir -p /home/ansible/.ssh echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJG0zjARSDp+nr/0Cax9B27GjKkebrTH/arlz4CyhMznm1FxroVG0l8OKCnd3ZLVOyURmL0wIw0o4OPL52eyNycc0PMZweL1FTTS5qf6Ijbi6Y5hOS7h3ygGTj56mfgR/UiAVH0FRshKBJFrvIUD6ksJoJh3QkHOoiNXqEgdVUjggF408AXNFPpZQIaPIR5LjTaEY7YbUf0EKVWg9INev/Xm+0Md4+O/BbryfQUOs84wfZKzw4UuDmk2L9pLIuGnXGURUxMPVp/CJrWXNOYIQTImF2+HUIJKR/BqOda28gRBF+Jq+77u6HYt5bPG1HOGREzy2f8jg2oN/ZEaPyMOgH ansible-pub-key' >> /home/ansible/.ssh/authorized_keys chmod 0600 /home/ansible/.ssh/authorized_keys chown -R ansible:ansible /home/ansible echo 'ansible ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/99-ansible chmod 0440 /etc/sudoers.d/99-ansible } if id "ansible" &>/dev/null; then echo 'ansible user is already there' exit else echo 'user not found, creating it' if id "sudo" &>/dev/null; then echo 'sudo is already installed' else echo 'sudo not installed, installing it now' install_sudo fi add_user fi } lmu_system_mkswap_command() { #!/bin/bash swapFile=${args[location]} size=${args[--size]} if [ "${EUID}" -ne 0 ]; then echo "Please run as root or sudo" exit 1 fi # Turn off swap swapoff -a # Create swapfile fallocate -l "${size}G" "${swapFile}" chmod 0600 "${swapFile}" mkswap "${swapFile}" # Add to fstab echo -e "${swapFile}\tnone\tswap\tsw\t0 0" >> /etc/fstab # Turn on swap swapon -a } lmu_system_networking_ipforward_command() { echo "# this file is located in 'src/system_networking_ipforward_command.sh'" echo "# code for 'lmu system networking ipforward' goes here" echo "# you can edit it freely and regenerate (it will not be overwritten)" inspect_args } lmu_applications_telegraf_install_command() { #!/bin/bash if [ "${EUID}" -ne 0 ]; then echo "Please run as root or sudo" exit 1 fi # influxdata-archive_compat.key GPG fingerprint: # 9D53 9D90 D332 8DC7 D6C8 D3B9 D8FF 8E1F 7DF8 B07E wget -q https://repos.influxdata.com/influxdata-archive_compat.key echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | tee /etc/apt/sources.list.d/influxdata.list apt-get update && apt-get install telegraf } lmu_applications_docker_install_command() { #!/bin/bash if [ "${EUID}" -ne 0 ]; then echo "Please run as root or sudo" exit 1 fi curl -s https://get.docker.com | sh } lmu_webserver_acme.sh_install_command() { #!?bin/bash if [ "${EUID}" -ne 0 ]; then echo "Please run as root or sudo" exit 1 fi curl https://get.acme.sh | sh /root/.acme.sh/acme.sh --upgrade --auto-upgrade /root/.acme.sh/acme.sh --set-default-ca --server letsencrypt } lmu_webserver_php_install_command() { #!/bin/bash if [ "${EUID}" -ne 0 ]; then echo "Please run as root or sudo" exit 1 fi apt update apt install -y php-{fpm,curl,xml,common,imagick,json,mbstring,mysql,xml,zip,bcmath,gd,intl,mcrypt} } parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --version | -v) version_command exit ;; --help | -h) long_usage=yes lmu_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; install) action="install" shift lmu_install_parse_requirements "$@" shift $# ;; log2ram) action="log2ram" shift lmu_log2ram_parse_requirements "$@" shift $# ;; customize) action="customize" shift lmu_customize_parse_requirements "$@" shift $# ;; monitoring) action="monitoring" shift lmu_monitoring_parse_requirements "$@" shift $# ;; logging) action="logging" shift lmu_logging_parse_requirements "$@" shift $# ;; remote) action="remote" shift lmu_remote_parse_requirements "$@" shift $# ;; users) action="users" shift lmu_users_parse_requirements "$@" shift $# ;; system) action="system" shift lmu_system_parse_requirements "$@" shift $# ;; applications | apps) action="applications" shift lmu_applications_parse_requirements "$@" shift $# ;; webserver) action="webserver" shift lmu_webserver_parse_requirements "$@" shift $# ;; "") lmu_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_install_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_install_usage exit ;; *) break ;; esac done action="install" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_log2ram_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_log2ram_usage exit ;; *) break ;; esac done action="log2ram" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_customize_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_customize_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; etc_issue) action="etc_issue" shift lmu_customize_etc_issue_parse_requirements "$@" shift $# ;; "") lmu_customize_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_customize_etc_issue_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_customize_etc_issue_usage exit ;; *) break ;; esac done action="customize etc_issue" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_monitoring_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_monitoring_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; checkmk) action="checkmk" shift lmu_monitoring_checkmk_parse_requirements "$@" shift $# ;; zabbix) action="zabbix" shift lmu_monitoring_zabbix_parse_requirements "$@" shift $# ;; "") lmu_monitoring_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_monitoring_checkmk_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_monitoring_checkmk_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; install) action="install" shift lmu_monitoring_checkmk_install_parse_requirements "$@" shift $# ;; "") lmu_monitoring_checkmk_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_monitoring_checkmk_install_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_monitoring_checkmk_install_usage exit ;; *) break ;; esac done action="monitoring checkmk install" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_monitoring_zabbix_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_monitoring_zabbix_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; install) action="install" shift lmu_monitoring_zabbix_install_parse_requirements "$@" shift $# ;; "") lmu_monitoring_zabbix_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_monitoring_zabbix_install_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_monitoring_zabbix_install_usage exit ;; *) break ;; esac done action="monitoring zabbix install" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_logging_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_logging_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; vector) action="vector" shift lmu_logging_vector_parse_requirements "$@" shift $# ;; "") lmu_logging_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_logging_vector_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_logging_vector_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; install) action="install" shift lmu_logging_vector_install_parse_requirements "$@" shift $# ;; configure) action="configure" shift lmu_logging_vector_configure_parse_requirements "$@" shift $# ;; "") lmu_logging_vector_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_logging_vector_install_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_logging_vector_install_usage exit ;; *) break ;; esac done action="logging vector install" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_logging_vector_configure_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_logging_vector_configure_usage exit ;; *) break ;; esac done action="logging vector configure" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_remote_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_remote_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; add2mc) action="add2mc" shift lmu_remote_add2mc_parse_requirements "$@" shift $# ;; tailscale) action="tailscale" shift lmu_remote_tailscale_parse_requirements "$@" shift $# ;; rathole) action="rathole" shift lmu_remote_rathole_parse_requirements "$@" shift $# ;; "") lmu_remote_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_remote_add2mc_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_remote_add2mc_usage exit ;; *) break ;; esac done action="remote add2mc" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_remote_tailscale_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_remote_tailscale_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; install) action="install" shift lmu_remote_tailscale_install_parse_requirements "$@" shift $# ;; auth) action="auth" shift lmu_remote_tailscale_auth_parse_requirements "$@" shift $# ;; "") lmu_remote_tailscale_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_remote_tailscale_install_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_remote_tailscale_install_usage exit ;; *) break ;; esac done action="remote tailscale install" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_remote_tailscale_auth_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_remote_tailscale_auth_usage exit ;; *) break ;; esac done action="remote tailscale auth" while [[ $# -gt 0 ]]; do key="$1" case "$key" in --server | -s) if [[ -n ${2+x} ]]; then args['--server']="$2" shift shift else printf "%s\n" "--server requires an argument: --server, -s SERVER" >&2 exit 1 fi ;; --dns) args['--dns']=1 shift ;; --routes) args['--routes']=1 shift ;; -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) if [[ -z ${args['authkey']+x} ]]; then args['authkey']=$1 shift else printf "invalid argument: %s\n" "$key" >&2 exit 1 fi ;; esac done if [[ -z ${args['authkey']+x} ]]; then printf "missing required argument: AUTHKEY\nusage: lmu remote tailscale auth AUTHKEY [OPTIONS]\n" >&2 exit 1 fi [[ -n ${args['--server']:-} ]] || args['--server']="https://headscale.leffler.network" } lmu_remote_rathole_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_remote_rathole_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; install) action="install" shift lmu_remote_rathole_install_parse_requirements "$@" shift $# ;; configure) action="configure" shift lmu_remote_rathole_configure_parse_requirements "$@" shift $# ;; "") lmu_remote_rathole_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_remote_rathole_install_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_remote_rathole_install_usage exit ;; *) break ;; esac done action="remote rathole install" while [[ $# -gt 0 ]]; do key="$1" case "$key" in --version) if [[ -n ${2+x} ]]; then args['--version']="$2" shift shift else printf "%s\n" "--version requires an argument: --version VERSION" >&2 exit 1 fi ;; -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done [[ -n ${args['--version']:-} ]] || args['--version']="0.5.0" } lmu_remote_rathole_configure_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_remote_rathole_configure_usage exit ;; *) break ;; esac done action="remote rathole configure" while [[ $# -gt 0 ]]; do key="$1" case "$key" in --server | -s) if [[ -n ${2+x} ]]; then args['--server']="$2" shift shift else printf "%s\n" "--server requires an argument: --server, -s SERVER" >&2 exit 1 fi ;; --version) if [[ -n ${2+x} ]]; then args['--version']="$2" shift shift else printf "%s\n" "--version requires an argument: --version VERSION" >&2 exit 1 fi ;; --service_name | -n) if [[ -n ${2+x} ]]; then args['--service_name']="$2" shift shift else printf "%s\n" "--service_name requires an argument: --service_name, -n SERVICE_NAME" >&2 exit 1 fi ;; -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) if [[ -z ${args['local_service']+x} ]]; then args['local_service']=$1 shift else printf "invalid argument: %s\n" "$key" >&2 exit 1 fi ;; esac done if [[ -z ${args['local_service']+x} ]]; then printf "missing required argument: LOCAL_SERVICE\nusage: lmu remote rathole configure LOCAL_SERVICE [OPTIONS]\n" >&2 exit 1 fi if [[ -z ${args['--service_name']+x} ]]; then printf "missing required flag: --service_name, -n SERVICE_NAME\n" >&2 exit 1 fi [[ -n ${args['--server']:-} ]] || args['--server']="proxy.leffler.network:2332" [[ -n ${args['--version']:-} ]] || args['--version']="0.5.0" } lmu_users_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_users_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; ansible) action="ansible" shift lmu_users_ansible_parse_requirements "$@" shift $# ;; "") lmu_users_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_users_ansible_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_users_ansible_usage exit ;; *) break ;; esac done action="users ansible" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_system_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_system_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; mkswap) action="mkswap" shift lmu_system_mkswap_parse_requirements "$@" shift $# ;; networking) action="networking" shift lmu_system_networking_parse_requirements "$@" shift $# ;; "") lmu_system_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_system_mkswap_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_system_mkswap_usage exit ;; *) break ;; esac done action="system mkswap" while [[ $# -gt 0 ]]; do key="$1" case "$key" in --size | -s) if [[ -n ${2+x} ]]; then args['--size']="$2" shift shift else printf "%s\n" "--size requires an argument: --size, -s SIZE" >&2 exit 1 fi ;; -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) if [[ -z ${args['location']+x} ]]; then args['location']=$1 shift else printf "invalid argument: %s\n" "$key" >&2 exit 1 fi ;; esac done [[ -n ${args['location']:-} ]] || args['location']="/swap.file" [[ -n ${args['--size']:-} ]] || args['--size']="2" } lmu_system_networking_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_system_networking_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; ipforward) action="ipforward" shift lmu_system_networking_ipforward_parse_requirements "$@" shift $# ;; "") lmu_system_networking_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_system_networking_ipforward_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_system_networking_ipforward_usage exit ;; *) break ;; esac done action="system networking ipforward" while [[ $# -gt 0 ]]; do key="$1" case "$key" in --remove) if [[ -n ${2+x} ]]; then args['--remove']="$2" shift shift else printf "%s\n" "--remove requires an argument: --remove REMOVE" >&2 exit 1 fi ;; -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_applications_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_applications_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; telegraf) action="telegraf" shift lmu_applications_telegraf_parse_requirements "$@" shift $# ;; docker) action="docker" shift lmu_applications_docker_parse_requirements "$@" shift $# ;; "") lmu_applications_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_applications_telegraf_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_applications_telegraf_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; install) action="install" shift lmu_applications_telegraf_install_parse_requirements "$@" shift $# ;; "") lmu_applications_telegraf_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_applications_telegraf_install_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_applications_telegraf_install_usage exit ;; *) break ;; esac done action="applications telegraf install" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_applications_docker_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_applications_docker_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; install) action="install" shift lmu_applications_docker_install_parse_requirements "$@" shift $# ;; "") lmu_applications_docker_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_applications_docker_install_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_applications_docker_install_usage exit ;; *) break ;; esac done action="applications docker install" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_webserver_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_webserver_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; acme.sh) action="acme.sh" shift lmu_webserver_acme.sh_parse_requirements "$@" shift $# ;; php) action="php" shift lmu_webserver_php_parse_requirements "$@" shift $# ;; "") lmu_webserver_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_webserver_acme.sh_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_webserver_acme.sh_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; install) action="install" shift lmu_webserver_acme.sh_install_parse_requirements "$@" shift $# ;; "") lmu_webserver_acme.sh_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_webserver_acme.sh_install_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_webserver_acme.sh_install_usage exit ;; *) break ;; esac done action="webserver acme.sh install" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_webserver_php_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_webserver_php_usage exit ;; *) break ;; esac done action=${1:-} case $action in -*) ;; install) action="install" shift lmu_webserver_php_install_parse_requirements "$@" shift $# ;; "") lmu_webserver_php_usage >&2 exit 1 ;; *) printf "invalid command: %s\n" "$action" >&2 exit 1 ;; esac while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } lmu_webserver_php_install_parse_requirements() { while [[ $# -gt 0 ]]; do case "${1:-}" in --help | -h) long_usage=yes lmu_webserver_php_install_usage exit ;; *) break ;; esac done action="webserver php install" while [[ $# -gt 0 ]]; do key="$1" case "$key" in -?*) printf "invalid option: %s\n" "$key" >&2 exit 1 ;; *) printf "invalid argument: %s\n" "$key" >&2 exit 1 ;; esac done } initialize() { version="0.0.2" long_usage='' set -euo pipefail } run() { declare -A args=() declare -A deps=() declare -a other_args=() declare -a input=() normalize_input "$@" parse_requirements "${input[@]}" case "$action" in "install") lmu_install_command ;; "log2ram") lmu_log2ram_command ;; "customize") lmu_customize_command ;; "customize etc_issue") lmu_customize_etc_issue_command ;; "monitoring") lmu_monitoring_command ;; "monitoring checkmk") lmu_monitoring_checkmk_command ;; "monitoring checkmk install") lmu_monitoring_checkmk_install_command ;; "monitoring zabbix") lmu_monitoring_zabbix_command ;; "monitoring zabbix install") lmu_monitoring_zabbix_install_command ;; "logging") lmu_logging_command ;; "logging vector") lmu_logging_vector_command ;; "logging vector install") lmu_logging_vector_install_command ;; "logging vector configure") lmu_logging_vector_configure_command ;; "remote") lmu_remote_command ;; "remote add2mc") lmu_remote_add2mc_command ;; "remote tailscale") lmu_remote_tailscale_command ;; "remote tailscale install") lmu_remote_tailscale_install_command ;; "remote tailscale auth") lmu_remote_tailscale_auth_command ;; "remote rathole") lmu_remote_rathole_command ;; "remote rathole install") lmu_remote_rathole_install_command ;; "remote rathole configure") lmu_remote_rathole_configure_command ;; "users") lmu_users_command ;; "users ansible") lmu_users_ansible_command ;; "system") lmu_system_command ;; "system mkswap") lmu_system_mkswap_command ;; "system networking") lmu_system_networking_command ;; "system networking ipforward") lmu_system_networking_ipforward_command ;; "applications") lmu_applications_command ;; "applications telegraf") lmu_applications_telegraf_command ;; "applications telegraf install") lmu_applications_telegraf_install_command ;; "applications docker") lmu_applications_docker_command ;; "applications docker install") lmu_applications_docker_install_command ;; "webserver") lmu_webserver_command ;; "webserver acme.sh") lmu_webserver_acme.sh_command ;; "webserver acme.sh install") lmu_webserver_acme.sh_install_command ;; "webserver php") lmu_webserver_php_command ;; "webserver php install") lmu_webserver_php_install_command ;; esac } initialize run "$@"