Polish and align all scripts; add generic notifier script

This commit is contained in:
Alexander Schäferdiek 2023-01-25 23:27:38 +01:00
parent fbe2eea125
commit e47a2b0145
31 changed files with 474 additions and 185 deletions

View file

@ -3,8 +3,15 @@
system-helpers - Collection of helper systemd services, systemd timers and system-helpers - Collection of helper systemd services, systemd timers and
shell scripts for common configuration. shell scripts for common configuration.
It can help you out for small servers where you think a proper monitoring and
alerting system like [Prometheus](https://prometheus.io) and
[AlertManager](https://prometheus.io/docs/alerting/latest/alertmanager/) is too much.
The **notifier** script can send notifications via mail or [gotify](https://gotify.net).
**system-helpers** collection provides the following helpers **system-helpers** collection provides the following helpers
- notifier which sends notifications via mail or gotify (see **see notifier**)
- checking if systemd services and timers are running (see **man systemd_check**) - checking if systemd services and timers are running (see **man systemd_check**)
- borgmatic backup (see exposed systemd services *borgmatic@* which require a valid *borgmatic.yml* file in */etc/borgmatic* or your **$HOME/.config/borgmatic**) - borgmatic backup (see exposed systemd services *borgmatic@* which require a valid *borgmatic.yml* file in */etc/borgmatic* or your **$HOME/.config/borgmatic**)
- restic backup (see */usr/share/doc/system-helpers/restic* for an example *mybackup*) - restic backup (see */usr/share/doc/system-helpers/restic* for an example *mybackup*)

View file

@ -7,13 +7,13 @@ check_updates - Notifies about available updates. Configuration is done in envir
It's part of **system-helpers**. It's part of **system-helpers**.
# SYNOPSIS # SYNOPSIS
**check_updates** [CONFIG_FILE (absolute path)] **check_updates**
# DESCRIPTION # DESCRIPTION
**check_updates** checks for available updates using *checkupdates* and sends out a mail. It comes with systemd services. **check_updates** checks for available updates using *checkupdates* and sends out a mail. It comes with systemd services.
If no *CONFIG_FILE* is provided, **check_updates** tries to read from *$HOME/.check_updates.conf* and */etc/check_updates.conf* for configuration. It will exit with a non-zero exit code if it cannot find an proper configuration file. By default, **check_updates** tries to read from *$HOME/.check_updates.conf* and */etc/check_updates.conf* for configuration. It will exit with a non-zero exit code if it cannot find a proper configuration file.
The following are at least required for the script to work:\ The following are at least required for the script to work:\
- **CHECK_UPDATES_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available. - **CHECK_UPDATES_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available.

View file

@ -7,13 +7,13 @@ disk_space_alert - Checks available disk space and sends out notification via ma
It's part of **system-helpers**. It's part of **system-helpers**.
# SYNOPSIS # SYNOPSIS
**disk_space_alert** [CONFIG_FILE (absolute path)] **disk_space_alert**
# DESCRIPTION # DESCRIPTION
**disk_space_alert** checks available diskspace for configured **mounts** and sends out a mail if certain limits are reached. It comes with systemd services. **disk_space_alert** checks available diskspace for configured **mounts** and sends out a mail if certain limits are reached. It comes with systemd services.
If no *CONFIG_FILE* is provided, **disk_space_alert** tries to read from *$HOME/.disk_space_alert.conf* and */etc/disk_space_alert.conf* for configuration. It will exit with a non-zero exit code if it cannot find an proper configuration file. By default, **disk_space_alert** tries to read from *$HOME/.disk_space_alert.conf* and */etc/disk_space_alert.conf* for configuration. It will exit with a non-zero exit code if it cannot find a proper configuration file.
The following are at least required for the script to work:\ The following are at least required for the script to work:\
- **DISK_SPACE_ALERT_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available.\ - **DISK_SPACE_ALERT_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available.\

View file

@ -7,13 +7,13 @@ docker_check - Checks a set of docker containers and notifies if their state is
It's part of **system-helpers**. It's part of **system-helpers**.
# SYNOPSIS # SYNOPSIS
**docker_check** [CONFIG_FILE (absolute path)] **docker_check**
# DESCRIPTION # DESCRIPTION
**docker_check** checks a list of docker containers and notifies if their state is not up and running. It comes with systemd services. **docker_check** checks a list of docker containers and notifies if their state is not up and running. It comes with systemd services.
If no *CONFIG_FILE* is provided, **docker_check** tries to read from *$HOME/.docker_check.conf* and */etc/docker_check.conf* for configuration. It will exit with a non-zero exit code if it cannot find an proper configuration file. By default, **docker_check** tries to read from *$HOME/.docker_check.conf* and */etc/docker_check.conf* for configuration. It will exit with a non-zero exit code if it cannot find a proper configuration file.
The following are at least required for the script to work:\ The following are at least required for the script to work:\
- **DOCKER_CHECK_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available.\ - **DOCKER_CHECK_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available.\

View file

@ -3,17 +3,17 @@
% January 2023 % January 2023
# NAME # NAME
docker_compose_update - An utility to batch update *docker-compose* deployments residing in sub folders. Configuration is done in environment files.\ docker_compose_update - Utility to batch update *docker-compose* deployments residing in sub folders of a base directory. Configuration is done in environment files.\
It's part of **system-helpers**. It's part of **system-helpers**.
# SYNOPSIS # SYNOPSIS
**docker_compose_update** [CONFIG_FILE (absolute path)] **docker_compose_update**
# DESCRIPTION # DESCRIPTION
**docker_compose_update** is an utility to batch update *docker-compose* deployments residing in sub folders of a **base directory**, e.g */root/deployments/* having different sub folders, each having a *docker-compose* deployment in it. **docker_compose_update** is an utility to batch update *docker-compose* deployments residing in sub folders of a **base directory**, e.g */root/deployments/* having different sub folders, each having a *docker-compose* deployment in it.
If no *CONFIG_FILE* is provided, **docker_compose_update** tries to read from *$HOME/.docker_compose_update.conf* and */etc/docker_compose_update.conf* for configuration. It will exit with a non-zero exit code if it cannot find an proper configuration file. By default, **docker_compose_update** tries to read from *$HOME/.docker_compose_update.conf* and */etc/docker_compose_update.conf* for configuration. It will exit with a non-zero exit code if it cannot find a proper configuration file.
The following are at least required for the script to work:\ The following are at least required for the script to work:\
- **DOCKER_COMPOSE_UPDATE_BASEDIR="/root/deployments"** determines the **base directory** where all *docker-compose* stacks are located in their own sub-folders.\ - **DOCKER_COMPOSE_UPDATE_BASEDIR="/root/deployments"** determines the **base directory** where all *docker-compose* stacks are located in their own sub-folders.\

View file

@ -7,13 +7,13 @@ dynv6 - Updates dynv6 (an external service) and notifies about changes of IP add
It's part of **system-helpers**. It's part of **system-helpers**.
# SYNOPSIS # SYNOPSIS
**dynv6** [CONFIG_FILE (absolute path)] **dynv6**
# DESCRIPTION # DESCRIPTION
**dynv6** updates dynv6 (an external service) and notifies about changes of IP addresses. It comes with systemd services. **dynv6** updates dynv6 (an external service) and notifies about changes of IP addresses. It comes with systemd services.
If no *CONFIG_FILE* is provided, **dynv6** tries to read from *$HOME/.dynv6.conf* and */etc/dynv6.conf* for configuration. It will exit with a non-zero exit code if it cannot find an proper configuration file. By default, **dynv6** tries to read from *$HOME/.dynv6.conf* and */etc/dynv6.conf* for configuration. It will exit with a non-zero exit code if it cannot find a proper configuration file.
The following are at least required for the script to work:\ The following are at least required for the script to work:\
- **DYNV6_MAIL_ENABLED** to enable or disable mail notification. - **DYNV6_MAIL_ENABLED** to enable or disable mail notification.

View file

@ -7,13 +7,13 @@ memory_usage_alert - Checks available memory and sends out notification via mail
It's part of **system-helpers**. It's part of **system-helpers**.
# SYNOPSIS # SYNOPSIS
**memory_usage_alert** [CONFIG_FILE (absolute path)] **memory_usage_alert**
# DESCRIPTION # DESCRIPTION
**memory_usage_alert** checks available memory and sends out a mail if certain limits are reached. It comes with systemd services. **memory_usage_alert** checks available memory and sends out a mail if certain limits are reached. It comes with systemd services.
If no *CONFIG_FILE* is provided, **memory_usage_alert** tries to read from *$HOME/.memory_usage_alert.conf* and */etc/memory_usage_alert.conf* for configuration. It will exit with a non-zero exit code if it cannot find an proper configuration file. By default, **memory_usage_alert** tries to read from *$HOME/.memory_usage_alert.conf* and */etc/memory_usage_alert.conf* for configuration. It will exit with a non-zero exit code if it cannot find a proper configuration file.
The following are at least required for the script to work:\ The following are at least required for the script to work:\
- **MEMORY_USAGE_ALERT_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available.\ - **MEMORY_USAGE_ALERT_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available.\

39
_man/src/notifier.1.md Normal file
View file

@ -0,0 +1,39 @@
% notifier(1) notifier
% Alexander Schäferdiek
% January 2023
# NAME
notifier - Notifies via mail or gotify. Configuration is done in environment files.\
It's part of **system-helpers**.
# SYNOPSIS
**notifier** TITLE MESSAGE [MAIL_ADDRESS]
# DESCRIPTION
**notifier** executes *mailx* or *gotify* to send out notifications. It is used in other **system-helpers** by default.
By default, **notifier** tries to read from *$HOME/.notifier.conf* and */etc/notifier.conf* for configuration. It will exit with a non-zero exit code if it cannot find a proper configuration file.
The following configuration values can be set, defaults are shown as well:\
- **NOTIFIER_MAIL_ENABLED="true"** which enables or disables notification via mail to *NOTIFIER_MAIL_ADDRESS*.
- **NOTIFIER_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available¸
- **NOTIFIER_GOTIFY_ENABLED="false"** which 'gotify' command has be available and needs to be properly configured by having a cli.json file
You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user.
# EXAMPLE
Create a *$HOME/.notifier.conf* and add *NOTIFIER_MAIL_ADDRESS="alias@domain.tld"*. Notifications will be delivered to alias@domain.tld. Examples can be found in */usr/share/doc/notifier*.
# EXIT VALUES
**0**
: Success
**1**
: Error
# SEE ALSO
system-helpers

View file

@ -0,0 +1,33 @@
% smart_tests_long(1) smart_tests_long
% Alexander Schäferdiek
% January 2023
# NAME
smart_tests_long - Schedules smartd long tests. Configuration is done in environment files.\
It's part of **system-helpers**.
# SYNOPSIS
**smart_tests_long**
# DESCRIPTION
**smart_tests_long** checks for available updates using *smartctl* and sends out a mail. It comes with systemd services.
By default, **smart_tests_long** tries to read from *$HOME/.smartctl_tests_long.conf* and */etc/smartctl_tests_long.conf* for configuration. It will exit with a non-zero exit code if it cannot find a proper configuration file.
The following are at least required for the script to work:\
- **SMARTCTL_TESTS_LONG_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available.
- **SMARTCTL_TESTS_LONG_DEVICES=(sda)** array of block devices (not partitions!) to check.
You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user.
# EXAMPLE
Create a *$HOME/.smartctl_tests_long.conf* and add *SMARTCTL_TESTS_LONG_MAIL_ADDRESS="alias@domain.tld"*. Notifications will be delivered to alias@domain.tld for default block device **sda**. Examples can be found in */usr/share/doc/smart_tests_long*.
# EXIT VALUES
**0**
: Success
**1**
: Error

View file

@ -7,13 +7,13 @@ systemd_check - Checks a set of systemd services, targets, mounts of timers, and
It's part of **system-helpers**. It's part of **system-helpers**.
# SYNOPSIS # SYNOPSIS
**systemd_check** [CONFIG_FILE (absolute path)] **systemd_check**
# DESCRIPTION # DESCRIPTION
**systemd_check** checks a set of systemd services, targets, mounts of timers, and notifies if their state is not up and running. It comes with systemd services. **systemd_check** checks a set of systemd services, targets, mounts of timers, and notifies if their state is not up and running. It comes with systemd services.
If no *CONFIG_FILE* is provided, **systemd_check** tries to read from *$HOME/.systemd_check.conf* and */etc/systemd_check.conf* for configuration. It will exit with a non-zero exit code if it cannot find an proper configuration file. By default, **systemd_check** tries to read from *$HOME/.systemd_check.conf* and */etc/systemd_check.conf* for configuration. It will exit with a non-zero exit code if it cannot find a proper configuration file.
The following are at least required for the script to work:\ The following are at least required for the script to work:\
- **SYSTEMD_CHECK_LIST_FILE="$HOME/.systemd_check.list"** which lists to be checked systemd services, timers or targets separated by lines.\ - **SYSTEMD_CHECK_LIST_FILE="$HOME/.systemd_check.list"** which lists to be checked systemd services, timers or targets separated by lines.\

View file

@ -7,20 +7,20 @@ systemd_failure_notify - Notifies via mail or gotify when a service has failed.
It's part of **system-helpers**. It's part of **system-helpers**.
# SYNOPSIS # SYNOPSIS
**systemd_failure_notify** [CONFIG_FILE (absolute path)] [service name] **systemd_failure_notify** [SERVICE]
# DESCRIPTION # DESCRIPTION
**systemd_failure_notify** executes *mailx* or *gotify* to send out notifications. It comes with systemd services. Use the provided systemd service in the **OnFailure** directive with *OnFailure=systemd_failure_notify@%n.service*. **systemd_failure_notify** executes *mailx* or *gotify* to send out notifications. It comes with systemd services. Use the provided systemd service in the **OnFailure** directive with *OnFailure=systemd_failure_notify@%n.service*.
If no *CONFIG_FILE* is provided, **systemd_failure_notify** tries to read from *$HOME/.systemd_failure_notify.conf* and */etc/systemd_failure_notify.conf* for configuration. It will exit with a non-zero exit code if it cannot find an proper configuration file. By default, **systemd_failure_notify** tries to read from *$HOME/.systemd_failure_notify.conf* and */etc/systemd_failure_notify.conf* for configuration. It will exit with a non-zero exit code if it cannot find a proper configuration file.
The following are at least required for the script to work:\ The following are at least required for the script to work:\
- **SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available¸ - **SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available¸
By default, **SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED** is set to **true**. Set it to **false** to use *gotify* only.¸ By default, **SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED** is set to **true**. Set it to **false** to use *gotify* only.\
The following are optional and integrate gotify-cli to send notifications, it defaults to false: The following are optional and integrate gotify-cli to send notifications, it defaults to false:\
- **SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED="true"** uses *gotify* command which has be available and needs to be properly configured by having a cli.json file. - **SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED="true"** uses *gotify* command which has be available and needs to be properly configured by having a cli.json file.
You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user. You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user.

View file

@ -4,7 +4,7 @@
usage() { usage() {
USAGE=$( USAGE=$(
cat <<EOF cat <<EOF
Usage: check_updates [CONFIG_FILE (absolute path)] Usage: check_updates
Sends out update notifications. Please see man check_updates. Sends out update notifications. Please see man check_updates.
EOF EOF
@ -32,14 +32,8 @@ apply_config() {
} }
source_config() { source_config() {
local config=$1 local configFallback=$1
local configFallback=$2 local configGlobalFallback=$2
local configGlobalFallback=$3
if [[ -f "$config" ]]; then
apply_config "$config"
return
fi
if [[ -f "$configFallback" ]]; then if [[ -f "$configFallback" ]]; then
apply_config "$configFallback" apply_config "$configFallback"
@ -75,7 +69,7 @@ check_required() {
type mailx &> /dev/null || { echo "Requiring 'mailx' but it's not installed"; exit 1; } type mailx &> /dev/null || { echo "Requiring 'mailx' but it's not installed"; exit 1; }
} }
source_config "$1" "$HOME/.check_updates.conf" "/etc/check_updates.conf" source_config "$HOME/.check_updates.conf" "/etc/check_updates.conf"
apply_defaults apply_defaults
check_required check_required

View file

@ -3,7 +3,7 @@
# usage # usage
usage() { usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: disk_space_alert [CONFIG_FILE (absolute path)] Usage: disk_space_alert
Checks available diskspace for configured **mounts** and sends out a mail if certain limits are reached. Please see man disk_space_alert. Checks available diskspace for configured **mounts** and sends out a mail if certain limits are reached. Please see man disk_space_alert.
EOF EOF
@ -31,14 +31,8 @@ apply_config() {
} }
source_config() { source_config() {
local config=$1; local configFallback=$1;
local configFallback=$2; local configGlobalFallback=$2;
local configGlobalFallback=$3;
if [[ -f "$config" ]]; then
apply_config "$config";
return;
fi
if [[ -f "$configFallback" ]]; then if [[ -f "$configFallback" ]]; then
apply_config "$configFallback"; apply_config "$configFallback";
@ -57,14 +51,17 @@ check_required() {
type df &> /dev/null || { echo "Requiring 'df' but it's not installed"; exit 1; } type df &> /dev/null || { echo "Requiring 'df' but it's not installed"; exit 1; }
} }
source_config "$1" "$HOME/.disk_space_alert.conf" "/etc/disk_space_alert.conf" # apply defaults
check_required
HOSTNAME=$(hostname)
DISK_SPACE_ALERT_MAIL_ADDRESS=""; DISK_SPACE_ALERT_MAIL_ADDRESS="";
DISK_SPACE_ALERT_THRESHOLD=93 DISK_SPACE_ALERT_THRESHOLD=93
DISK_SPACE_ALERT_MOUNTPOINTS=("/") DISK_SPACE_ALERT_MOUNTPOINTS=("/")
source_config "$HOME/.disk_space_alert.conf" "/etc/disk_space_alert.conf"
check_required
# do not touch below
HOSTNAME=$(hostname)
for point in "${DISK_SPACE_ALERT_MOUNTPOINTS[@]}" for point in "${DISK_SPACE_ALERT_MOUNTPOINTS[@]}"
do do
CURRENT=$(df "$point" | grep "$point" | awk '{ print $5}' | sed 's/%//g') CURRENT=$(df "$point" | grep "$point" | awk '{ print $5}' | sed 's/%//g')

View file

@ -3,7 +3,7 @@
# usage # usage
usage() { usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: docker_check [CONFIG_FILE (absolute path)] Usage: docker_check
Checks a list of docker containers and notifies if their state is not up and running. Please see man docker_check. Checks a list of docker containers and notifies if their state is not up and running. Please see man docker_check.
EOF EOF
@ -13,13 +13,6 @@ EOF
set -e; set -e;
DOCKER_CHECK_LIST_FILE="$HOME/.docker_check.list"
DOCKER_CHECK_GLOBAL_LIST_FILE="/etc/docker_check.list"
DOCKER_CHECK_NOTIFY_LEVELS=("UNKNOWN" "WARNING" "CRITICAL")
DOCKER_CHECK_MAIL_ENABLED=false
DOCKER_CHECK_MAIL_ADDRESS=""
CONTAINERS=()
# check for config file # check for config file
apply_config() { apply_config() {
local config=$1; local config=$1;
@ -38,14 +31,8 @@ apply_config() {
} }
source_config() { source_config() {
local config=$1; local configFallback=$1;
local configFallback=$2; local configGlobalFallback=$2;
local configGlobalFallback=$3;
if [[ -f "$config" ]]; then
apply_config "$config";
return;
fi
if [[ -f "$configFallback" ]]; then if [[ -f "$configFallback" ]]; then
apply_config "$configFallback"; apply_config "$configFallback";
@ -64,7 +51,14 @@ check_required() {
type docker &> /dev/null || { echo "Requiring 'docker' but it's not installed"; exit 1; } type docker &> /dev/null || { echo "Requiring 'docker' but it's not installed"; exit 1; }
} }
source_config "$1" "$HOME/.docker_check.conf" "/etc/docker_check.conf" DOCKER_CHECK_LIST_FILE="$HOME/.docker_check.list"
DOCKER_CHECK_GLOBAL_LIST_FILE="/etc/docker_check.list"
DOCKER_CHECK_NOTIFY_LEVELS=("UNKNOWN" "WARNING" "CRITICAL")
DOCKER_CHECK_MAIL_ENABLED=false
DOCKER_CHECK_MAIL_ADDRESS=""
CONTAINERS=()
source_config "$HOME/.docker_check.conf" "/etc/docker_check.conf"
check_required check_required
HOSTNAME=$(hostname) HOSTNAME=$(hostname)

View file

@ -3,9 +3,9 @@
# usage # usage
usage() { usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: docker_compose_update [CONFIG_FILE (absolute path)] Usage: docker_compose_update
An utility to batch update *docker-compose* deployments residing in sub folders. Please see man docker_compose_update. Utility to batch update docker-compose deployments residing in sub folders of a base directory. Please see man docker_compose_update.
EOF EOF
) )
echo "$USAGE"; echo "$USAGE";
@ -33,14 +33,8 @@ apply_config() {
} }
source_config() { source_config() {
local config=$1; local configFallback=$1;
local configFallback=$2; local configGlobalFallback=$2;
local configGlobalFallback=$3;
if [[ -f "$config" ]]; then
apply_config "$config";
return;
fi
if [[ -f "$configFallback" ]]; then if [[ -f "$configFallback" ]]; then
apply_config "$configFallback"; apply_config "$configFallback";
@ -72,10 +66,9 @@ check_required() {
} }
# check requirements # check requirements
CONFIG_FILE="$1";
FALLBACK_CONFIG_FILE="${HOME}/.docker_compose_update.conf"; FALLBACK_CONFIG_FILE="${HOME}/.docker_compose_update.conf";
FALLBACK_CONFIG_GLOBAL_FILE="/etc/docker_compose_update.conf"; FALLBACK_CONFIG_GLOBAL_FILE="/etc/docker_compose_update.conf";
source_config "${CONFIG_FILE}" "${FALLBACK_CONFIG_FILE}" "${FALLBACK_CONFIG_GLOBAL_FILE}"; source_config "${FALLBACK_CONFIG_FILE}" "${FALLBACK_CONFIG_GLOBAL_FILE}";
apply_defaults; apply_defaults;
check_required; check_required;

View file

@ -4,8 +4,9 @@ set -e;
usage() { usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: dynv6 [CONFIG_FILE (absolute path)] Usage: dynv6
updates dynv6 (an external service) and notifies about changes of IP addresses. Please see man dynv6.
Updates dynv6 (an external service) and notifies about changes of IP addresses. Please see man dynv6.
EOF EOF
) )
echo "$USAGE"; echo "$USAGE";
@ -29,14 +30,8 @@ apply_config() {
} }
source_config() { source_config() {
local config=$1; local configFallback=$1;
local configFallback=$2; local configGlobalFallback=$2;
local configGlobalFallback=$3;
if [[ -f "$config" ]]; then
apply_config "$config";
return;
fi
if [[ -f "$configFallback" ]]; then if [[ -f "$configFallback" ]]; then
apply_config "$configFallback"; apply_config "$configFallback";
@ -91,10 +86,9 @@ check_required() {
} }
# check requirements # check requirements
CONFIG_FILE="$1";
FALLBACK_CONFIG_FILE="${HOME}/.dynv6.conf"; FALLBACK_CONFIG_FILE="${HOME}/.dynv6.conf";
FALLBACK_CONFIG_GLOBAL_FILE="/etc/dynv6.conf"; FALLBACK_CONFIG_GLOBAL_FILE="/etc/dynv6.conf";
source_config "${CONFIG_FILE}" "${FALLBACK_CONFIG_FILE}" "${FALLBACK_CONFIG_GLOBAL_FILE}"; source_config "${FALLBACK_CONFIG_FILE}" "${FALLBACK_CONFIG_GLOBAL_FILE}";
apply_defaults; apply_defaults;
check_required; check_required;

View file

@ -3,7 +3,7 @@
# usage # usage
usage() { usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: memory_usage_alert [CONFIG_FILE (absolute path)] Usage: memory_usage_alert
Checks available memory and sends out notification via mail. Please see man memory_usage_alert. Checks available memory and sends out notification via mail. Please see man memory_usage_alert.
EOF EOF
@ -13,9 +13,6 @@ EOF
set -e; set -e;
MEMORY_USAGE_ALERT_MAIL_ADDRESS="";
MEMORY_USAGE_ALERT_THRESHOLD=512;
# check for config file # check for config file
apply_config() { apply_config() {
local config=$1; local config=$1;
@ -34,14 +31,8 @@ apply_config() {
} }
source_config() { source_config() {
local config=$1; local configFallback=$1;
local configFallback=$2; local configGlobalFallback=$2;
local configGlobalFallback=$3;
if [[ -f "$config" ]]; then
apply_config "$config";
return;
fi
if [[ -f "$configFallback" ]]; then if [[ -f "$configFallback" ]]; then
apply_config "$configFallback"; apply_config "$configFallback";
@ -60,7 +51,10 @@ check_required() {
type free &> /dev/null || { echo "Requiring 'free' but it's not installed"; exit 1; } type free &> /dev/null || { echo "Requiring 'free' but it's not installed"; exit 1; }
} }
source_config "$1" "$HOME/.memory_usage_alert.conf" "/etc/memory_usage_alert.conf" MEMORY_USAGE_ALERT_MAIL_ADDRESS="";
MEMORY_USAGE_ALERT_THRESHOLD=512;
source_config "$HOME/.memory_usage_alert.conf" "/etc/memory_usage_alert.conf"
check_required check_required
HOSTNAME=$(hostname) HOSTNAME=$(hostname)

119
usr/local/bin/notifier Executable file
View file

@ -0,0 +1,119 @@
#!/usr/bin/env bash
# usage
usage() {
USAGE=$(cat <<EOF
Usage: notifier <subject> <content> [<mail address>]
Sends out notifications. Please see man notifier.
EOF
)
echo "$USAGE";
}
set -e;
NOTIFIER_SUBJECT=$1
if [ -z "$NOTIFIER_SUBJECT" ]; then
echo "No subject given";
echo "";
usage;
exit 1;
fi
NOTIFIER_CONTENT=$2
if [ -z "$NOTIFIER_CONTENT" ]; then
echo "No content given";
echo "";
usage;
exit 1;
fi
NOTIFIER_MAIL_ENABLED="true";
NOTIFIER_GOTIFY_ENABLED="false";
NOTIFIER_MAIL_ADDRESS=$3;
# check for config file
apply_config() {
local config=$1;
if [[ ! -f "$config" ]]; then
echo "No config file specified";
echo "";
usage;
exit 1;
fi
set -a;
# shellcheck disable=SC1090
source "$config";
set +a;
}
check_requirements() {
local mailEnabled=$1;
local gotifyEnabled=$2;
local mailAddress=$3;
if [[ "${mailEnabled}" == "false" && "${gotifyEnabled}" == "false" ]]; then
echo "Mail and gotify cannot be disabled simultanously";
echo "";
usage;
exit 1;
fi
if [[ "${mailEnabled}" == "true" ]]; then
type mailx &> /dev/null || { echo "Requiring 'mailx' but it's not installed"; exit 1; }
if [ -z "${mailAddress}" ]; then
echo "No mail address given";
echo "";
usage;
exit 1;
fi
fi
if [[ "${gotifyEnabled}" == "true" ]]; then
type gotify &> /dev/null || { echo "Requiring 'gotify' but it's not installed"; exit 1; }
fi
}
source_config() {
local configFallback=$1;
local configGlobalFallback=$2;
if [[ -f "$configFallback" ]]; then
apply_config "$configFallback";
return;
fi
if [[ -f "$configGlobalFallback" ]]; then
apply_config "$configGlobalFallback";
return;
fi
}
source_config "$HOME/.notifier.conf" "/etc/notifier.conf"
check_requirements "${NOTIFIER_MAIL_ENABLED}" "${NOTIFIER_GOTIFY_ENABLED}" "${NOTIFIER_MAIL_ADDRESS}"
SUBJECT="${NOTIFIER_SUBJECT}"
MESSAGE="${NOTIFIER_CONTENT}"
if [[ "${NOTIFIER_MAIL_ENABLED}" == "true" ]]; then
echo "$MESSAGE"|mailx -Ssendwait -s "$SUBJECT" "$NOTIFIER_MAIL_ADDRESS";
echo "Sent notifiction via mail"
else
echo "Sending notifictions via mail is disabled"
fi
if [[ "${NOTIFIER_GOTIFY_ENABLED}" == "true" ]]; then
if [[ ! -f "${HOME}/.config/gotify/cli.json" && ! -f "${HOME}/gotify/cli.json" && ! -f "./cli.json" && ! -f "/etc/gotify/cli.json" ]]; then
echo "Cannot find a valid cli.json, please run 'gotify init' before using this"
exit 1;
fi
echo "$MESSAGE"|gotify push --quiet --title "${SUBJECT}";
echo "Sent message via gotify"
else
echo "Sending notifictions via gotify is disabled"
fi

View file

@ -3,18 +3,9 @@
# usage # usage
usage() { usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: smartctl_tests_long [CONFIG_FILE (absolute path)] Usage: smartctl_tests_long
If no CONFIG_FILE is given, HOME/.smartctl_tests_long.conf or /etc/smartctl_tests_long.conf is used. This fallback option Schedules smartd long tests. Please see man smartctl_tests_long.
has to exist or the script will exit.
Configuration can be done in any file and any pre-defined variable can be overwritten.
The following are at least required for the script to work:
- SMARTCTL_TESTS_LONG_MAIL_ADDRESS="" // mail.rc has to be configured
- SMARTCTL_TESTS_LONG_DEVICES=(sda) // array of block devices (not partitions!) to check
You can copy this script to '/usr/local/bin' and use create a custom CONFIG_FILE as user. Examples can be found in '/usr/share/doc/<scriptname>'.
EOF EOF
) )
echo "$USAGE"; echo "$USAGE";
@ -22,9 +13,6 @@ EOF
set -e; set -e;
SMARTCTL_TESTS_LONG_MAIL_ADDRESS="";
SMARTCTL_TESTS_LONG_DEVICES=(sda)
# check for config file # check for config file
apply_config() { apply_config() {
local config=$1; local config=$1;
@ -43,14 +31,8 @@ apply_config() {
} }
source_config() { source_config() {
local config=$1; local configFallback=$1;
local configFallback=$2; local configGlobalFallback=$2;
local configGlobalFallback=$3;
if [[ -f "$config" ]]; then
apply_config "$config";
return;
fi
if [[ -f "$configFallback" ]]; then if [[ -f "$configFallback" ]]; then
apply_config "$configFallback"; apply_config "$configFallback";
@ -69,7 +51,11 @@ check_required() {
type smartctl &> /dev/null || { echo "Requiring 'smartctl' but it's not installed"; exit 1; } type smartctl &> /dev/null || { echo "Requiring 'smartctl' but it's not installed"; exit 1; }
} }
source_config "$1" "$HOME/.smartctl_tests_long.conf" "/etc/smartctl_tests_long.conf" SMARTCTL_TESTS_LONG_MAIL_ADDRESS="";
SMARTCTL_TESTS_LONG_DEVICES=(sda)
source_config "$HOME/.smartctl_tests_long.conf" "/etc/smartctl_tests_long.conf"
check_required
HOSTNAME=$(hostname) HOSTNAME=$(hostname)

View file

@ -3,7 +3,7 @@
# usage # usage
usage() { usage() {
SYSTEMD_CHECK_USAGE=$(cat <<EOF SYSTEMD_CHECK_USAGE=$(cat <<EOF
Usage: systemd_check.sh [CONFIG_FILE (absolute path)] Usage: systemd_check.sh
Checks a set of systemd services, targets, mounts of timers, and notifies if their state is not up and running. Please see man systemd_check. Checks a set of systemd services, targets, mounts of timers, and notifies if their state is not up and running. Please see man systemd_check.
@ -14,13 +14,6 @@ EOF
set -e; set -e;
# vars and defaults
SYSTEMD_CHECK_LIST_FILE="$HOME/.systemd_check.list"
SYSTEMD_CHECK_GLOBAL_LIST_FILE="/etc/systemd_check.list"
SYSTEMD_CHECK_MAIL_ENABLED=fase
SYSTEMD_CHECK_MAIL_ADDRESS=""
SYSTEMD_CHECK_SERVICES=()
# check for config file # check for config file
apply_config() { apply_config() {
local config=$1; local config=$1;
@ -39,14 +32,8 @@ apply_config() {
} }
source_config() { source_config() {
local config=$1; local configFallback=$1;
local configFallback=$2; local configGlobalFallback=$2;
local configGlobalFallback=$3;
if [[ -f "$config" ]]; then
apply_config "$config";
return;
fi
if [[ -f "$configFallback" ]]; then if [[ -f "$configFallback" ]]; then
apply_config "$configFallback"; apply_config "$configFallback";
@ -66,7 +53,13 @@ check_required() {
type systemctl &> /dev/null || { echo "Requiring 'systemctl' but it's not installed"; exit 1; } type systemctl &> /dev/null || { echo "Requiring 'systemctl' but it's not installed"; exit 1; }
} }
source_config "$1" "$HOME/.systemd_check.conf" "/etc/systemd_check.conf" SYSTEMD_CHECK_LIST_FILE="$HOME/.systemd_check.list"
SYSTEMD_CHECK_GLOBAL_LIST_FILE="/etc/systemd_check.list"
SYSTEMD_CHECK_MAIL_ENABLED=fase
SYSTEMD_CHECK_MAIL_ADDRESS=""
SYSTEMD_CHECK_SERVICES=()
source_config "$HOME/.systemd_check.conf" "/etc/systemd_check.conf"
check_required check_required
SYSTEMD_CHECK_HOSTNAME=$(hostname) SYSTEMD_CHECK_HOSTNAME=$(hostname)

View file

@ -3,7 +3,7 @@
# usage # usage
usage() { usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: systemd_failure_notify [CONFIG_FILE (absolute path)] <service> Usage: systemd_failure_notify [SERVICE]
Sends out notifications for failed services. Please see man systemd_failure_notify. Sends out notifications for failed services. Please see man systemd_failure_notify.
EOF EOF
@ -59,14 +59,8 @@ check_requirements() {
} }
source_config() { source_config() {
local config=$1; local configFallback=$1;
local configFallback=$2; local configGlobalFallback=$2;
local configGlobalFallback=$3;
if [[ -f "$config" ]]; then
apply_config "$config";
return;
fi
if [[ -f "$configFallback" ]]; then if [[ -f "$configFallback" ]]; then
apply_config "$configFallback"; apply_config "$configFallback";
@ -78,7 +72,7 @@ source_config() {
return; return;
fi fi
} }
source_config "$2" "$HOME/.systemd_failure_notify.conf" "/etc/systemd_failure_notify.conf" source_config "$HOME/.systemd_failure_notify.conf" "/etc/systemd_failure_notify.conf"
check_requirements "$SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED" "$SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED" check_requirements "$SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED" "$SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED"
SYSTEMD_FAILURE_NOTIFY_HOSTNAME=$(hostname) SYSTEMD_FAILURE_NOTIFY_HOSTNAME=$(hostname)

View file

@ -26,17 +26,17 @@ Configuration is done in environment files.
It\[cq]s part of \f[B]system-helpers\f[R]. It\[cq]s part of \f[B]system-helpers\f[R].
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\f[B]check_updates\f[R] [CONFIG_FILE (absolute path)] \f[B]check_updates\f[R]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\f[B]check_updates\f[R] checks for available updates using \f[B]check_updates\f[R] checks for available updates using
\f[I]checkupdates\f[R] and sends out a mail. \f[I]checkupdates\f[R] and sends out a mail.
It comes with systemd services. It comes with systemd services.
.PP .PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]check_updates\f[R] tries By default, \f[B]check_updates\f[R] tries to read from
to read from \f[I]$HOME/.check_updates.conf\f[R] and \f[I]$HOME/.check_updates.conf\f[R] and
\f[I]/etc/check_updates.conf\f[R] for configuration. \f[I]/etc/check_updates.conf\f[R] for configuration.
It will exit with a non-zero exit code if it cannot find an proper It will exit with a non-zero exit code if it cannot find a proper
configuration file. configuration file.
.PP .PP
The following are at least required for the script to work: The following are at least required for the script to work:

View file

@ -27,17 +27,17 @@ Configuration is done in environment files.
It\[cq]s part of \f[B]system-helpers\f[R]. It\[cq]s part of \f[B]system-helpers\f[R].
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\f[B]disk_space_alert\f[R] [CONFIG_FILE (absolute path)] \f[B]disk_space_alert\f[R]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\f[B]disk_space_alert\f[R] checks available diskspace for configured \f[B]disk_space_alert\f[R] checks available diskspace for configured
\f[B]mounts\f[R] and sends out a mail if certain limits are reached. \f[B]mounts\f[R] and sends out a mail if certain limits are reached.
It comes with systemd services. It comes with systemd services.
.PP .PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]disk_space_alert\f[R] By default, \f[B]disk_space_alert\f[R] tries to read from
tries to read from \f[I]$HOME/.disk_space_alert.conf\f[R] and \f[I]$HOME/.disk_space_alert.conf\f[R] and
\f[I]/etc/disk_space_alert.conf\f[R] for configuration. \f[I]/etc/disk_space_alert.conf\f[R] for configuration.
It will exit with a non-zero exit code if it cannot find an proper It will exit with a non-zero exit code if it cannot find a proper
configuration file. configuration file.
.PP .PP
The following are at least required for the script to work: The following are at least required for the script to work:

View file

@ -27,17 +27,17 @@ Configuration is done in environment files.
It\[cq]s part of \f[B]system-helpers\f[R]. It\[cq]s part of \f[B]system-helpers\f[R].
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\f[B]docker_check\f[R] [CONFIG_FILE (absolute path)] \f[B]docker_check\f[R]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\f[B]docker_check\f[R] checks a list of docker containers and notifies \f[B]docker_check\f[R] checks a list of docker containers and notifies
if their state is not up and running. if their state is not up and running.
It comes with systemd services. It comes with systemd services.
.PP .PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]docker_check\f[R] tries to By default, \f[B]docker_check\f[R] tries to read from
read from \f[I]$HOME/.docker_check.conf\f[R] and \f[I]$HOME/.docker_check.conf\f[R] and \f[I]/etc/docker_check.conf\f[R]
\f[I]/etc/docker_check.conf\f[R] for configuration. for configuration.
It will exit with a non-zero exit code if it cannot find an proper It will exit with a non-zero exit code if it cannot find a proper
configuration file. configuration file.
.PP .PP
The following are at least required for the script to work: The following are at least required for the script to work:

View file

@ -18,8 +18,8 @@
.hy .hy
.SH NAME .SH NAME
.PP .PP
docker_compose_update - An utility to batch update docker_compose_update - Utility to batch update \f[I]docker-compose\f[R]
\f[I]docker-compose\f[R] deployments residing in sub folders. deployments residing in sub folders of a base directory.
Configuration is done in environment files. Configuration is done in environment files.
.PD 0 .PD 0
.P .P
@ -27,7 +27,7 @@ Configuration is done in environment files.
It\[cq]s part of \f[B]system-helpers\f[R]. It\[cq]s part of \f[B]system-helpers\f[R].
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\f[B]docker_compose_update\f[R] [CONFIG_FILE (absolute path)] \f[B]docker_compose_update\f[R]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\f[B]docker_compose_update\f[R] is an utility to batch update \f[B]docker_compose_update\f[R] is an utility to batch update
@ -36,10 +36,10 @@ It\[cq]s part of \f[B]system-helpers\f[R].
different sub folders, each having a \f[I]docker-compose\f[R] deployment different sub folders, each having a \f[I]docker-compose\f[R] deployment
in it. in it.
.PP .PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]docker_compose_update\f[R] By default, \f[B]docker_compose_update\f[R] tries to read from
tries to read from \f[I]$HOME/.docker_compose_update.conf\f[R] and \f[I]$HOME/.docker_compose_update.conf\f[R] and
\f[I]/etc/docker_compose_update.conf\f[R] for configuration. \f[I]/etc/docker_compose_update.conf\f[R] for configuration.
It will exit with a non-zero exit code if it cannot find an proper It will exit with a non-zero exit code if it cannot find a proper
configuration file. configuration file.
.PP .PP
The following are at least required for the script to work: The following are at least required for the script to work:

View file

@ -27,17 +27,17 @@ Configuration is done in environment files.
It\[cq]s part of \f[B]system-helpers\f[R]. It\[cq]s part of \f[B]system-helpers\f[R].
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\f[B]dynv6\f[R] [CONFIG_FILE (absolute path)] \f[B]dynv6\f[R]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\f[B]dynv6\f[R] updates dynv6 (an external service) and notifies about \f[B]dynv6\f[R] updates dynv6 (an external service) and notifies about
changes of IP addresses. changes of IP addresses.
It comes with systemd services. It comes with systemd services.
.PP .PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]dynv6\f[R] tries to read By default, \f[B]dynv6\f[R] tries to read from
from \f[I]$HOME/.dynv6.conf\f[R] and \f[I]/etc/dynv6.conf\f[R] for \f[I]$HOME/.dynv6.conf\f[R] and \f[I]/etc/dynv6.conf\f[R] for
configuration. configuration.
It will exit with a non-zero exit code if it cannot find an proper It will exit with a non-zero exit code if it cannot find a proper
configuration file. configuration file.
.PP .PP
The following are at least required for the script to work: The following are at least required for the script to work:

View file

@ -27,17 +27,17 @@ Configuration is done in environment files.
It\[cq]s part of \f[B]system-helpers\f[R]. It\[cq]s part of \f[B]system-helpers\f[R].
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\f[B]memory_usage_alert\f[R] [CONFIG_FILE (absolute path)] \f[B]memory_usage_alert\f[R]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\f[B]memory_usage_alert\f[R] checks available memory and sends out a \f[B]memory_usage_alert\f[R] checks available memory and sends out a
mail if certain limits are reached. mail if certain limits are reached.
It comes with systemd services. It comes with systemd services.
.PP .PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]memory_usage_alert\f[R] By default, \f[B]memory_usage_alert\f[R] tries to read from
tries to read from \f[I]$HOME/.memory_usage_alert.conf\f[R] and \f[I]$HOME/.memory_usage_alert.conf\f[R] and
\f[I]/etc/memory_usage_alert.conf\f[R] for configuration. \f[I]/etc/memory_usage_alert.conf\f[R] for configuration.
It will exit with a non-zero exit code if it cannot find an proper It will exit with a non-zero exit code if it cannot find a proper
configuration file. configuration file.
.PP .PP
The following are at least required for the script to work: The following are at least required for the script to work:

View file

@ -0,0 +1,78 @@
.\" Automatically generated by Pandoc 2.19.2
.\"
.\" Define V font for inline verbatim, using C font in formats
.\" that render this, and otherwise B font.
.ie "\f[CB]x\f[]"x" \{\
. ftr V B
. ftr VI BI
. ftr VB B
. ftr VBI BI
.\}
.el \{\
. ftr V CR
. ftr VI CI
. ftr VB CB
. ftr VBI CBI
.\}
.TH "notifier" "1" "January 2023" "notifier" ""
.hy
.SH NAME
.PP
notifier - Notifies via mail or gotify.
Configuration is done in environment files.
.PD 0
.P
.PD
It\[cq]s part of \f[B]system-helpers\f[R].
.SH SYNOPSIS
.PP
\f[B]notifier\f[R] TITLE MESSAGE [MAIL_ADDRESS]
.SH DESCRIPTION
.PP
\f[B]notifier\f[R] executes \f[I]mailx\f[R] or \f[I]gotify\f[R] to send
out notifications.
It is used in other \f[B]system-helpers\f[R] by default.
.PP
By default, \f[B]notifier\f[R] tries to read from
\f[I]$HOME/.notifier.conf\f[R] and \f[I]/etc/notifier.conf\f[R] for
configuration.
It will exit with a non-zero exit code if it cannot find a proper
configuration file.
.PP
The following configuration values can be set, defaults are shown as
well:
.PD 0
.P
.PD
.IP \[bu] 2
\f[B]NOTIFIER_MAIL_ENABLED=\[lq]true\[rq]\f[R] which enables or disables
notification via mail to \f[I]NOTIFIER_MAIL_ADDRESS\f[R].
.IP \[bu] 2
\f[B]NOTIFIER_MAIL_ADDRESS=\[lq]\[lq]\f[R] which requires
\f[I]mail.rc\f[R] to be configured and `\f[I]mailx\f[R]' command has be
available\[ac]
.IP \[bu] 2
\f[B]NOTIFIER_GOTIFY_ENABLED=\[lq]false\[rq]\f[R] which `gotify' command
has be available and needs to be properly configured by having a
cli.json file
.PP
You can copy this script to \f[I]/usr/local/bin\f[R] and use create a
custom \f[B]CONFIG_FILE\f[R] as user.
.SH EXAMPLE
.PP
Create a \f[I]$HOME/.notifier.conf\f[R] and add
\f[I]NOTIFIER_MAIL_ADDRESS=\[lq]alias\[at]domain.tld\[rq]\f[R].
Notifications will be delivered to alias\[at]domain.tld.
Examples can be found in \f[I]/usr/share/doc/notifier\f[R].
.SH EXIT VALUES
.TP
\f[B]0\f[R]
Success
.TP
\f[B]1\f[R]
Error
.SH SEE ALSO
.PP
system-helpers
.SH AUTHORS
Alexander Sch\[:a]ferdiek.

View file

@ -0,0 +1,70 @@
.\" Automatically generated by Pandoc 2.19.2
.\"
.\" Define V font for inline verbatim, using C font in formats
.\" that render this, and otherwise B font.
.ie "\f[CB]x\f[]"x" \{\
. ftr V B
. ftr VI BI
. ftr VB B
. ftr VBI BI
.\}
.el \{\
. ftr V CR
. ftr VI CI
. ftr VB CB
. ftr VBI CBI
.\}
.TH "smart_tests_long" "1" "January 2023" "smart_tests_long" ""
.hy
.SH NAME
.PP
smart_tests_long - Schedules smartd long tests.
Configuration is done in environment files.
.PD 0
.P
.PD
It\[cq]s part of \f[B]system-helpers\f[R].
.SH SYNOPSIS
.PP
\f[B]smart_tests_long\f[R]
.SH DESCRIPTION
.PP
\f[B]smart_tests_long\f[R] checks for available updates using
\f[I]smartctl\f[R] and sends out a mail.
It comes with systemd services.
.PP
By default, \f[B]smart_tests_long\f[R] tries to read from
\f[I]$HOME/.smartctl_tests_long.conf\f[R] and
\f[I]/etc/smartctl_tests_long.conf\f[R] for configuration.
It will exit with a non-zero exit code if it cannot find a proper
configuration file.
.PP
The following are at least required for the script to work:
.PD 0
.P
.PD
- \f[B]SMARTCTL_TESTS_LONG_MAIL_ADDRESS=\[lq]\[lq]\f[R] which requires
\f[I]mail.rc\f[R] to be configured and `\f[I]mailx\f[R]' command has be
available.
- \f[B]SMARTCTL_TESTS_LONG_DEVICES=(sda)\f[R] array of block devices
(not partitions!)
to check.
.PP
You can copy this script to \f[I]/usr/local/bin\f[R] and use create a
custom \f[B]CONFIG_FILE\f[R] as user.
.SH EXAMPLE
.PP
Create a \f[I]$HOME/.smartctl_tests_long.conf\f[R] and add
\f[I]SMARTCTL_TESTS_LONG_MAIL_ADDRESS=\[lq]alias\[at]domain.tld\[rq]\f[R].
Notifications will be delivered to alias\[at]domain.tld for default
block device \f[B]sda\f[R].
Examples can be found in \f[I]/usr/share/doc/smart_tests_long\f[R].
.SH EXIT VALUES
.TP
\f[B]0\f[R]
Success
.TP
\f[B]1\f[R]
Error
.SH AUTHORS
Alexander Sch\[:a]ferdiek.

View file

@ -27,17 +27,17 @@ Configuration is done in environment files.
It\[cq]s part of \f[B]system-helpers\f[R]. It\[cq]s part of \f[B]system-helpers\f[R].
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\f[B]systemd_check\f[R] [CONFIG_FILE (absolute path)] \f[B]systemd_check\f[R]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\f[B]systemd_check\f[R] checks a set of systemd services, targets, \f[B]systemd_check\f[R] checks a set of systemd services, targets,
mounts of timers, and notifies if their state is not up and running. mounts of timers, and notifies if their state is not up and running.
It comes with systemd services. It comes with systemd services.
.PP .PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]systemd_check\f[R] tries By default, \f[B]systemd_check\f[R] tries to read from
to read from \f[I]$HOME/.systemd_check.conf\f[R] and \f[I]$HOME/.systemd_check.conf\f[R] and
\f[I]/etc/systemd_check.conf\f[R] for configuration. \f[I]/etc/systemd_check.conf\f[R] for configuration.
It will exit with a non-zero exit code if it cannot find an proper It will exit with a non-zero exit code if it cannot find a proper
configuration file. configuration file.
.PP .PP
The following are at least required for the script to work: The following are at least required for the script to work:

View file

@ -27,8 +27,7 @@ Configuration is done in environment files.
It\[cq]s part of \f[B]system-helpers\f[R]. It\[cq]s part of \f[B]system-helpers\f[R].
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\f[B]systemd_failure_notify\f[R] [CONFIG_FILE (absolute path)] [service \f[B]systemd_failure_notify\f[R] [SERVICE]
name]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\f[B]systemd_failure_notify\f[R] executes \f[I]mailx\f[R] or \f[B]systemd_failure_notify\f[R] executes \f[I]mailx\f[R] or
@ -37,11 +36,10 @@ It comes with systemd services.
Use the provided systemd service in the \f[B]OnFailure\f[R] directive Use the provided systemd service in the \f[B]OnFailure\f[R] directive
with \f[I]OnFailure=systemd_failure_notify\[at]%n.service\f[R]. with \f[I]OnFailure=systemd_failure_notify\[at]%n.service\f[R].
.PP .PP
If no \f[I]CONFIG_FILE\f[R] is provided, By default, \f[B]systemd_failure_notify\f[R] tries to read from
\f[B]systemd_failure_notify\f[R] tries to read from
\f[I]$HOME/.systemd_failure_notify.conf\f[R] and \f[I]$HOME/.systemd_failure_notify.conf\f[R] and
\f[I]/etc/systemd_failure_notify.conf\f[R] for configuration. \f[I]/etc/systemd_failure_notify.conf\f[R] for configuration.
It will exit with a non-zero exit code if it cannot find an proper It will exit with a non-zero exit code if it cannot find a proper
configuration file. configuration file.
.PP .PP
The following are at least required for the script to work: The following are at least required for the script to work:
@ -54,11 +52,17 @@ command has be available\[ac]
.PP .PP
By default, \f[B]SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED\f[R] is set to By default, \f[B]SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED\f[R] is set to
\f[B]true\f[R]. \f[B]true\f[R].
Set it to \f[B]false\f[R] to use \f[I]gotify\f[R] only.\[ac] Set it to \f[B]false\f[R] to use \f[I]gotify\f[R] only.
.PD 0
.P
.PD
.PP .PP
The following are optional and integrate gotify-cli to send The following are optional and integrate gotify-cli to send
notifications, it defaults to false: - notifications, it defaults to false:
\f[B]SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED=\[lq]true\[rq]\f[R] uses .PD 0
.P
.PD
- \f[B]SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED=\[lq]true\[rq]\f[R] uses
\f[I]gotify\f[R] command which has be available and needs to be properly \f[I]gotify\f[R] command which has be available and needs to be properly
configured by having a cli.json file. configured by having a cli.json file.
.PP .PP