Compare commits

..

5 Commits

Author SHA1 Message Date
Kovács Zoltán 99a83f318a feat: Implemented a notification service for unhealthy containers. 2026-05-22 10:45:21 +02:00
Kovács Zoltán 4e405a7f7a Improvements in .templates/bin scripts:
* obsolescent egrep calls have removed;
* /usr/local/bin has been added to PATH for cron calls.
2026-05-04 15:18:28 +02:00
Kovács Zoltán 9dab9d465d Minor improvements in check_certificates wrapper script. 2026-05-04 15:06:25 +02:00
Kovács Zoltán 14d499350e Improvements (cronmail) and fixes in mail utilities. 2026-05-02 23:46:29 +02:00
Kovács Zoltán 5b0b5ae2d3 configs_backup.sh now saves all root files (not only the docker-compose.yml). 2026-05-02 23:12:36 +02:00
15 changed files with 189 additions and 41 deletions
BIN
View File
Binary file not shown.
+6 -4
View File
@@ -28,6 +28,9 @@
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu> # Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
# Kovács Zoltán <kovacsz@marcusconsulting.hu> # Kovács Zoltán <kovacsz@marcusconsulting.hu>
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html) # License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
# 2026-05-04 v1.1
# mod: the obsolescent egrep calls have been changed to POSIX grep -E calls.
# fix: /usr/local/bin was missing from the PATH for cron calls.
# 2023-06-18 v1.0 # 2023-06-18 v1.0
# new: forked from the "SMARTERP_skeleton" repository. # new: forked from the "SMARTERP_skeleton" repository.
# mod: "instance" => "service" # mod: "instance" => "service"
@@ -95,14 +98,14 @@ if [ -n "$CRON" ]; then
# Ubuntu gets the initial environment from a separate file. # Ubuntu gets the initial environment from a separate file.
if [ -r "/etc/environment" ]; then if [ -r "/etc/environment" ]; then
# Extracts from this file, strips the right part w/o quotes. # Extracts from this file, strips the right part w/o quotes.
includepath=$(cat "/etc/environment" | $(which egrep) '^PATH=') includepath=$(cat "/etc/environment" | $(which grep) -E '^PATH=')
includepath=${includepath:5} includepath=${includepath:5}
includepath="${includepath%\"}"; includepath="${includepath#\"}" includepath="${includepath%\"}"; includepath="${includepath#\"}"
[[ -n "$includepath" ]] && PATH="$PATH:$includepath" [[ -n "$includepath" ]] && PATH="$PATH:$includepath"
unset includepath unset includepath
fi fi
# We need the $HOME/bin as well. # We need the $HOME/bin and /usr/local/bin paths as well.
PATH="$HOME/bin:$PATH" PATH="$HOME/bin:/usr/local/bin:$PATH"
fi fi
# We need also the sbin directories. # We need also the sbin directories.
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
@@ -111,7 +114,6 @@ if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin
# #
TR=$(which tr 2>/dev/null) TR=$(which tr 2>/dev/null)
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
#for item in basename df egrep head mail printf sleep
for item in basename printf sleep for item in basename printf sleep
do do
if [ -n "$(which $item)" ] if [ -n "$(which $item)" ]
+74
View File
@@ -0,0 +1,74 @@
#!/bin/bash
#
# https://github.com/containrrr/shoutrrr/tree/main
# https://github.com/RafhaanShah/Container-Mon
#
# Email notification settings below assume the gateway acting
# as a smarthost and Docker version v20.10+ is required.
image="ghcr.io/rafhaanshah/container-mon"
instance="containermon"
networks=""
outfile=""
volume=""
MSG_MISSINGDEP="Fatal: missing dependency"
# Checks the dependencies.
TR=$(which tr 2>/dev/null)
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
for item in cat dirname docker hostname
do
if [ -n "$(which $item)" ]
then export $(echo $item | "$TR" '[:lower:]' '[:upper:]')=$(which $item)
else echo "$MSG_MISSINGDEP $item." >&2; exit 1; fi
done
# Stops and removes the container (if necessary).
if [ -n "$("$DOCKER" ps -q -f name=$instance)" ]
then "$DOCKER" stop "$instance"; fi
if [ -n "$("$DOCKER" ps -a -q -f name=$instance)" ]
then "$DOCKER" rm "$instance"; fi
# Checks for an upgrade.
$DOCKER pull "$image"
# Creates the container.
$DOCKER create \
-e TZ="Europe/Budapest" \
-e CONTAINERMON_CHECK_EXIT_CODE=false \
-e CONTAINERMON_CHECK_STOPPED=false \
-e CONTAINERMON_CRON="*/2 * * * *" \
-e CONTAINERMON_FAIL_LIMIT=1 \
-e CONTAINERMON_NOTIFICATION_URL="smtp://host.docker.internal:25/?from=$USER@$("$HOSTNAME" -f)&to=$USER@$("$HOSTNAME")&subject=[[Containermon $(hostname)]]" \
-e CONTAINERMON_HEALTHY_NOTIFICATION_URL="smtp://host.docker.internal:25/?from=$USER@$("$HOSTNAME" -f)&to=$USER@$("$HOSTNAME")&subject=[[Containermon $(hostname)]]" \
-e CONTAINERMON_NOTIFY_HEALTHY=true \
-e CONTAINERMON_MESSAGE_PREFIX="" \
-e CONTAINERMON_USE_LABELS=true \
-v /var/run/docker.sock:/var/run/docker.sock \
--add-host="host.docker.internal:host-gateway" \
--restart unless-stopped \
--label "com.centurylinklabs.watchtower.enable=true" \
--name $instance $image
# Connects it to the network(s).
if [ -n "$networks" ]; then
for network in $networks
do
# Checks the network, creates it if necessary.
if [ -z "$("$DOCKER" network ls -q -f name=$network)" ]
then "$DOCKER" network create -d bridge "$network"; fi
# Then connects.
$DOCKER network connect $network $instance
done
fi
# Finally launches it.
$DOCKER start $instance
# Adds the time zone handler package to the running container.
$DOCKER exec $instance sh -c "apk add tzdata"
if [ -n "$outfile" -a -w "$("$DIRNAME" "$outfile")" ]; then
# Sets a background process to collect the image's output.
# This process will automatically terminate when the image stops.
"$DOCKER" logs -f $instance >>"$outfile" 2>&1 &
fi
+4 -2
View File
@@ -7,6 +7,8 @@
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu> # Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
# Kovács Zoltán <kovacsz@marcusconsulting.hu> # Kovács Zoltán <kovacsz@marcusconsulting.hu>
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html) # License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
# 2026-05-04 v1.2
# fix: /usr/local/bin was missing from the PATH for cron calls.
# 2026-05-01 v1.1 # 2026-05-01 v1.1
# new: dnf support has been added for Oracle/RHEL compatibility. # new: dnf support has been added for Oracle/RHEL compatibility.
# mod: the egrep calls have been replaced by grep -E command # mod: the egrep calls have been replaced by grep -E command
@@ -66,8 +68,8 @@ if [ -n "$CRON" ]; then
[[ -n "$includepath" ]] && PATH="$PATH:$includepath" [[ -n "$includepath" ]] && PATH="$PATH:$includepath"
unset includepath unset includepath
fi fi
# We need the $HOME/bin as well. # We need the $HOME/bin and /usr/local/bin paths as well.
PATH="$HOME/bin:$PATH" PATH="$HOME/bin:/usr/local/bin:$PATH"
fi fi
# We need also the sbin directories. # We need also the sbin directories.
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
+6 -3
View File
@@ -7,6 +7,9 @@
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu> # Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
# Kovács Zoltán <kovacsz@marcusconsulting.hu> # Kovács Zoltán <kovacsz@marcusconsulting.hu>
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html) # License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
# 2026-05-04 v1.1
# mod: the obsolescent egrep calls have been changed to POSIX grep -E calls.
# fix: /usr/local/bin was missing from the PATH for cron calls.
# 2023-06-18 v1.0 # 2023-06-18 v1.0
# new: forked from the "SMARTERP_skeleton" repository. # new: forked from the "SMARTERP_skeleton" repository.
# mod: "instance" => "service" # mod: "instance" => "service"
@@ -45,14 +48,14 @@ if [ -n "$CRON" ]; then
# Ubuntu gets the initial environment from a separate file. # Ubuntu gets the initial environment from a separate file.
if [ -r "/etc/environment" ]; then if [ -r "/etc/environment" ]; then
# Extracts from this file, strips the right part w/o quotes. # Extracts from this file, strips the right part w/o quotes.
includepath=$(cat "/etc/environment" | $(which egrep) '^PATH=') includepath=$(cat "/etc/environment" | $(which grep) -E '^PATH=')
includepath=${includepath:5} includepath=${includepath:5}
includepath="${includepath%\"}"; includepath="${includepath#\"}" includepath="${includepath%\"}"; includepath="${includepath#\"}"
[[ -n "$includepath" ]] && PATH="$PATH:$includepath" [[ -n "$includepath" ]] && PATH="$PATH:$includepath"
unset includepath unset includepath
fi fi
# We need the $HOME/bin as well. # We need the $HOME/bin and /usr/local/bin paths as well.
PATH="$HOME/bin:$PATH" PATH="$HOME/bin:/usr/local/bin:$PATH"
fi fi
# We need also the sbin directories. # We need also the sbin directories.
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
+6 -3
View File
@@ -7,6 +7,9 @@
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu> # Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
# Kovács Zoltán <kovacsz@marcusconsulting.hu> # Kovács Zoltán <kovacsz@marcusconsulting.hu>
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html) # License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
# 2026-05-04 v1.1
# mod: the obsolescent egrep calls have been changed to POSIX grep -E calls.
# fix: /usr/local/bin was missing from the PATH for cron calls.
# 2023-06-18 v1.0 # 2023-06-18 v1.0
# new: forked from the "SMARTERP_skeleton" repository. # new: forked from the "SMARTERP_skeleton" repository.
# mod: "instance" => "service" # mod: "instance" => "service"
@@ -45,14 +48,14 @@ if [ -n "$CRON" ]; then
# Ubuntu gets the initial environment from a separate file. # Ubuntu gets the initial environment from a separate file.
if [ -r "/etc/environment" ]; then if [ -r "/etc/environment" ]; then
# Extracts from this file, strips the right part w/o quotes. # Extracts from this file, strips the right part w/o quotes.
includepath=$(cat "/etc/environment" | $(which egrep) '^PATH=') includepath=$(cat "/etc/environment" | $(which grep) -E '^PATH=')
includepath=${includepath:5} includepath=${includepath:5}
includepath="${includepath%\"}"; includepath="${includepath#\"}" includepath="${includepath%\"}"; includepath="${includepath#\"}"
[[ -n "$includepath" ]] && PATH="$PATH:$includepath" [[ -n "$includepath" ]] && PATH="$PATH:$includepath"
unset includepath unset includepath
fi fi
# We need the $HOME/bin as well. # We need the $HOME/bin and /usr/local/bin paths as well.
PATH="$HOME/bin:$PATH" PATH="$HOME/bin:/usr/local/bin:$PATH"
fi fi
# We need also the sbin directories. # We need also the sbin directories.
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
+7 -5
View File
@@ -20,6 +20,8 @@
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu> # Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
# Kovács Zoltán <kovacsz@marcusconsulting.hu> # Kovács Zoltán <kovacsz@marcusconsulting.hu>
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html) # License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
# 2026-05-04 v1.1
# mod: the obsolescent egrep calls have been changed to POSIX grep -E calls.
# 2023-06-18 v1.0 # 2023-06-18 v1.0
# new: forked from the "SMARTERP_skeleton" repository. # new: forked from the "SMARTERP_skeleton" repository.
# 2022-11-03 v0.4 # 2022-11-03 v0.4
@@ -131,7 +133,7 @@ done; shift $((OPTIND -1))
# Common dependencies. # Common dependencies.
TR=$(which tr 2>/dev/null) TR=$(which tr 2>/dev/null)
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
for item in basename df date dirname egrep grep gzip hostname id \ for item in basename df date dirname grep gzip hostname id \
pwd sed tail tee $additem pwd sed tail tee $additem
do do
if [ -n "$(which $item)" ] if [ -n "$(which $item)" ]
@@ -346,8 +348,8 @@ else
# 1st the schema with some arbitrary conversions. # 1st the schema with some arbitrary conversions.
"$PG_DUMP" $CONNECT \ "$PG_DUMP" $CONNECT \
$PGDUMPACLS --schema-only -d "$PGDATABASE" | \ $PGDUMPACLS --schema-only -d "$PGDATABASE" | \
"$EGREP" -iv '^SET idle_in_transaction_session_timeout =' | \ "$GREP" -E -iv '^SET idle_in_transaction_session_timeout =' | \
"$EGREP" -iv '^SET default_table_access_method =' | \ "$GREP" -E -iv '^SET default_table_access_method =' | \
"$SED" 's/FUNCTION =/PROCEDURE = /' | \ "$SED" 's/FUNCTION =/PROCEDURE = /' | \
"$SED" "s/CURRENT_DATE/\('now'::text\)::date/g" "$SED" "s/CURRENT_DATE/\('now'::text\)::date/g"
# 2nd the data as COPY statements. # 2nd the data as COPY statements.
@@ -358,8 +360,8 @@ else
# 1st the schema with some arbitrary conversions. # 1st the schema with some arbitrary conversions.
"$PG_DUMP" $CONNECT \ "$PG_DUMP" $CONNECT \
$PGDUMPACLS --schema-only -d "$PGDATABASE" | \ $PGDUMPACLS --schema-only -d "$PGDATABASE" | \
"$EGREP" -iv '^SET idle_in_transaction_session_timeout =' | \ "$GREP" -E -iv '^SET idle_in_transaction_session_timeout =' | \
"$EGREP" -iv '^SET default_table_access_method =' | \ "$GREP" -E -iv '^SET default_table_access_method =' | \
"$SED" 's/FUNCTION =/PROCEDURE = /' | \ "$SED" 's/FUNCTION =/PROCEDURE = /' | \
"$SED" "s/CURRENT_DATE/\('now'::text\)::date/g" \ "$SED" "s/CURRENT_DATE/\('now'::text\)::date/g" \
>"$PGDUMPFILE" 2>>"$logfile"; result=$? >"$PGDUMPFILE" 2>>"$logfile"; result=$?
+8 -6
View File
@@ -55,6 +55,8 @@
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu> # Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
# Kovács Zoltán <kovacsz@marcusconsulting.hu> # Kovács Zoltán <kovacsz@marcusconsulting.hu>
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html) # License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
# 2026-05-04 v1.4
# mod: the obsolescent egrep calls have been changed to POSIX grep -E calls.
# 2025-09-15 v1.3 # 2025-09-15 v1.3
# fix: now correctly handles "zero elements to keep" directives. # fix: now correctly handles "zero elements to keep" directives.
# 2025-08-12 v1.2 # 2025-08-12 v1.2
@@ -127,7 +129,7 @@ done
# Checks the dependencies. # Checks the dependencies.
TR=$(which tr 2>/dev/null) TR=$(which tr 2>/dev/null)
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
for item in basename date dirname egrep sed seq sort stat xargs for item in basename date dirname grep sed seq sort stat xargs
do do
if [ -n "$(which $item)" ] if [ -n "$(which $item)" ]
then export $(echo $item | "$TR" '[:lower:]' '[:upper:]')=$(which $item) then export $(echo $item | "$TR" '[:lower:]' '[:upper:]')=$(which $item)
@@ -219,11 +221,11 @@ function rotate_class {
if [ -z "$CLASSES_PATTERN" ]; then if [ -z "$CLASSES_PATTERN" ]; then
# All non-hidden files but no subfolders, symlinks, etc. # All non-hidden files but no subfolders, symlinks, etc.
files=$(cd "$BACKUP_FOLDER"; \ files=$(cd "$BACKUP_FOLDER"; \
ls -1 -t --file-type | "$XARGS" -0 | "$EGREP" -v '[/=>@|$]$' ) ls -1 -t --file-type | "$XARGS" -0 | "$GREP" -E -v '[/=>@|$]$' )
else else
# Non-hidden files (but no subfolders, symlinks, etc.) matching to the pattern. # Non-hidden files (but no subfolders, symlinks, etc.) matching to the pattern.
files=$(cd "$BACKUP_FOLDER"; \ files=$(cd "$BACKUP_FOLDER"; \
ls -1 -t --file-type | "$XARGS" -0 | "$EGREP" "$CLASSES_PATTERN" ) ls -1 -t --file-type | "$XARGS" -0 | "$GREP" -E "$CLASSES_PATTERN" )
fi fi
# Lack of files gives it up here. # Lack of files gives it up here.
[[ -z "$files" ]] && return [[ -z "$files" ]] && return
@@ -401,7 +403,7 @@ function rotate_classes {
# Tries to validate the pattern. # Tries to validate the pattern.
# Test calls simulate the later use. # Test calls simulate the later use.
if [ -n "$CLASSES_PATTERN" ]; then if [ -n "$CLASSES_PATTERN" ]; then
echo "test" | "$EGREP" "$CLASSES_PATTERN" >/dev/null 2>&1 echo "test" | "$GREP" -E "$CLASSES_PATTERN" >/dev/null 2>&1
[[ $? -gt 1 ]] && return # unusable [[ $? -gt 1 ]] && return # unusable
fi fi
# Does contain unexplored classifiers? # Does contain unexplored classifiers?
@@ -413,7 +415,7 @@ function rotate_classes {
# Needs further exploring. # Needs further exploring.
# Non-hidden files (but no subfolders, symlinks, etc.) matching to the pattern. # Non-hidden files (but no subfolders, symlinks, etc.) matching to the pattern.
local files=$(cd "$BACKUP_FOLDER"; \ local files=$(cd "$BACKUP_FOLDER"; \
ls -1 -t --file-type | "$XARGS" -0 | "$EGREP" "$CLASSES_PATTERN" ) ls -1 -t --file-type | "$XARGS" -0 | "$GREP" -E "$CLASSES_PATTERN" )
# Selects the qualifier substrings which actually have matching files. # Selects the qualifier substrings which actually have matching files.
local classes=$(echo -e "$files" | "$SED" -E "s/$CLASSES_PATTERN/\1/" | "$SORT" -u) local classes=$(echo -e "$files" | "$SED" -E "s/$CLASSES_PATTERN/\1/" | "$SORT" -u)
# Enumerates these qualifiers. # Enumerates these qualifiers.
@@ -434,7 +436,7 @@ if [ -z "$CLASSES_PATTERN" ]; then
rotate_class rotate_class
else else
# Tries to validate the pattern (loosely). # Tries to validate the pattern (loosely).
echo "test" | "$EGREP" "$CLASSES_PATTERN" >/dev/null 2>&1 echo "test" | "$GREP" -E "$CLASSES_PATTERN" >/dev/null 2>&1
[[ $? -gt 1 ]] && echo -e "$MSG_BADPATTERN $CLASSES_PATTERN" >&2 && exit 1 [[ $? -gt 1 ]] && echo -e "$MSG_BADPATTERN $CLASSES_PATTERN" >&2 && exit 1
# Seems to be valid, go on! # Seems to be valid, go on!
rotate_classes "$CLASSES_PATTERN" rotate_classes "$CLASSES_PATTERN"
+1
View File
@@ -58,6 +58,7 @@ $DOCKER create \
--add-host="host.docker.internal:host-gateway" \ --add-host="host.docker.internal:host-gateway" \
--restart unless-stopped \ --restart unless-stopped \
--label "com.centurylinklabs.watchtower.enable=true" \ --label "com.centurylinklabs.watchtower.enable=true" \
--label "containermon.enable=true" \
--name $instance $image --name $instance $image
# Connects it to the network(s). # Connects it to the network(s).
+7 -3
View File
@@ -1,3 +1,7 @@
# Wrapper scripts to various mail transfer agents. # Wrapper scripts to various mail agents
Only needed if your system does not provide the POSIX mailx compatible mail command. If sending email is prohibited from your environment use *mail.dummy* to avoid warnings from cron, etc.
To activate, choose a suitable one then place it somewhere in the path (~/bin or /usr/local/bin are recommended), name it mail and give it execute permission. Only needed if your system does not provide a local MTA (e.g *sendmail*) and/or a POSIX *mailx* compatible mail command.
To activate, choose a suitable one then place it somewhere in the path (*/usr/local/bin* is recommended), name or symlink it to *mail* and give it execute permission to anyone.
To use them with *crond*, you may need the *cronmail* converter script, which can accept sendmail-formatted mail and convert it into a suitable *mailx* call. You can usually set this script as a mail sender for *crond* using the *CRONDARGS* environment variable.
+52
View File
@@ -0,0 +1,52 @@
#!/bin/bash
#
# This is a sendmail to mailx format converter script.
# It receives a well-formed email text from standard input, parses it,
# and invokes a POSIX mailx compliant mail user agent with the result.
#
# It is primarily designed to use with crond. To activate
# use CRONDARGS="-m pathname_to_cronmail" in/etc/default/cron or
# /etc/sysconfig/crond configuration.
#
# Author: Kovács Zoltán <kovacsz@marcusconsulting.hu>
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
# 2026-05-02 v0.1 Initila release.
# Initialisations.
#
SUBJECT=""
RECIPIENT="$USER" # Default recipient.
MESSAGE=""
MUA="/usr/local/bin/mail" # Custom mail user agent script.
# Parsing the stdin line by line.
#
while IFS= read -r line
do
# Parses the recipient.
if [[ "$line" =~ ^(T|t)o:\ .*$ ]]; then
RECIPIENT="${line#*: }"
# Parses the subject line.
elif [[ "$line" =~ ^(S|s)ubject:\ .*$ ]]; then
SUBJECT="${line#*: }"
# Message body starts with an empty line.
elif [[ "$line" =~ ^$ ]]; then
MESSAGE+="\n"
# Collects the message body lines.
# The first empty line will be stripped.
elif [ -n "$MESSAGE" ]; then
[[ "$MESSAGE" = "\n" ]] \
&& MESSAGE="$line\n" \
|| MESSAGE+="$line\n"
fi
done
# Calls the mail user agent.
#
if [ -x "$MUA" ]; then
if [ -n "$SUBJECT" -o -n "$MESSAGE" ]; then
echo -e "$MESSAGE" | "$MUA" -s "$SUBJECT" "$RECIPIENT"
fi
fi
# That's all, Folks! :)
-3
View File
@@ -1,3 +0,0 @@
#!/bin/bash
#
# Dummy file to met the dependencies. Does nothing.
+3 -3
View File
@@ -20,7 +20,7 @@ SMTP_PASS="topsecret"
# s-nail call. # s-nail call.
# #
if [ -x "$(which s-nail 2>/dev/null)" ]; then if [ -x "/bin/s-nail" ]; then
# The recipient's address is the last argument. # The recipient's address is the last argument.
recipient="${@: -1}" recipient="${@: -1}"
set -- "${@: 1: $#-1}" set -- "${@: 1: $#-1}"
@@ -29,8 +29,8 @@ if [ -x "$(which s-nail 2>/dev/null)" ]; then
[[ "$recipient" = "$USER" ]] && recipient="$TO" [[ "$recipient" = "$USER" ]] && recipient="$TO"
[[ "$recipient" = "$USER@$HOSTNAME" ]] && recipient="$TO" [[ "$recipient" = "$USER@$HOSTNAME" ]] && recipient="$TO"
if [ -n "$recipient" ]; then if [ -n "$recipient" ]; then
"$(which s-nail)" -S from="$FROM" -S v15-compat \ "/bin/s-nail" -S from="$FROM" -S v15-compat \
-S smtp-auth="login" -S smtp-use-starttls \ -S smtp-auth="login" $([[ "$SMTP_PROTO" = "submission" ]] && echo "-S smtp-use-starttls") \
-S mta="$SMTP_PROTO://$SMTP_USER:$SMTP_PASS@$SMTP_SERVER" \ -S mta="$SMTP_PROTO://$SMTP_USER:$SMTP_PASS@$SMTP_SERVER" \
-S record="/var/mail/$USER" \ -S record="/var/mail/$USER" \
"${@}" $recipient "${@}" $recipient
+4 -2
View File
@@ -5,6 +5,8 @@
# #
# Author: Kovács Zoltán <kovacsz@marcusconsulting.hu> # Author: Kovács Zoltán <kovacsz@marcusconsulting.hu>
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html) # License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
# 2026-04-28 v0.3
# mod: now includes all files (not only YMLFILE) in the base folder.
# 2024-03-07 v0.2 # 2024-03-07 v0.2
# fix: tar now dereferences the symlinks (if any). # fix: tar now dereferences the symlinks (if any).
# 2021-09-03 v0.1 Initial release # 2021-09-03 v0.1 Initial release
@@ -26,7 +28,7 @@ MSG_NONWRITE="The target directory isn't writable"
# Checks the dependencies. # Checks the dependencies.
TR=$(which tr 2>/dev/null) TR=$(which tr 2>/dev/null)
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
for item in date dirname hostname readlink tar for item in date dirname find hostname readlink tar
do do
if [ -n "$(which $item)" ] if [ -n "$(which $item)" ]
then export $(echo $item | "$TR" '[:lower:]' '[:upper:]' | "$TR" '-' '_')=$(which $item) then export $(echo $item | "$TR" '[:lower:]' '[:upper:]' | "$TR" '-' '_')=$(which $item)
@@ -72,7 +74,7 @@ if [ -w "$BACKUPDIR" ]; then
BACKUP_NAME="configs.$("$DATE" '+%Y%m%d_%H%M%S').$("$HOSTNAME")" BACKUP_NAME="configs.$("$DATE" '+%Y%m%d_%H%M%S').$("$HOSTNAME")"
( cd "$BASE_DIR" ( cd "$BASE_DIR"
"$TAR" czhf "$BACKUPDIR/$BACKUP_NAME.tgz" \ "$TAR" czhf "$BACKUPDIR/$BACKUP_NAME.tgz" \
"$YMLFILE" configs docker \ $("$FIND" -maxdepth 1 -type f) configs docker \
2>>"$BACKUPDIR/$BACKUP_NAME.log" 2>>"$BACKUPDIR/$BACKUP_NAME.log"
) )
fi fi
+7 -3
View File
@@ -6,6 +6,9 @@
# See https://github.com/Matty9191/ssl-cert-check for details. # See https://github.com/Matty9191/ssl-cert-check for details.
# #
# Author: Kovács Zoltán <kovacsz@marcusconsulting.hu> # Author: Kovács Zoltán <kovacsz@marcusconsulting.hu>
# 2026-05-04 v0.2
# mod: It now also checks the dependencies of the worker script.
# fix: Suppresses error output during 'which' calls.
# 2026-02-16 v0.1 Initial release # 2026-02-16 v0.1 Initial release
# Accepted environment variables and their defaults. # Accepted environment variables and their defaults.
@@ -27,12 +30,13 @@ MSG_MISSINGYML="Fatal: didn't find the docker-compose.yml file"
LANG=C LANG=C
LC_ALL=C LC_ALL=C
# Checks the dependencies. # Checks the dependencies (including the worker script's).
TR=$(which tr 2>/dev/null) TR=$(which tr 2>/dev/null)
if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi
for item in basename dirname find readlink for item in basename dirname find readlink \
awk date grep mktemp openssl printf
do do
if [ -n "$(which $item)" ] if [ -n "$(which $item 2>/dev/null)" ]
then export $(echo $item | "$TR" '[:lower:]' '[:upper:]' | "$TR" '-' '_')=$(which $item) then export $(echo $item | "$TR" '[:lower:]' '[:upper:]' | "$TR" '-' '_')=$(which $item)
else echo "$MSG_MISSINGDEP $item." >&2; exit 1; fi else echo "$MSG_MISSINGDEP $item." >&2; exit 1; fi
done done