diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9afee1b..2a80c6f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -103,7 +103,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} v3_15: @@ -198,7 +198,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} v3_14: @@ -293,7 +293,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} v3_13: @@ -389,7 +389,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} v3_12: @@ -485,7 +485,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} v3_11: @@ -581,7 +581,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} v3_10: @@ -677,7 +677,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} v3_9: @@ -773,7 +773,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} v3_8: @@ -965,7 +965,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm64 + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} v3_6: @@ -1061,7 +1061,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm/v6,linux/arm64 + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} v3_5: diff --git a/CHANGELOG.md b/CHANGELOG.md index e441e99..14b3d11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +## 7.3.0 2022-02-07 + + ### Added + - S6 Overlay 3.0.0.2 + - FluentBit 1.7.12 + - Zabbix Agent 5.4.10 + - New functions (create_zabbix) for easier development + - doas package for eventual replacement of sudo + - Added new helpers on command line (service_up/service_down/changelog/version) + - Added banner showing image name and version upon startup + - Custom Bash Prompt when entering in container + + ### Changed + - Stop relying on /usr/bin/with-contenv - Instead use recommended /command/ folder as outlined in S6 overlay documentation + - Cleanup of code and allow for CaMeLCasE environment variables (specifically for var_true/var_false and others) + - Many optimizations and cleanup of scripts for pure modernization sake + + ### Removed + - Removed fix-attrs.d reliance due to deprecation by S6 Overlay + ## 7.2.19 2022-01-20 ### Changed diff --git a/Dockerfile b/Dockerfile index 59cfd02..2f11595 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,14 +2,16 @@ FROM docker.io/alpine:3.15 LABEL maintainer="Dave Conroy (github.com/tiredofit)" ARG GOLANG_VERSION=1.17.6 -ARG ZABBIX_VERSION +ARG DOAS_VERSION ARG FLUENTBIT_VERSION ARG S6_OVERLAY_VERSION +ARG ZABBIX_VERSION ### Set defaults -ENV FLUENTBIT_VERSION=${FLUENTBIT_VERSION:-"1.8.11"} \ - S6_OVERLAY_VERSION=${S6_OVERLAY_VERSION:-"v2.2.0.3"} \ - ZABBIX_VERSION=${ZABBIX_VERSION:-"5.4.9"} \ +ENV FLUENTBIT_VERSION=${FLUENTBIT_VERSION:-"1.8.12"} \ + S6_OVERLAY_VERSION=${S6_OVERLAY_VERSION:-"3.0.0.2"} \ + ZABBIX_VERSION=${ZABBIX_VERSION:-"5.4.10"} \ + DOAS_VERSION=${DOAS_VERSION:-"v6.8.2"} \ DEBUG_MODE=FALSE \ TIMEZONE=Etc/GMT \ CONTAINER_ENABLE_SCHEDULING=TRUE \ @@ -18,16 +20,20 @@ ENV FLUENTBIT_VERSION=${FLUENTBIT_VERSION:-"1.8.11"} \ CONTAINER_MESSAGING_BACKEND=msmtp \ CONTAINER_ENABLE_MONITORING=TRUE \ CONTAINER_MONITORING_BACKEND=zabbix \ - CONTAINER_ENABLE_LOGSHIPPING=FALSE + CONTAINER_ENABLE_LOGSHIPPING=FALSE \ + S6_GLOBAL_PATH=/command:/usr/bin:/bin:/usr/sbin:sbin:/usr/local/bin:/usr/local/sbin \ + S6_KEEP_ENV=1 \ + IMAGE_NAME="tiredofit/alpine" \ + IMAGE_REPO_URL="https://github.com/tiredofit/docker-alpine/" ## Mono Repo workarounds RUN case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f 1,2)" in \ - 3.5|3.6) no_upx=true ;; \ + "3.5" | "3.6" ) no_upx=true ;; \ *) busybox_extras="busybox-extras" ;; \ esac ; \ \ case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f 1,2)" in \ - "3.11" |"3.12" | "3.13" | "3.14" | "3.15" ) zabbix_args=" --enable-agent2 " ; zabbix_agent2=true ; fluentbit_make=true ;; \ + "3.11" |"3.12" | "3.13" | "3.14" | "3.15" | "edge" ) zabbix_args=" --enable-agent2 " ; zabbix_agent2=true ; fluentbit_make=true ;; \ *) : ;; \ esac ; \ \ @@ -38,18 +44,24 @@ RUN case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f esac; \ \ case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f 1,2)" in \ - 3.5|3.6) upx="" ;; \ + "3.5"| "3.6") upx="" ;; \ esac ; \ \ -## + case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f 1,2)" in \ + "3.5" | "3.6" | "3.7" | "3.8" ) build_doas=true ;; \ + *) doas_package="doas" ;; \ + esac ; \ + ## set -ex && \ apk update && \ apk upgrade && \ ### Add core utils apk add -t .base-rundeps \ bash \ + bc \ ${busybox_extras} \ curl \ + ${doas_package} \ fts \ grep \ iputils \ @@ -102,7 +114,18 @@ RUN case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f ## Quiet down sudo echo "Set disable_coredump false" > /etc/sudo.conf && \ \ -### Golang installation +### Build Doas + if [ "$build_doas" = "true" ] ; then \ + mkdir -p /usr/src/doas ; \ + curl -sSL https://github.com/Duncaen/OpenDoas/archive/${DOAS_VERSION}.tar.gz | tar xfz - --strip 1 -C /usr/src/doas ; \ + cd /usr/src/doas ; \ + ./configure --prefix=/usr \ + --enable-static \ + --without-pam ; \ + make ; \ + make install ; \ + fi ; \ + ### Golang installation if [ "$zabbix_agent2" = "true" ] ; then \ mkdir -p /usr/src/golang ; \ curl -sSL https://dl.google.com/go/go${GOLANG_VERSION}.src.tar.gz | tar xvfz - --strip 1 -C /usr/src/golang ; \ @@ -218,7 +241,7 @@ RUN case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f -DFLB_RELEASE=Yes \ -DFLB_SHARED_LIB=No \ -DFLB_SIGNV4=No \ - -DFLB_SMALL=No \ + -DFLB_SMALL=Yes \ . && \ if [ "$fluentbit_make" = "true" ] ; then if [ "$apkArch" = "x86_64" ] ; then make -j"$(nproc)" ; make install ; mv /usr/etc/fluent-bit /etc/fluent-bit ; mkdir -p /etc/fluent-bit/parsers.d; mkdir -p /etc/fluent-bit/conf.d ; strip /usr/bin/fluent-bit ; if [ "$apkArch" = "x86_64" ] && [ "$no_upx" != "true" ]; then upx /usr/bin/fluent-bit ; fi ; fi ; fi ;\ \ @@ -231,13 +254,15 @@ RUN case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f #mv promtail /usr/sbin && \ \ ### Clean up - mkdir -p /etc/logrotate.d && \ + mkdir -p /etc/logrotate && \ + mkdir -p /etc/doas.d && \ apk del --purge \ .fluentbit-build-deps \ .golang-build-deps \ .zabbix-build-deps \ && \ rm -rf /etc/logrotate.d/* && \ + rm -rf /etc/doas.conf /etc/doas.d/* && \ rm -rf /root/.cache && \ rm -rf /root/go && \ rm -rf /tmp/* && \ @@ -245,15 +270,34 @@ RUN case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f rm -rf /var/cache/apk/* && \ \ ### S6 overlay installation + apkArch="$(apk --print-arch)" && \ case "$apkArch" in \ - x86_64) s6Arch='amd64' ;; \ - armv7) s6Arch='arm' ;; \ + x86_64) s6Arch='x86_64' ;; \ + armv7) s6Arch='armhf' ;; \ armhf) s6Arch='armhf' ;; \ aarch64) s6Arch='aarch64' ;; \ - ppc64le) s6Arch='ppc64le' ;; \ *) echo >&2 "Error: unsupported architecture ($apkArch)"; exit 1 ;; \ esac; \ - curl -sSL https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-${s6Arch}.tar.gz | tar xfz - -C / + curl -sSL https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch-${S6_OVERLAY_VERSION}.tar.xz | tar xvpfJ - -C / && \ + curl -sSL https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${s6Arch}-${S6_OVERLAY_VERSION}.tar.xz | tar xvpfJ - -C / && \ + curl -sSL https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch-${S6_OVERLAY_VERSION}.tar.xz | tar xvpfJ - -C / && \ + curl -sSL https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch-${S6_OVERLAY_VERSION}.tar.xz | tar xvpfJ - -C / && \ + mkdir -p /etc/cont-init.d && \ + mkdir -p /etc/cont-finish.d && \ + mkdir -p /etc/services.d && \ + chown -R 0755 /etc/cont-init.d && \ + chown -R 0755 /etc/cont-finish.d && \ + chmod -R 0755 /etc/services.d && \ + # To remove when S6 3.1.0 is released + echo "/command:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin" > /etc/s6-overlay/config/global_path && \ + ## + sed -i "s|s6-rc -v2|s6-rc -v1|g" /package/admin/s6-overlay/etc/s6-linux-init/skel/rc.init && \ + sed -i "s|s6-rc -v2|s6-rc -v1|g" /package/admin/s6-overlay/etc/s6-linux-init/skel/rc.shutdown && \ + sed -i "s|echo|# echo |g" /package/admin/s6-overlay/etc/s6-rc/scripts/cont-init && \ + sed -i "s|echo|# echo |g" /package/admin/s6-overlay/etc/s6-rc/scripts/cont-finish && \ + sed -i "s|echo ' (no readiness notification)'|# echo ' (no readiness notification)'|g" /package/admin/s6-overlay/etc/s6-rc/scripts/services-up && \ + sed -i "s|s6-echo -n|# s6-echo -n|g" /package/admin/s6-overlay/etc/s6-rc/scripts/services-up + ### Networking configuration EXPOSE 2020/TCP 10050/TCP @@ -262,4 +306,4 @@ EXPOSE 2020/TCP 10050/TCP ENTRYPOINT ["/init"] ### Add folders -ADD install/ / +COPY install/ / diff --git a/LICENSE b/LICENSE index 81d2163..5dd7a07 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Dave Conroy +Copyright (c) 2022 Dave Conroy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 82a2dd4..18d1f76 100644 --- a/README.md +++ b/README.md @@ -122,19 +122,20 @@ The following directories are used for configuration and can be mapped for persi Below is the complete list of available options that can be used to customize your installation. #### Container Options -| Parameter | Description | Default | -| ----------------------------------- | ---------------------------------------------------------------------- | ------------------------ | -| `CONAINER_ENABLE_LOG_TIMESTAMP` | Prefix this images container logs with timestamp | `TRUE` | -| `CONTAINER_COLORIZE_OUTPUT` | Enable/Disable colorized console output | `TRUE` | -| `CONTAINER_CUSTOM_PATH` | Used for adding custom files into the image upon startup | `/assets/custom` | -| `CONTAINER_CUSTOM_SCRIPTS_PATH` | Used for adding custom scripts to execute upon startup | `/assets/custom-scripts` | -| `CONTAINER_ENABLE_PROCESS_COUNTER` | Show how many times process has executed in console log | `TRUE` | -| `CONTAINER_LOG_LEVEL` | Control level of output of container `INFO`, `WARN`, `NOTICE`, `DEBUG` | `NOTICE` | -| `CONTAINER_LOG_TIMESAMP_TIME_FMT` | Timestamp Time Format | `%H:%M:%S` | -| `CONTAINER_LOG_TIMESTAMP_DATE_FMT` | Timestamp Date Format | `%Y-%m-%d` | -| `CONTAINER_LOG_TIMESTAMP_SEPERATOR` | Timestamp seperator | `-` | -| `CONTAINER_NAME` | Used for setting entries in Monnitoring and Log Shipping | (hostname) | -| `TIMEZONE` | Set Timezone | `Etc/GMT` | +| Parameter | Description | Default | +| ----------------------------------- | ----------------------------------------------------------------------------------- | ------------------------ | +| `CONAINER_ENABLE_LOG_TIMESTAMP` | Prefix this images container logs with timestamp | `TRUE` | +| `CONTAINER_COLORIZE_OUTPUT` | Enable/Disable colorized console output | `TRUE` | +| `CONTAINER_CUSTOM_BASH_PROMPT` | If you wish to set a different bash prompt then '(imagename):(version) HH:MM:SS # ' | | +| `CONTAINER_CUSTOM_PATH` | Used for adding custom files into the image upon startup | `/assets/custom` | +| `CONTAINER_CUSTOM_SCRIPTS_PATH` | Used for adding custom scripts to execute upon startup | `/assets/custom-scripts` | +| `CONTAINER_ENABLE_PROCESS_COUNTER` | Show how many times process has executed in console log | `TRUE` | +| `CONTAINER_LOG_LEVEL` | Control level of output of container `INFO`, `WARN`, `NOTICE`, `DEBUG` | `NOTICE` | +| `CONTAINER_LOG_TIMESAMP_TIME_FMT` | Timestamp Time Format | `%H:%M:%S` | +| `CONTAINER_LOG_TIMESTAMP_DATE_FMT` | Timestamp Date Format | `%Y-%m-%d` | +| `CONTAINER_LOG_TIMESTAMP_SEPERATOR` | Timestamp seperator | `-` | +| `CONTAINER_NAME` | Used for setting entries in Monnitoring and Log Shipping | (hostname) | +| `TIMEZONE` | Set Timezone | `Etc/GMT` | #### Scheduling Options @@ -380,7 +381,7 @@ See `/assets/functions/00-container` for more detailed documentation for the var Put at the top: ````bash -#!/usr/bin/with-contenv bash # Pull in Container Environment Variables from Dockerfile/Docker Runtime +#!/command/with-contenv bash # Pull in Container Environment Variables from Dockerfile/Docker Runtime source /assets/functions/00-container # Pull in all custom container functions from this image prepare_service single # Read functions and defaults only from files matching this script filename - see detailed docs for more PROCESS_NAME="process" # set the prefix for any logging @@ -398,7 +399,7 @@ liftoff # this writes to the state files at /tmp/s Put at the top: ````bash -#!/usr/bin/with-contenv bash # Pull in Container Environment Variables from Dockerfile/Docker Runtime +#!/command/with-contenv bash # Pull in Container Environment Variables from Dockerfile/Docker Runtime source /assets/functions/00-container # Pull in all custom container functions from this image prepare_service defaults single # Read defaults only from files matching this script filename - see detailed docs for more PROCESS_NAME="process" # set the prefix for any logging diff --git a/install/assets/defaults/00-container b/install/assets/defaults/00-container index 96c422e..370d45b 100755 --- a/install/assets/defaults/00-container +++ b/install/assets/defaults/00-container @@ -1,21 +1,32 @@ -#!/usr/bin/with-contenv bash +#!/command/with-contenv bash ### Set defaults CONTAINER_CUSTOM_PATH=${CONTAINER_CUSTOM_PATH:-"/assets/custom/"} CONTAINER_CUSTOM_SCRIPTS_PATH=${CONTAINER_CUSTOM_SCRIPTS_PATH:-"/assets/custom-scripts/"} +CONTAINER_ENABLE_CUSTOM_BASH_PROMPT=${CONTAINER_ENABLE_CUSTOM_BASH_PROMPT:-"TRUE"} CONTAINER_ENABLE_DOCKER_SECRETS=${CONTAINER_ENABLE_DOCKER_SECRETS:-"TRUE"} -CONTAINER_ENABLE_PROCESS_COUNTER=${CONTAINER_ENABLE_PROCESS_COUNTER:-"TRUE"} +CONTAINER_ENABLE_LOGROTATE=${CONTAINER_ENABLE_LOGROTATE:-"TRUE"} +CONTAINER_ENABLE_LOGSHIPPING=${CONTAINER_ENABLE_LOGSHIPPING:-"FALSE"} CONTAINER_ENABLE_LOG_PREFIX=${CONTAINER_ENABLE_LOG_PREFIX:-"TRUE"} +CONTAINER_ENABLE_MESSAGING=${CONTAINER_ENABLE_MESSAGING:-"TRUE"} +CONTAINER_ENABLE_MONITORING=${CONTAINER_ENABLE_MONITORING:-"TRUE"} +CONTAINER_ENABLE_PERMISSIONS=${CONTAINER_ENABLE_PERMISSIONS:-"TRUE"} +CONTAINER_ENABLE_PROCESS_COUNTER=${CONTAINER_ENABLE_PROCESS_COUNTER:-"TRUE"} CONTAINER_ENABLE_PROCESS_HELPER=${CONTAINER_ENABLE_PROCESS_HELPER:-"TRUE"} +CONTAINER_ENABLE_SCHEDULING=${CONTAINER_ENABLE_SCHEDULING:-"TRUE"} +CONTAINER_LOGSHIPPING_BACKEND=${CONTAINER_LOGSHIPPING_BACKEND:-"fluent-bit"} CONTAINER_LOG_LEVEL=${CONTAINER_LOG_LEVEL:-"NOTICE"} CONTAINER_LOG_PREFIX_DATE_FMT=${CONTAINER_LOG_PREFIX_DATE_FMT:-"%Y-%m-%d"} -CONTAINER_LOG_PREFIX_SEPERATOR=${CONTAINER_LOG_PREFIX_SEPERATOR:-"-"} +CONTAINER_LOG_PREFIX_SEPERATOR=${CONTAINER_LOG_PREFIX_SEPERATOR:-"."} CONTAINER_LOG_PREFIX_TIME_FMT=${CONTAINER_LOG_PREFIX_TIME_FMT:-"%H:%M:%S"} +CONTAINER_MESSAGING_BACKEND=${CONTAINER_MESSAGING_BACKEND:-"msmtp"} +CONTAINER_MONITORING_BACKEND=${CONTAINER_MONITORING_BACKEND:-"zabbix"} CONTAINER_NAME=${CONTAINER_NAME:-"$(hostname)"} CONTAINER_PROCESS_HELPER_DATE_FMT=${CONTAINER_PROCESS_HELPER_DATE_FMT:-"%Y-%m-%d"} CONTAINER_PROCESS_HELPER_PATH=${CONTAINER_PROCESS_HELPER_PATH:-"/assets/container/processhelper/"} CONTAINER_PROCESS_HELPER_SCRIPT=${CONTAINER_PROCESS_HELPER_SCRIPT:-"processhelper.sh"} CONTAINER_PROCESS_HELPER_TIME_FMT=${CONTAINER_PROCESS_HELPER_TIME_FMT:-"%H:%M:%S"} +CONTAINER_SCHEDULING_BACKEND=${CONTAINER_SCHEDULING_BACKEND:-"cron"} CONTAINER_SCHEDULING_LOCATION=${CONTAINER_SCHEDULING_LOCATION:-"/assets/cron/"} CONTAINER_SKIP_SANITY_CHECK=${CONTAINER_SKIP_SANITY_CHECK:-"FALSE"} DEBUG_MODE=${DEBUG_MODE:-"FALSE"} diff --git a/install/assets/defaults/02-permissions b/install/assets/defaults/02-permissions index 19d9d6b..a447184 100755 --- a/install/assets/defaults/02-permissions +++ b/install/assets/defaults/02-permissions @@ -1,4 +1,3 @@ -#!/usr/bin/with-contenv bash +#!/command/with-contenv bash -CONTAINER_ENABLE_PERMISSIONS=${CONTAINER_ENABLE_PERMISSIONS:-"TRUE"} DEBUG_PERMISSIONS=${DEBUG_PERMISSIONS:-"FALSE"} diff --git a/install/assets/defaults/03-monitoring b/install/assets/defaults/03-monitoring index 39fa58e..cd20e44 100755 --- a/install/assets/defaults/03-monitoring +++ b/install/assets/defaults/03-monitoring @@ -1,7 +1,5 @@ -#!/usr/bin/with-contenv bash +#!/command/with-contenv bash -CONTAINER_ENABLE_MONITORING=${CONTAINER_ENABLE_MONITORING:-"TRUE"} -CONTAINER_MONITORING_BACKEND=${CONTAINER_MONITORING_BACKEND:-"zabbix"} ZABBIX_AGENT_LOG_FILE=${ZABBIX_AGENT_LOG_FILE:-"zabbix_agentd.log"} ZABBIX_AGENT_LOG_PATH=${ZABBIX_AGENT_LOG_PATH:-"/var/log/zabbix/agent/"} ZABBIX_ALLOW_ROOT=${ZABBIX_ALLOW_ROOT:-"1"} @@ -29,19 +27,18 @@ ZABBIX_SOCKET=${ZABBIX_SOCKET:-"/var/lib/zabbix/run/zabbix-agent.sock"} ZABBIX_START_AGENTS=${ZABBIX_START_AGENTS:-"1"} ZABBIX_STATUS_PORT=${ZABBIX_STATUS_PORT:-"8050"} ZABBIX_USER=${ZABBIX_USER:-"zabbix"} +ZABBIX_USER_DOAS=${ZABBIX_USER_DOAS:-"TRUE"} ZABBIX_USER_SUDO=${ZABBIX_USER_SUDO:-"TRUE"} os=$(cat /etc/os-release |grep ^ID= | cut -d = -f2) case ${os} in "alpine" ) - case "$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f 1,2)" in - 3.11|3.12|3.13|3.14|3.15|3.16|edge ) - ZABBIX_AGENT_TYPE=${ZABBIX_AGENT_TYPE:-"modern"} - ;; - *) - ZABBIX_AGENT_TYPE=${ZABBIX_AGENT_TYPE:-"classic"} - ;; - esac + osver=$(cat /etc/os-release | grep VERSION_ID | cut -d = -f 2 | cut -d . -f 1,2) + if (( $(bc -l <<< "$osver >= 3.11") )) || [ "$osver" = "edge" ] ; then + ZABBIX_AGENT_TYPE=${ZABBIX_AGENT_TYPE:-"modern"} + else + ZABBIX_AGENT_TYPE=${ZABBIX_AGENT_TYPE:-"classic"} + fi ;; "debian" ) ZABBIX_AGENT_TYPE=${ZABBIX_AGENT_TYPE:-"modern"} diff --git a/install/assets/defaults/04-scheduling b/install/assets/defaults/04-scheduling index b139eba..3674b18 100755 --- a/install/assets/defaults/04-scheduling +++ b/install/assets/defaults/04-scheduling @@ -1,7 +1,5 @@ -#!/usr/bin/with-contenv bash +#!/command/with-contenv bash -CONTAINER_ENABLE_SCHEDULING=${CONTAINER_ENABLE_SCHEDULING:-"TRUE"} -CONTAINER_SCHEDULING_BACKEND=${CONTAINER_SCHEDULING_BACKEND:-"cron"} SCHEDULING_LOG_TYPE=${SCHEDULING_LOG_TYPE:-"FILE"} SCHEDULING_LOG_LOCATION=${SCHEDULING_LOG_LOCATION:-"/var/log/cron/"} SCHEDULING_LOG_LEVEL=${SCHEDULING_LOG_LEVEL:-"8"} \ No newline at end of file diff --git a/install/assets/defaults/05-logging b/install/assets/defaults/05-logging index 13b0602..fe3df81 100755 --- a/install/assets/defaults/05-logging +++ b/install/assets/defaults/05-logging @@ -1,8 +1,5 @@ -#!/usr/bin/with-contenv bash +#!/command/with-contenv bash -CONTAINER_ENABLE_LOGROTATE=${CONTAINER_ENABLE_LOGROTATE:-"TRUE"} -CONTAINER_ENABLE_LOGSHIPPING=${CONTAINER_ENABLE_LOGSHIPPING:-"FALSE"} -CONTAINER_LOGSHIPPING_BACKEND=${CONTAINER_LOGSHIPPING_BACKEND:-"fluent-bit"} FLUENTBIT_CONFIG_PARSERS=${FLUENTBIT_CONFIG_PARSERS:-"parsers.conf"} FLUENTBIT_CONFIG_PLUGINS=${FLUENTBIT_CONFIG_PLUGINS:-"plugins.conf"} FLUENTBIT_ENABLE_HTTP_SERVER=${FLUENTBIT_ENABLE_HTTP_SERVER:-"TRUE"} diff --git a/install/assets/defaults/06-messaging b/install/assets/defaults/06-messaging index 3d67571..9a0c872 100755 --- a/install/assets/defaults/06-messaging +++ b/install/assets/defaults/06-messaging @@ -1,7 +1,5 @@ -#!/usr/bin/with-contenv bash +#!/command/with-contenv bash -CONTAINER_ENABLE_MESSAGING=${CONTAINER_ENABLE_MESSAGING:-"TRUE"} -CONTAINER_MESSAGING_BACKEND=${CONTAINER_MESSAGING_BACKEND:-"msmtp"} SMTP_AUTO_FROM=${SMTP_AUTO_FROM:-"FALSE"} SMTP_DOMAIN=${SMTP_DOMAIN:-"docker"} SMTP_HOST=${SMTP_HOST:-"postfix-relay"} diff --git a/install/assets/functions/00-container b/install/assets/functions/00-container index 777937b..66813d5 100755 --- a/install/assets/functions/00-container +++ b/install/assets/functions/00-container @@ -1,65 +1,18 @@ -#!/usr/bin/with-contenv bash +#!/command/with-contenv bash source /assets/defaults/00-container -### Colours -# Foreground (Text) Colors -cbl="\e[30m" # Color Black -cdr="\e[31m" # Color Dark Red -cdg="\e[32m" # Color Dark Green -cdy="\e[33m" # Color Dark Yellow -cdb="\e[34m" # Color Dark Blue -cdm="\e[35m" # Color Dark Magenta -cdc="\e[36m" # Color Dark Cyan -cdgy="\e[90m" # Color Dark Gray -clgy="\e[37m" # Color Light Gray -clr="\e[91m" # Color Light Red -clg="\e[92m" # Color Light Green -cly="\e[93m" # Color Light Yellow -clb="\e[94m" # Color Light Blue -clm="\e[95m" # Color Light Magenta -clc="\e[96m" # Color Light Cyan -cwh="\e[97m" # Color White - -# Turns off all formatting -coff="\e[0m" # Color Off - # Background Colors -bbl="\e[40m" # Background Color Black -bdr="\e[41m" # Background Color Dark Red bdg="\e[42m" # Background Color Dark Green -bdy="\e[43m" # Background Color Dark Yellow bdb="\e[44m" # Background Color Dark Blue bdm="\e[45m" # Background Color Dark Magenta -bdc="\e[46m" # Background Color Dark Cyan bdgy="\e[100m" # Background Color Dark Gray -blgy="\e[47m" # Background Color Light Gray blr="\e[101m" # Background Color Light Red -blg="\e[102m" # Background Color Light Green -bly="\e[103m" # Background Color Light Yellow -blb="\e[104m" # Background Color Light Blue -blm="\e[105m" # Background Color Light Magenta -blc="\e[106m" # Background Color Light Cyan -bwh="\e[107m" # Background Color White boff="\e[49m" # Background Color Off -# Styles -sbo="\e[1m" # Style Bold -sdi="\e[2m" # Style Dim -sun="\e[4m" # Style Underline -sbl="\e[5m" # Style Blink -sre="\e[7m" # Style Reverse -shi="\e[8m" # Style Hidden -sbof="\e[21m" # Style Bold Off -sdif="\e[22m" # Style Dim Off -sunf="\e[24m" # Style Underline Off -sblf="\e[25m" # Style Blink Off -sref="\e[27m" # Style Reverse Off -shif="\e[28m" # Style Hidden Off - - -### Check to see Initialization Script ran + check_container_initialized() { + ### Check to see Initialization Script ran print_debug "Checking to see if container initialization scripts have completed" output_off while [ ! -f /tmp/state/99-container-init ]; do @@ -89,7 +42,7 @@ check_service_initialized() { if [ "$csi_bypass" = "FALSE" ] ; then if [ -z "$2" ]; then case "$(dirname "$0")" in - "/var/run/s6/etc/cont-init.d") + "/var/run/s6/etc/cont-init.d" | "/etc/cont-init.d" ) service=$(basename "$0") ;; *) @@ -111,10 +64,10 @@ check_service_initialized() { } create_logrotate() { -## Usage (optional logship parser) (optional user) (optional group) (optional logship parser) -## e.g. create_logrotate cron /var/log/cron/cron.log cron root root -## If you dont have a parser just use 'none' -## If you are passing wilcard characters ie /logs/*.log make sure you 'set -f' before the function and 'set +f' afterwards. + ## Usage (optional logship parser) (optional user) (optional group) (optional logship parser) + ## e.g. create_logrotate cron /var/log/cron/cron.log cron root root + ## If you dont have a parser just use 'none' + ## If you are passing wilcard characters ie /logs/*.log make sure you 'set -f' before the function and 'set +f' afterwards. if [ -n "$1" ] && [ -n "$2" ]; then if [ ! -f /etc/logrotate.d/"$1" ] ; then @@ -144,14 +97,36 @@ $2 { ${lruser} } EOF - chown root:root /etc/logrotate.d/${1} - chmod 0644 /etc/logrotate.d/${1} + chown root:root /etc/logrotate.d/"${1}" + chmod 0644 /etc/logrotate.d/"${1}" else print_debug "Skipping creating automatic logrotation for ${1}" fi fi } +create_zabbix() { + ## Usage (optional custom Autoregister name) + ## e.g. create_zabbix cron + ## If you dont put an autoregister argument it will just use the Configuration Name + + if [ -n "$1" ] ; then + if [ -n "$2" ] ; then + autoregister=$2 + else + autoregister=$1 + fi + print_debug "Adding Zabbix Auto Register configuration for '$1'" + if var_true "${CONTAINER_ENABLE_MONITORING}" && [ "${CONTAINER_MONITORING_BACKEND,,}" = "zabbix" ]; then + source /assets/defaults/03-monitoring + cat < "${ZABBIX_CONFIG_PATH}"/"${ZABBIX_CONFIG_FILE}.d"/tiredofit_$1.conf +# Zabbix $1 Configuration - Automatically Generated +# Autoregister=$autoregister +EOF + fi + fi +} + custom_files() { ## Copy files from one lcoation to somewhere else on the file system ## eg. Copy all files in /assets/custom (Default ENV CONTAINER_CUSTOM_PATH) to /www/html 'custom_files /www/html' @@ -164,8 +139,8 @@ custom_files() { ccustom_files_destination="${1}" fi - if [ -d "${ccustom_files_source}" ] && dir_notempty ; then - print "Custom Files: Copying files from '${ccustom_files_source}' to '${ccustom_files_destination}'" + if [ -d "${ccustom_files_source}" ] && dir_notempty "${ccustom_files_source}" ; then + print_debug "Custom Files: Copying files from '${ccustom_files_source}' to '${ccustom_files_destination}'" if [ -d "${ccustom_files-destination}" ] ; then mkdir -p "${ccustom_files-destination}" fi @@ -332,64 +307,62 @@ dir_notempty() { [ -n "$(ls -A "$1")" ] } -## Docker Secrets Support -## usage: file_env VAR [DEFAULT] -## ie: file_env 'XYZ_DB_PASSWORD' 'example' -## (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { - if [ "$CONTAINER_ENABLE_DOCKER_SECRETS" = "TRUE" ] || [ "$CONTAINER_ENABLE_DOCKER_SECRETS" = "true" ] ; then - local var="$1" - local fileVar="${var}_FILE" - local def="${2:-}" - local val="$def" - if [ "${!fileVar:-}" ]; then + ## Docker Secrets Support + ## usage: file_env VAR [DEFAULT] + ## ie: file_env 'XYZ_DB_PASSWORD' 'example' + ## (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) + if [ "${CONTAINER_ENABLE_DOCKER_SECRETS,,}" = "true" ] ; then + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + local val="$def" + if [ "${!fileVar:-}" ]; then val="$(cat "${!fileVar}")" - elif [ "${!var:-}" ]; then + elif [ "${!var:-}" ]; then val="${!var}" - fi + fi - if [ -z "${val}" ]; then + if [ -z "${val}" ]; then print_error "error: neither $var nor $fileVar are set but are required" exit 1 - fi - export "$var"="$val" - unset "$fileVar" - fi + fi + export "$var"="$val" + unset "$fileVar" + fi } -## Get Defaults -## Usage: get_defaults