Compare commits
5 Commits
358211bcff
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 99a83f318a | |||
| 4e405a7f7a | |||
| 9dab9d465d | |||
| 14d499350e | |||
| 5b0b5ae2d3 |
@@ -28,6 +28,9 @@
|
||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||
# 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
|
||||
# new: forked from the "SMARTERP_skeleton" repository.
|
||||
# mod: "instance" => "service"
|
||||
@@ -95,14 +98,14 @@ if [ -n "$CRON" ]; then
|
||||
# Ubuntu gets the initial environment from a separate file.
|
||||
if [ -r "/etc/environment" ]; then
|
||||
# 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%\"}"; includepath="${includepath#\"}"
|
||||
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
||||
unset includepath
|
||||
fi
|
||||
# We need the $HOME/bin as well.
|
||||
PATH="$HOME/bin:$PATH"
|
||||
# We need the $HOME/bin and /usr/local/bin paths as well.
|
||||
PATH="$HOME/bin:/usr/local/bin:$PATH"
|
||||
fi
|
||||
# We need also the sbin directories.
|
||||
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)
|
||||
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
|
||||
do
|
||||
if [ -n "$(which $item)" ]
|
||||
|
||||
Executable
+74
@@ -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
|
||||
@@ -7,6 +7,8 @@
|
||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||
# 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
|
||||
# new: dnf support has been added for Oracle/RHEL compatibility.
|
||||
# mod: the egrep calls have been replaced by grep -E command
|
||||
@@ -66,8 +68,8 @@ if [ -n "$CRON" ]; then
|
||||
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
||||
unset includepath
|
||||
fi
|
||||
# We need the $HOME/bin as well.
|
||||
PATH="$HOME/bin:$PATH"
|
||||
# We need the $HOME/bin and /usr/local/bin paths as well.
|
||||
PATH="$HOME/bin:/usr/local/bin:$PATH"
|
||||
fi
|
||||
# We need also the sbin directories.
|
||||
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||
# 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
|
||||
# new: forked from the "SMARTERP_skeleton" repository.
|
||||
# mod: "instance" => "service"
|
||||
@@ -45,14 +48,14 @@ if [ -n "$CRON" ]; then
|
||||
# Ubuntu gets the initial environment from a separate file.
|
||||
if [ -r "/etc/environment" ]; then
|
||||
# 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%\"}"; includepath="${includepath#\"}"
|
||||
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
||||
unset includepath
|
||||
fi
|
||||
# We need the $HOME/bin as well.
|
||||
PATH="$HOME/bin:$PATH"
|
||||
# We need the $HOME/bin and /usr/local/bin paths as well.
|
||||
PATH="$HOME/bin:/usr/local/bin:$PATH"
|
||||
fi
|
||||
# We need also the sbin directories.
|
||||
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||
# 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
|
||||
# new: forked from the "SMARTERP_skeleton" repository.
|
||||
# mod: "instance" => "service"
|
||||
@@ -45,14 +48,14 @@ if [ -n "$CRON" ]; then
|
||||
# Ubuntu gets the initial environment from a separate file.
|
||||
if [ -r "/etc/environment" ]; then
|
||||
# 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%\"}"; includepath="${includepath#\"}"
|
||||
[[ -n "$includepath" ]] && PATH="$PATH:$includepath"
|
||||
unset includepath
|
||||
fi
|
||||
# We need the $HOME/bin as well.
|
||||
PATH="$HOME/bin:$PATH"
|
||||
# We need the $HOME/bin and /usr/local/bin paths as well.
|
||||
PATH="$HOME/bin:/usr/local/bin:$PATH"
|
||||
fi
|
||||
# We need also the sbin directories.
|
||||
if ! [[ "$PATH" =~ '/sbin:' ]]; then PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"; fi
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||
# 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
|
||||
# new: forked from the "SMARTERP_skeleton" repository.
|
||||
# 2022-11-03 v0.4
|
||||
@@ -131,7 +133,7 @@ done; shift $((OPTIND -1))
|
||||
# Common dependencies.
|
||||
TR=$(which tr 2>/dev/null)
|
||||
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
|
||||
do
|
||||
if [ -n "$(which $item)" ]
|
||||
@@ -346,8 +348,8 @@ else
|
||||
# 1st the schema with some arbitrary conversions.
|
||||
"$PG_DUMP" $CONNECT \
|
||||
$PGDUMPACLS --schema-only -d "$PGDATABASE" | \
|
||||
"$EGREP" -iv '^SET idle_in_transaction_session_timeout =' | \
|
||||
"$EGREP" -iv '^SET default_table_access_method =' | \
|
||||
"$GREP" -E -iv '^SET idle_in_transaction_session_timeout =' | \
|
||||
"$GREP" -E -iv '^SET default_table_access_method =' | \
|
||||
"$SED" 's/FUNCTION =/PROCEDURE = /' | \
|
||||
"$SED" "s/CURRENT_DATE/\('now'::text\)::date/g"
|
||||
# 2nd the data as COPY statements.
|
||||
@@ -358,8 +360,8 @@ else
|
||||
# 1st the schema with some arbitrary conversions.
|
||||
"$PG_DUMP" $CONNECT \
|
||||
$PGDUMPACLS --schema-only -d "$PGDATABASE" | \
|
||||
"$EGREP" -iv '^SET idle_in_transaction_session_timeout =' | \
|
||||
"$EGREP" -iv '^SET default_table_access_method =' | \
|
||||
"$GREP" -E -iv '^SET idle_in_transaction_session_timeout =' | \
|
||||
"$GREP" -E -iv '^SET default_table_access_method =' | \
|
||||
"$SED" 's/FUNCTION =/PROCEDURE = /' | \
|
||||
"$SED" "s/CURRENT_DATE/\('now'::text\)::date/g" \
|
||||
>"$PGDUMPFILE" 2>>"$logfile"; result=$?
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||
# 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
|
||||
# fix: now correctly handles "zero elements to keep" directives.
|
||||
# 2025-08-12 v1.2
|
||||
@@ -127,7 +129,7 @@ done
|
||||
# Checks the dependencies.
|
||||
TR=$(which tr 2>/dev/null)
|
||||
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
|
||||
if [ -n "$(which $item)" ]
|
||||
then export $(echo $item | "$TR" '[:lower:]' '[:upper:]')=$(which $item)
|
||||
@@ -219,11 +221,11 @@ function rotate_class {
|
||||
if [ -z "$CLASSES_PATTERN" ]; then
|
||||
# All non-hidden files but no subfolders, symlinks, etc.
|
||||
files=$(cd "$BACKUP_FOLDER"; \
|
||||
ls -1 -t --file-type | "$XARGS" -0 | "$EGREP" -v '[/=>@|$]$' )
|
||||
ls -1 -t --file-type | "$XARGS" -0 | "$GREP" -E -v '[/=>@|$]$' )
|
||||
else
|
||||
# Non-hidden files (but no subfolders, symlinks, etc.) matching to the pattern.
|
||||
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
|
||||
# Lack of files gives it up here.
|
||||
[[ -z "$files" ]] && return
|
||||
@@ -401,7 +403,7 @@ function rotate_classes {
|
||||
# Tries to validate the pattern.
|
||||
# Test calls simulate the later use.
|
||||
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
|
||||
fi
|
||||
# Does contain unexplored classifiers?
|
||||
@@ -413,7 +415,7 @@ function rotate_classes {
|
||||
# Needs further exploring.
|
||||
# Non-hidden files (but no subfolders, symlinks, etc.) matching to the pattern.
|
||||
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.
|
||||
local classes=$(echo -e "$files" | "$SED" -E "s/$CLASSES_PATTERN/\1/" | "$SORT" -u)
|
||||
# Enumerates these qualifiers.
|
||||
@@ -434,7 +436,7 @@ if [ -z "$CLASSES_PATTERN" ]; then
|
||||
rotate_class
|
||||
else
|
||||
# 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
|
||||
# Seems to be valid, go on!
|
||||
rotate_classes "$CLASSES_PATTERN"
|
||||
|
||||
@@ -58,6 +58,7 @@ $DOCKER create \
|
||||
--add-host="host.docker.internal:host-gateway" \
|
||||
--restart unless-stopped \
|
||||
--label "com.centurylinklabs.watchtower.enable=true" \
|
||||
--label "containermon.enable=true" \
|
||||
--name $instance $image
|
||||
|
||||
# Connects it to the network(s).
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# Wrapper scripts to various mail transfer 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.
|
||||
# Wrapper scripts to various mail agents
|
||||
|
||||
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.
|
||||
|
||||
Executable
+52
@@ -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! :)
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Dummy file to met the dependencies. Does nothing.
|
||||
Regular → Executable
+3
-3
@@ -20,7 +20,7 @@ SMTP_PASS="topsecret"
|
||||
|
||||
# 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.
|
||||
recipient="${@: -1}"
|
||||
set -- "${@: 1: $#-1}"
|
||||
@@ -29,8 +29,8 @@ if [ -x "$(which s-nail 2>/dev/null)" ]; then
|
||||
[[ "$recipient" = "$USER" ]] && recipient="$TO"
|
||||
[[ "$recipient" = "$USER@$HOSTNAME" ]] && recipient="$TO"
|
||||
if [ -n "$recipient" ]; then
|
||||
"$(which s-nail)" -S from="$FROM" -S v15-compat \
|
||||
-S smtp-auth="login" -S smtp-use-starttls \
|
||||
"/bin/s-nail" -S from="$FROM" -S v15-compat \
|
||||
-S smtp-auth="login" $([[ "$SMTP_PROTO" = "submission" ]] && echo "-S smtp-use-starttls") \
|
||||
-S mta="$SMTP_PROTO://$SMTP_USER:$SMTP_PASS@$SMTP_SERVER" \
|
||||
-S record="/var/mail/$USER" \
|
||||
"${@}" $recipient
|
||||
@@ -5,6 +5,8 @@
|
||||
#
|
||||
# Author: Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||
# 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
|
||||
# fix: tar now dereferences the symlinks (if any).
|
||||
# 2021-09-03 v0.1 Initial release
|
||||
@@ -26,7 +28,7 @@ MSG_NONWRITE="The target directory isn't writable"
|
||||
# Checks the dependencies.
|
||||
TR=$(which tr 2>/dev/null)
|
||||
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
|
||||
if [ -n "$(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")"
|
||||
( cd "$BASE_DIR"
|
||||
"$TAR" czhf "$BACKUPDIR/$BACKUP_NAME.tgz" \
|
||||
"$YMLFILE" configs docker \
|
||||
$("$FIND" -maxdepth 1 -type f) configs docker \
|
||||
2>>"$BACKUPDIR/$BACKUP_NAME.log"
|
||||
)
|
||||
fi
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
# See https://github.com/Matty9191/ssl-cert-check for details.
|
||||
#
|
||||
# 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
|
||||
|
||||
# Accepted environment variables and their defaults.
|
||||
@@ -27,12 +30,13 @@ MSG_MISSINGYML="Fatal: didn't find the docker-compose.yml file"
|
||||
LANG=C
|
||||
LC_ALL=C
|
||||
|
||||
# Checks the dependencies.
|
||||
# Checks the dependencies (including the worker script's).
|
||||
TR=$(which tr 2>/dev/null)
|
||||
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
|
||||
if [ -n "$(which $item)" ]
|
||||
if [ -n "$(which $item 2>/dev/null)" ]
|
||||
then export $(echo $item | "$TR" '[:lower:]' '[:upper:]' | "$TR" '-' '_')=$(which $item)
|
||||
else echo "$MSG_MISSINGDEP $item." >&2; exit 1; fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user