Switch to pandoc for man creation; add manuals for configuration-based helper scripts; add support for gotify in systemd_failure_notify
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Alexander Schäferdiek 2023-01-25 02:16:01 +01:00
parent ad137e68b3
commit dde06a6da3
34 changed files with 1091 additions and 308 deletions

2
_man/.gitignore vendored
View file

@ -1,2 +0,0 @@
vendor/
.bundle/

View file

@ -1,4 +0,0 @@
source "https://rubygems.org"
gem "ronn", "~> 0.7.3"

View file

@ -1,19 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
hpricot (0.8.6)
mustache (1.1.1)
rdiscount (2.2.0.2)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
rdiscount (>= 1.5.8)
PLATFORMS
x86_64-linux
DEPENDENCIES
ronn (~> 0.7.3)
BUNDLED WITH
2.3.15

View file

@ -1,14 +1,12 @@
# README # README
Build man pages with `ronn`. Build man pages.
- Install Ruby and `gem` - Install `pandoc`
- Install `gem install bundler` or via system package `bundler` - Execute the following to build
- Execute the following to build and serve via _Jekyll_
```shell ```shell
bundle config set --local path 'vendor/bundle' cd _man
bundle install
# generate man pages in /usr/share/man/man1 # generate man pages in /usr/share/man/man1
for file in src/*.ronn; do bn=$(basename $file .ronn); bundle exec ronn --pipe < $file > ../usr/share/man/man1/$bn; done for file in src/*.md; do bn=$(basename $file .md); pandoc $file -s -t man -o ../usr/share/man/man1/$bn; done
``` ```

View file

@ -0,0 +1,32 @@
% check_updates(1) check_updates
% Alexander Schäferdiek
% January 2023
# NAME
check_updates - Notifies about available updates. Configuration is done in environment files.\
It's part of **system-helpers**.
# SYNOPSIS
**check_updates** [CONFIG_FILE (absolute path)]
# DESCRIPTION
**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.
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.
You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user.
# EXAMPLE
Create a *$HOME/.check_updates.conf* and add *CHECK_UPDATES_MAIL_ADDRESS="alias@domain.tld"*. Notifications will be delivered to alias@domain.tld. Examples can be found in */usr/share/doc/check_updates*.
# EXIT VALUES
**0**
: Success
**1**
: Error

View file

@ -0,0 +1,36 @@
% disk_space_alert(1) disk_space_alert
% Alexander Schäferdiek
% January 2023
# NAME
disk_space_alert - Checks available disk space and sends out notification via mail. Configuration is done in environment files.\
It's part of **system-helpers**.
# SYNOPSIS
**disk_space_alert** [CONFIG_FILE (absolute path)]
# 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.
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.
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.\
The following are optional or have reasonable defaults:
- **DISK_SPACE_ALERT_THRESHOLD=93** in percentage
- **DISK_SPACE_ALERT_MOUNTPOINTS=("/")** is an array of mountpoints
You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user.
# EXAMPLE
Create a *$HOME/.disk_space_alert.conf* and add *DISK_SPACE_ALERT_MAIL_ADDRESS="alias@domain.tld"*. Notifications will be delivered to alias@domain.tld. Examples can be found in */usr/share/doc/disk_space_alert*.
# EXIT VALUES
**0**
: Success
**1**
: Error

View file

@ -0,0 +1,35 @@
% docker_check(1) docker_check
% Alexander Schäferdiek
% January 2023
# NAME
docker_check - Checks a set of docker containers and notifies if their state is not up and running. Configuration is done in environment files.\
It's part of **system-helpers**.
# SYNOPSIS
**docker_check** [CONFIG_FILE (absolute path)]
# DESCRIPTION
**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.
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_LIST_FILE="$HOME/.docker_check.list"** which lists to be checked docker containers separated by lines. Provide their container name, e.g. output of current running docker containers piped into the file: *docker ps --format '{{.Names}}' >> $HOME/.docker_check.list*).\
- **DOCKER_CHECK_NOTIFY_LEVELS=("UNKNOWN" "WARNING" "CRITICAL")** determines when to notify/output/send mail. Possible: *"UNKNOWN"* *"WARNING"* *"CRITICAL"* *"INFO"*.\
- **DOCKER_CHECK_MAIL_ENABLED=false** enables or disables sending mail notifications.
You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user.
# EXAMPLE
Create a *$HOME/.docker_check.conf* and add *DOCKER_CHECK_MAIL_ADDRESS="alias@domain.tld"*. Notifications will be delivered to alias@domain.tld. Examples can be found in */usr/share/doc/docker_check*.
# EXIT VALUES
**0**
: Success
**1**
: Error

View file

@ -0,0 +1,36 @@
% docker_compose_update(1) docker_compose_update
% Alexander Schäferdiek
% January 2023
# NAME
docker_compose_update - An utility to batch update *docker-compose* deployments residing in sub folders. Configuration is done in environment files.\
It's part of **system-helpers**.
# SYNOPSIS
**docker_compose_update** [CONFIG_FILE (absolute path)]
# 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.
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.
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_IGNORES=("mailcow")** folder names which will be ignored and not be updated, at least () is required.\
- **DOCKER_COMPOSE_UPDATE_COMMANDS[aDirectoryName]="./callFancyScriptInDirectory"** to explicitly define update command for one sub folder *aDirectoryName*. This is a map and defining different instructions for multiple locations is possible. Example: accessor has to match the folder, e.g. *<baseDir>/aDirectoryName* will use command "*./callFancyScriptInDirectory"* when changing directory into it.\
- **DOCKER_COMPOSE_UPDATE_COMMAND="sudo docker-compose down; sudo docker-compose pull; sudo docker-compose up -d;"** determines the default update command executed for each deployment.\
- **DOCKER_COMPOSE_UPDATE_FAIL_ON_UPDATE_ERROR="false"** determines if script fails if at least one update procedure failed
You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user.
# EXAMPLE
Create a *$HOME/.docker_compose_update.conf* and necessary configuration. Examples can be found in */usr/share/doc/docker_compose_update*.
# EXIT VALUES
**0**
: Success
**1**
: Error

38
_man/src/dynv6.1.md Normal file
View file

@ -0,0 +1,38 @@
% dynv6(1) dynv6
% Alexander Schäferdiek
% January 2023
# NAME
dynv6 - Updates dynv6 (an external service) and notifies about changes of IP addresses. Configuration is done in environment files.\
It's part of **system-helpers**.
# SYNOPSIS
**dynv6** [CONFIG_FILE (absolute path)]
# DESCRIPTION
**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.
The following are at least required for the script to work:\
- **DYNV6_MAIL_ENABLED** to enable or disable mail notification.
- **DYNV6_MAIL_ADDRESS** which requires *mail.rc* to be configured and '*mailx*' command has be available.\
- **DYNV6_TOKEN** the dynv6 token.\
- **DYNV6_HOSTNAME** the dynv6 hostname.\
- **DYNV6_IPV4_ENABLED** enable or disable updating IPv4.\
- **DYNV6_IPV6_ENABLED** enable or disable updating IPv6.\
- **DYNV6_IPV6_INTERFACE** which interface to track, be sure that Privacy Extensions are disabled.\
You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user.
# EXAMPLE
Create a *$HOME/.dynv6.conf* and add *DYNV6_MAIL_ADDRESS="alias@domain.tld"*. Notifications will be delivered to alias@domain.tld. Examples can be found in */usr/share/doc/dynv6*.
# EXIT VALUES
**0**
: Success
**1**
: Error

View file

@ -0,0 +1,35 @@
% memory_usage_alert(1) memory_usage_alert
% Alexander Schäferdiek
% January 2023
# NAME
memory_usage_alert - Checks available memory and sends out notification via mail. Configuration is done in environment files.\
It's part of **system-helpers**.
# SYNOPSIS
**memory_usage_alert** [CONFIG_FILE (absolute path)]
# DESCRIPTION
**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.
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.\
The following are optional or have reasonable defaults:
- **MEMORY_USAGE_ALERT_THRESHOLD=512** threshold to warn about (in *megabytes*)
You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user.
# EXAMPLE
Create a *$HOME/.memory_usage_alert.conf* and add *MEMORY_USAGE_ALERT_MAIL_ADDRESS="alias@domain.tld"*. Notifications will be delivered to alias@domain.tld. Examples can be found in */usr/share/doc/memory_usage_alert*.
# EXIT VALUES
**0**
: Success
**1**
: Error

View file

@ -0,0 +1,26 @@
% system-helpers(1) system-helpers
% Alexander Schäferdiek
% January 2023
# NAME
system-helpers - Collection of helper systemd services, systemd timers and
shell scripts for common configuration. Designed for use with ArchLinux, although most scripts should work on any distribution.
# DESCRIPTION
**system-helpers** collection provides the following helpers
- 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**)
- restic backup (see */usr/share/doc/system-helpers/restic* for an example *mybackup*)
- checking if docker containers are running (see **man docker_check**)
- batch docker-compose upgrades (see **man docker_compose_update**)
- dynamic dns update (see **man docker_compose_update**)
- memory and disk checks (see **man disk_space_alert** and **man memory_usage_alert**)
- docker housekeeping for removing unused docker containers, volumes and images
- update check for pacman (ArchLinux specific, see **man check_updates**)
Provided systemd services mostly support mail notifications if they have failed
via **systemd_failure_notify**.
See */usr/share/doc/system-helpers* for example configurations which should
be copied inside **$HOME** or **/etc** depending on the helper script.

View file

@ -1,20 +0,0 @@
# system-helpers
system-helpers is a collection of helper systemd services, systemd timers and
shell scripts for common configuration and tasks like
* checking if systemd services and timers are running
* borgmatic backup
* restic backup
* checking if docker containers are running
* batch docker-compose upgrades
* docker housekeeping for removing unused docker containers, volumes and images
* dynamic dns update
* update check for pacman
* memory and disk checks
Provided systemd services mostly support mail notifications if they have failed
via systemd_failure_notify.
See `/usr/share/doc/system-helpers` for example configurations which should
be copied inside $HOME or /etc depending on the helper script.

View file

@ -0,0 +1,34 @@
% systemd_check(1) systemd_check
% Alexander Schäferdiek
% January 2023
# NAME
systemd_check - Checks a set of systemd services, targets, mounts of timers, and notifies if their state is not up and running. Configuration is done in environment files.\
It's part of **system-helpers**.
# SYNOPSIS
**systemd_check** [CONFIG_FILE (absolute path)]
# 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.
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.
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_MAIL_ENABLED=false** enables or disables sending mail notifications.
- **SYSTEMD_CHECK_MAIL_ADDRESS=""** which requires *mail.rc* to be configured and '*mailx*' command has be available.\
You can copy this script to */usr/local/bin* and use create a custom **CONFIG_FILE** as user.
# EXAMPLE
Create a *$HOME/.systemd_check.conf* and add *SYSTEMD_CHECK_MAIL_ADDRESS="alias@domain.tld"*. Notifications will be delivered to alias@domain.tld. Examples can be found in */usr/share/doc/systemd_check*.
# EXIT VALUES
**0**
: Success
**1**
: Error

View file

@ -0,0 +1,42 @@
% systemd_failure_notify(1) systemd_failure_notify
% Alexander Schäferdiek
% January 2023
# NAME
systemd_failure_notify - Notifies via mail or gotify when a service has failed. Configuration is done in environment files.\
It's part of **system-helpers**.
# SYNOPSIS
**systemd_failure_notify** [CONFIG_FILE (absolute path)] [service name]
# 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*.
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.
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¸
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:
- SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED="true" // '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/.systemd_failure_notify.conf* and add *SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS="alias@domain.tld"*. Notifications will be delivered to alias@domain.tld. Examples can be found in */usr/share/doc/systemd_failure_notify*.
Then, add **systemd_failure_notify@serviceName** in a systemd unit file in the **OnFailure** directive:
[Unit]\
OnFailure=systemd_failure_notify@%n.service\
# EXIT VALUES
**0**
: Success
**1**
: Error

View file

@ -5,15 +5,7 @@ usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: check_updates [CONFIG_FILE (absolute path)] Usage: check_updates [CONFIG_FILE (absolute path)]
If no CONFIG_FILE is given, HOME/.check_updates.conf or /etc/check_updates.conf is used. This fallback option Sends out update notifications. Please see man check_updates.
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:
- CHECK_UPDATES_MAIL_ADDRESS="" // mail.rc has to be configured
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";

View file

@ -5,19 +5,7 @@ usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: disk_space_alert [CONFIG_FILE (absolute path)] Usage: disk_space_alert [CONFIG_FILE (absolute path)]
If no CONFIG_FILE is given, HOME/.disk_space_alert.conf or /etc/disk_space_alert.conf is used. This fallback option Checks available diskspace for configured **mounts** and sends out a mail if certain limits are reached. Please see man disk_space_alert.
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:
- DISK_SPACE_ALERT_MAIL_ADDRESS="" // mail.rc has to be configured
The following are optional or have reasonable defaults:
- DISK_SPACE_ALERT_THRESHOLD=93 // in percent
- DISK_SPACE_ALERT_MOUNTPOINTS=("/") // array of mountpoints
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";

View file

@ -1,43 +0,0 @@
#!/usr/bin/env bash
# https://github.com/spherex-dev/docker-backup-volume
# creates a backup of the docker volume
while [ $# -gt 0 ]; do
case "$1" in
-v|-volume|--volume)
volume="$2"
;;
-p|-prefix|--prefix)
prefix="$2"
;;
-h|-help|--help)
printf "--volume the name of the volume\n"
printf "--mount the mount point of the volume\n"
exit 1
;;
*)
printf "***************************\n"
printf "* Error: Invalid argument.*\n"
printf "***************************\n"
exit 1
esac
shift
shift
done
uuid=$(cat /proc/sys/kernel/random/uuid)
if [ ! -d $prefix/$volume ]; then
mkdir -p $prefix/$volume
fi
IMAGE=alpine:latest
docker run \
--mount "type=volume,src=${volume},dst=/data" \
--name $uuid \
$IMAGE
timestamp=$(date +%Y-%m-%d_%H%M%S)
docker cp -a $uuid:/data /tmp/$uuid
tar -C /tmp/$uuid -czf $prefix/$volume/${timestamp}_${volume}.tar.gz .
rm -rf /tmp/$uuid
docker rm $uuid

View file

@ -1,76 +0,0 @@
#!/bin/bash
# https://github.com/spherex-dev/docker-backup-volume
# creates a docker volume from a backup
while [ $# -gt 0 ]; do
case "$1" in
-v|-volume|--volume)
volume="$2"
;;
-p|-prefix|--prefix)
prefix="$2"
;;
-n|-volume-name|--volume-name)
volume_name="$2"
;;
-s|-snapshot|--snapshot)
snapshot="$2"
;;
-h|-help|--help)
printf "--volume the backup name of the volume\n"
printf "--volume-name (optional) create the backup as this volume name\n"
printf "--prefix the storage prefix of the backup location"
exit 1
;;
*)
printf "***************************\n"
printf "* Error: Invalid argument.*\n"
printf "***************************\n"
exit 1
esac
shift
shift
done
if [ -z "$volume_name" ]; then
volume_name=$volume
fi
volume_exists=$(docker volume ls | grep -q $volume_name)
if [ $volume_exists ]; then
printf "***********************************\n"
printf "Error: volume $volume_name exists. \n"
printf "Please delete before proceeding \n"
printf "***********************************\n"
exit 1
fi
if [ -z "$snapshot" ]; then
snapshot=$(ls -At ${prefix}/${volume}/ | tail -n 1)
fi
if [ -z "$snapshot" ]; then
printf "**********************************\n"
printf "* Error: Unable to find snapshot.*\n"
printf "**********************************\n"
exit 1
else
echo "creating from snapshot: ${snapshot}"
fi
uuid=$(cat /proc/sys/kernel/random/uuid)
cwd=$(pwd)
IMAGE=alpine:latest
docker run \
--mount "type=volume,src=${volume_name},dst=/data" \
--name $uuid \
$IMAGE
mkdir /tmp/$uuid
tar -xf $prefix/$volume/$snapshot -C /tmp/$uuid
cd /tmp/$uuid
docker cp -a . $uuid:/data
docker rm $uuid
cd $cwd

View file

@ -5,18 +5,7 @@ usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: docker_check [CONFIG_FILE (absolute path)] Usage: docker_check [CONFIG_FILE (absolute path)]
If no CONFIG_FILE is given, HOME/.docker_check.conf or /etc/docker_check.conf is used. This fallback option Checks a list of docker containers and notifies if their state is not up and running. Please see man docker_check.
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 optional or have reasonable defaults:
DOCKER_CHECK_LIST_FILE="HOME/.docker_check.list" // the list file (output current running to file: docker ps --format '{{.Names}}' >> $HOME/.docker_check.list)
DOCKER_CHECK_NOTIFY_LEVELS=("UNKNOWN" "WARNING" "CRITICAL") // when to notify/output/send mail. possible: "UNKNOWN" "WARNING" "CRITICAL" "INFO", should at least be ()
DOCKER_CHECK_MAIL_ENABLED=false // send email (address has to be set), values: false|true
DOCKER_CHECK_MAIL_ADDRESS="" // mail.rc has to be configured
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";

View file

@ -5,20 +5,7 @@ usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: docker_compose_update [CONFIG_FILE (absolute path)] Usage: docker_compose_update [CONFIG_FILE (absolute path)]
If no CONFIG_FILE is given, HOME/.docker_compose_update.conf or /etc/docker_compose_update.conf is used. This fallback option An utility to batch update *docker-compose* deployments residing in sub folders. Please see man docker_compose_update.
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:
- DOCKER_COMPOSE_UPDATE_BASEDIR="/root/deployments" // where all docker stacks are located in their own sub-folders
- DOCKER_COMPOSE_UPDATE_IGNORES=("mailcow") // folder names which will be ignored and not be updated, at least () is required
- DOCKER_COMPOSE_UPDATE_COMMANDS[aDirectoryName]="./callFancyScriptInDirectory" // use another command to update, multiple possible.
Example: accessor has to match the folder, e.g. <baseDir>/aDirectoryName will use command "./callFancyScriptInDirectory" when changing directory into it.
- DOCKER_COMPOSE_UPDATE_COMMAND="sudo docker-compose down; sudo docker-compose pull; sudo docker-compose up -d;" // the default update command for deployments
- DOCKER_COMPOSE_UPDATE_FAIL_ON_UPDATE_ERROR="false" // if set to true, script fails if at least one update procedure failed
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";

View file

@ -5,22 +5,7 @@ set -e;
usage() { usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: dynv6 [CONFIG_FILE (absolute path)] Usage: dynv6 [CONFIG_FILE (absolute path)]
updates dynv6 (an external service) and notifies about changes of IP addresses. Please see man dynv6.
If no CONFIG_FILE is given, HOME/.dynv6.conf or /etc/dynv6.conf is used. This fallback option
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:
- DYNV6_MAIL_ENABLED= // if notify via mail
- DYNV6_MAIL_ADDRESS="" // (optional) mail.rc has to be configured
- DYNV6_TOKEN="" // the dynv6 token
- DYNV6_HOSTNAME="" // the dynv6 hostname
- DYNV6_IPV4_ENABLED=true // if should update ipv4
- DYNV6_IPV6_ENABLED=true // if should update ipv6
- DYNV6_IPV6_INTERFACE=eth0 // which interface to track, be sure that Privacy Extensions are disabled
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";

View file

@ -5,18 +5,7 @@ usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: memory_usage_alert [CONFIG_FILE (absolute path)] Usage: memory_usage_alert [CONFIG_FILE (absolute path)]
If no CONFIG_FILE is given, HOME/.memory_usage_alert.conf or /etc/memory_usage_alert.conf is used. This fallback option Checks available memory and sends out notification via mail. Please see man memory_usage_alert.
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:
- MEMORY_USAGE_ALERT_MAIL_ADDRESS="" // mail.rc has to be configured
The following are optional or have reasonable defaults:
- MEMORY_USAGE_ALERT_THRESHOLD=128 // threshold to warn about (in megabytes)
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";

View file

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
HOSTNAME=$(hostname) HOSTNAME=$(hostname)
echo "$SMARTD_MESSAGE" | mail -s "[smartd $HOSTNAME] $SMARTD_FAILTYPE" "$SMARTD_ADDRESS" echo "$SMARTD_MESSAGE" | mail -s "[smartd $HOSTNAME] $SMARTD_FAILTYPE" "$SMARTD_ADDRESS"
wall "$SMARTD_MESSAGE" wall "$SMARTD_MESSAGE"

View file

@ -5,21 +5,8 @@ usage() {
SYSTEMD_CHECK_USAGE=$(cat <<EOF SYSTEMD_CHECK_USAGE=$(cat <<EOF
Usage: systemd_check.sh [CONFIG_FILE (absolute path)] Usage: systemd_check.sh [CONFIG_FILE (absolute path)]
Checks if specific systemd SYSTEMD_CHECK_SERVICES are running and optionally sends a mail. 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.
If no CONFIG_FILE is given, HOME/.systemd_check.conf or /etc/systemd_check.conf is used. This fallback option
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:
- SYSTEMD_CHECK_LIST_FILE="HOME/.systemd_check.list" // path to file to list services to check, one per line
The following are optional or have reasonable defaults:
- SYSTEMD_CHECK_MAIL_ENABLED=false // send email (SYSTEMD_CHECK_MAIL_ADDRESS has to be set to true)? false|true
- SYSTEMD_CHECK_MAIL_ADDRESS="" // mail.rc has to be configured
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 "$SYSTEMD_CHECK_USAGE"; echo "$SYSTEMD_CHECK_USAGE";

View file

@ -3,26 +3,9 @@
# usage # usage
usage() { usage() {
USAGE=$(cat <<EOF USAGE=$(cat <<EOF
Usage: systemd_failure_notify [CONFIG_FILE (absolute path)] Usage: systemd_failure_notify [CONFIG_FILE (absolute path)] <service>
Notifies via mail when a service has failed. You need to place the following in the service which should be checked: Sends out notifications for failed services. Please see man systemd_failure_notify.
[Unit]
Description=...
OnFailure=systemd_failure_notify@%n.service
...
You should place the <scriptname>'s service into systemd's user and systemd's system folder so it can be used by global and user services.
If no CONFIG_FILE is given, HOME/.systemd_failure_notify.conf or /etc/systemd_failure_notify.conf is used. This fallback option
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:
- SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS="" // mail.rc has to be configured
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";
@ -40,8 +23,12 @@ fi
SYSTEMD_FAILURE_NOTFY_HOSTNAME=$(hostname) SYSTEMD_FAILURE_NOTFY_HOSTNAME=$(hostname)
SYSTEMD_FAILURE_NOTFY_USER=$(whoami) SYSTEMD_FAILURE_NOTFY_USER=$(whoami)
SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED="true";
SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS=""; SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS="";
SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED="false";
# check for config file # check for config file
apply_config() { apply_config() {
local config=$1; local config=$1;
@ -59,6 +46,19 @@ apply_config() {
set +a; set +a;
} }
check_requirements() {
local mailEnabled=$1;
local gotifyEnabled=$2;
if [[ "${mailEnabled}" == "true" ]]; then
type mailx &> /dev/null || echo "Requiring 'mailx' but it's not installed"; exit 1
fi
if [[ "${gotifyEnabled}" == "true" ]]; then
type gotify &> /dev/null || echo "Requiring 'gotify' but it's not installed"; exit 1
fi
}
source_config() { source_config() {
local config=$1; local config=$1;
local configFallback=$2; local configFallback=$2;
@ -80,7 +80,27 @@ source_config() {
fi fi
} }
source_config "$2" "$HOME/.systemd_failure_notify.conf" "/etc/systemd_failure_notify.conf" source_config "$2" "$HOME/.systemd_failure_notify.conf" "/etc/systemd_failure_notify.conf"
check_requirements "$SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED" "$SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED"
SUBJECT="[systemd $SYSTEMD_FAILURE_NOTFY_HOSTNAME for $SYSTEMD_FAILURE_NOTFY_USER] $SYSTEMD_FAILURE_NOTFY_SERVICE RUN FAILED" SUBJECT="[systemd $SYSTEMD_FAILURE_NOTFY_HOSTNAME for $SYSTEMD_FAILURE_NOTFY_USER] $SYSTEMD_FAILURE_NOTFY_SERVICE RUN FAILED"
MESSAGE="$SYSTEMD_FAILURE_NOTFY_SERVICE run failed" MESSAGE="$SYSTEMD_FAILURE_NOTFY_SERVICE run failed"
if [[ "${SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED}" == "true" ]]; then
echo "$MESSAGE"|mailx -Ssendwait -s "$SUBJECT" "$SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS"; echo "$MESSAGE"|mailx -Ssendwait -s "$SUBJECT" "$SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS";
echo "Sent notifiction via mail"
else
echo "Sending notifictions via mail is disabled"
fi
if [[ "${SYSTEMD_FAILURE_NOTIFY_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

@ -0,0 +1,66 @@
.\" 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 "check_updates" "1" "January 2023" "check_updates" ""
.hy
.SH NAME
.PP
check_updates - Notifies about available updates.
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]check_updates\f[R] [CONFIG_FILE (absolute path)]
.SH DESCRIPTION
.PP
\f[B]check_updates\f[R] checks for available updates using
\f[I]checkupdates\f[R] and sends out a mail.
It comes with systemd services.
.PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]check_updates\f[R] tries
to read from \f[I]$HOME/.check_updates.conf\f[R] and
\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
configuration file.
.PP
The following are at least required for the script to work:
.PD 0
.P
.PD
- \f[B]CHECK_UPDATES_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.
.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/.check_updates.conf\f[R] and add
\f[I]CHECK_UPDATES_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/check_updates\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

@ -0,0 +1,75 @@
.\" 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 "disk_space_alert" "1" "January 2023" "disk_space_alert" ""
.hy
.SH NAME
.PP
disk_space_alert - Checks available disk space and sends out
notification via mail.
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]disk_space_alert\f[R] [CONFIG_FILE (absolute path)]
.SH DESCRIPTION
.PP
\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.
It comes with systemd services.
.PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]disk_space_alert\f[R]
tries to read from \f[I]$HOME/.disk_space_alert.conf\f[R] and
\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
configuration file.
.PP
The following are at least required for the script to work:
.PD 0
.P
.PD
- \f[B]DISK_SPACE_ALERT_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.
.PD 0
.P
.PD
.PP
The following are optional or have reasonable defaults: -
\f[B]DISK_SPACE_ALERT_THRESHOLD=93\f[R] in percentage -
\f[B]DISK_SPACE_ALERT_MOUNTPOINTS=(\[lq]/\[rq])\f[R] is an array of
mountpoints
.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/.disk_space_alert.conf\f[R] and add
\f[I]DISK_SPACE_ALERT_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/disk_space_alert\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

@ -0,0 +1,87 @@
.\" 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 "docker_check" "1" "January 2023" "docker_check" ""
.hy
.SH NAME
.PP
docker_check - Checks a set of docker containers and notifies if their
state is not up and running.
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]docker_check\f[R] [CONFIG_FILE (absolute path)]
.SH DESCRIPTION
.PP
\f[B]docker_check\f[R] checks a list of docker containers and notifies
if their state is not up and running.
It comes with systemd services.
.PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]docker_check\f[R] tries to
read from \f[I]$HOME/.docker_check.conf\f[R] and
\f[I]/etc/docker_check.conf\f[R] for configuration.
It will exit with a non-zero exit code if it cannot find an proper
configuration file.
.PP
The following are at least required for the script to work:
.PD 0
.P
.PD
- \f[B]DOCKER_CHECK_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.
.PD 0
.P
.PD
- \f[B]DOCKER_CHECK_LIST_FILE=\[lq]$HOME/.docker_check.list\[rq]\f[R]
which lists to be checked docker containers separated by lines.
Provide their container name, e.g.\ output of current running docker
containers piped into the file: \f[I]docker ps \[en]format `{{.Names}}'
>> $HOME/.docker_check.list\f[R]).
.PD 0
.P
.PD
- \f[B]DOCKER_CHECK_NOTIFY_LEVELS=(\[lq]UNKNOWN\[rq] \[lq]WARNING\[rq]
\[lq]CRITICAL\[rq])\f[R] determines when to notify/output/send mail.
Possible: \f[I]\[lq]UNKNOWN\[rq]\f[R] \f[I]\[lq]WARNING\[rq]\f[R]
\f[I]\[lq]CRITICAL\[rq]\f[R] \f[I]\[lq]INFO\[rq]\f[R].
.PD 0
.P
.PD
- \f[B]DOCKER_CHECK_MAIL_ENABLED=false\f[R] enables or disables sending
mail notifications.
.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/.docker_check.conf\f[R] and add
\f[I]DOCKER_CHECK_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/docker_check\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

@ -0,0 +1,97 @@
.\" 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 "docker_compose_update" "1" "January 2023" "docker_compose_update" ""
.hy
.SH NAME
.PP
docker_compose_update - An utility to batch update
\f[I]docker-compose\f[R] deployments residing in sub folders.
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]docker_compose_update\f[R] [CONFIG_FILE (absolute path)]
.SH DESCRIPTION
.PP
\f[B]docker_compose_update\f[R] is an utility to batch update
\f[I]docker-compose\f[R] deployments residing in sub folders of a
\f[B]base directory\f[R], e.g \f[I]/root/deployments/\f[R] having
different sub folders, each having a \f[I]docker-compose\f[R] deployment
in it.
.PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]docker_compose_update\f[R]
tries to read from \f[I]$HOME/.docker_compose_update.conf\f[R] and
\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
configuration file.
.PP
The following are at least required for the script to work:
.PD 0
.P
.PD
- \f[B]DOCKER_COMPOSE_UPDATE_BASEDIR=\[lq]/root/deployments\[rq]\f[R]
determines the \f[B]base directory\f[R] where all
\f[I]docker-compose\f[R] stacks are located in their own sub-folders.
.PD 0
.P
.PD
- \f[B]DOCKER_COMPOSE_UPDATE_IGNORES=(\[lq]mailcow\[rq])\f[R] folder
names which will be ignored and not be updated, at least () is required.
.PD 0
.P
.PD
-
\f[B]DOCKER_COMPOSE_UPDATE_COMMANDS[aDirectoryName]=\[lq]./callFancyScriptInDirectory\[rq]\f[R]
to explicitly define update command for one sub folder
\f[I]aDirectoryName\f[R].
This is a map and defining different instructions for multiple locations
is possible.
Example: accessor has to match the folder,
e.g.\ \f[I]/aDirectoryName\f[R] will use command
\[lq]\f[I]./callFancyScriptInDirectory\[rq]\f[R] when changing directory
into it.
.PD 0
.P
.PD
- \f[B]DOCKER_COMPOSE_UPDATE_COMMAND=\[lq]sudo docker-compose down; sudo
docker-compose pull; sudo docker-compose up -d;\[rq]\f[R] determines the
default update command executed for each deployment.
.PD 0
.P
.PD
- \f[B]DOCKER_COMPOSE_UPDATE_FAIL_ON_UPDATE_ERROR=\[lq]false\[rq]\f[R]
determines if script fails if at least one update procedure failed
.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/.docker_compose_update.conf\f[R] and necessary
configuration.
Examples can be found in \f[I]/usr/share/doc/docker_compose_update\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

@ -0,0 +1,91 @@
.\" 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 "dynv6" "1" "January 2023" "dynv6" ""
.hy
.SH NAME
.PP
dynv6 - Updates dynv6 (an external service) and notifies about changes
of IP addresses.
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]dynv6\f[R] [CONFIG_FILE (absolute path)]
.SH DESCRIPTION
.PP
\f[B]dynv6\f[R] updates dynv6 (an external service) and notifies about
changes of IP addresses.
It comes with systemd services.
.PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]dynv6\f[R] tries to read
from \f[I]$HOME/.dynv6.conf\f[R] and \f[I]/etc/dynv6.conf\f[R] for
configuration.
It will exit with a non-zero exit code if it cannot find an proper
configuration file.
.PP
The following are at least required for the script to work:
.PD 0
.P
.PD
- \f[B]DYNV6_MAIL_ENABLED\f[R] to enable or disable mail notification.
- \f[B]DYNV6_MAIL_ADDRESS\f[R] which requires \f[I]mail.rc\f[R] to be
configured and `\f[I]mailx\f[R]' command has be available.
.PD 0
.P
.PD
- \f[B]DYNV6_TOKEN\f[R] the dynv6 token.
.PD 0
.P
.PD
- \f[B]DYNV6_HOSTNAME\f[R] the dynv6 hostname.
.PD 0
.P
.PD
- \f[B]DYNV6_IPV4_ENABLED\f[R] enable or disable updating IPv4.
.PD 0
.P
.PD
- \f[B]DYNV6_IPV6_ENABLED\f[R] enable or disable updating IPv6.
.PD 0
.P
.PD
- \f[B]DYNV6_IPV6_INTERFACE\f[R] which interface to track, be sure that
Privacy Extensions are disabled.
.PD 0
.P
.PD
.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/.dynv6.conf\f[R] and add
\f[I]DYNV6_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/dynv6\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

@ -0,0 +1,74 @@
.\" 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 "memory_usage_alert" "1" "January 2023" "memory_usage_alert" ""
.hy
.SH NAME
.PP
memory_usage_alert - Checks available memory and sends out notification
via mail.
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]memory_usage_alert\f[R] [CONFIG_FILE (absolute path)]
.SH DESCRIPTION
.PP
\f[B]memory_usage_alert\f[R] checks available memory and sends out a
mail if certain limits are reached.
It comes with systemd services.
.PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]memory_usage_alert\f[R]
tries to read from \f[I]$HOME/.memory_usage_alert.conf\f[R] and
\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
configuration file.
.PP
The following are at least required for the script to work:
.PD 0
.P
.PD
- \f[B]MEMORY_USAGE_ALERT_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.
.PD 0
.P
.PD
.PP
The following are optional or have reasonable defaults: -
\f[B]MEMORY_USAGE_ALERT_THRESHOLD=512\f[R] threshold to warn about (in
\f[I]megabytes\f[R])
.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/.memory_usage_alert.conf\f[R] and add
\f[I]MEMORY_USAGE_ALERT_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/memory_usage_alert\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

@ -1,27 +1,62 @@
.\" generated with Ronn/v0.7.3 .\" Automatically generated by Pandoc 2.19.2
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\"
system\-helpers is a collection of helper systemd services, systemd timers and shell scripts for common configuration and tasks like .\" Define V font for inline verbatim, using C font in formats
. .\" that render this, and otherwise B font.
.IP "" 4 .ie "\f[CB]x\f[]"x" \{\
. . ftr V B
.nf . ftr VI BI
. ftr VB B
* checking if systemd services and timers are running . ftr VBI BI
* borgmatic backup .\}
* restic backup .el \{\
* checking if docker containers are running . ftr V CR
* batch docker\-compose upgrades . ftr VI CI
* docker housekeeping for removing unused docker containers, volumes and images . ftr VB CB
* dynamic dns update . ftr VBI CBI
* update check for pacman .\}
* memory and disk checks .TH "system-helpers" "1" "January 2023" "system-helpers" ""
. .hy
.fi .SH NAME
. .PP
.IP "" 0 system-helpers - Collection of helper systemd services, systemd timers
. and shell scripts for common configuration.
.P Designed for use with ArchLinux, although most scripts should work on
Provided systemd services mostly support mail notifications if they have failed via systemd_failure_notify\. any distribution.
. .SH DESCRIPTION
.P .PP
See \fB/usr/share/doc/system\-helpers\fR for example configurations which should be copied inside $HOME or /etc depending on the helper script\. \f[B]system-helpers\f[R] collection provides the following helpers
.IP \[bu] 2
checking if systemd services and timers are running (see \f[B]man
systemd_check\f[R])
.IP \[bu] 2
borgmatic backup (see exposed systemd services \f[I]borgmatic\[at]\f[R]
which require a valid \f[I]borgmatic.yml\f[R] file in
\f[I]/etc/borgmatic\f[R] or your \f[B]$HOME/.config/borgmatic\f[R])
.IP \[bu] 2
restic backup (see \f[I]/usr/share/doc/system-helpers/restic\f[R] for an
example \f[I]mybackup\f[R])
.IP \[bu] 2
checking if docker containers are running (see \f[B]man
docker_check\f[R])
.IP \[bu] 2
batch docker-compose upgrades (see \f[B]man docker_compose_update\f[R])
.IP \[bu] 2
dynamic dns update (see \f[B]man docker_compose_update\f[R])
.IP \[bu] 2
memory and disk checks (see \f[B]man disk_space_alert\f[R] and \f[B]man
memory_usage_alert\f[R])
.IP \[bu] 2
docker housekeeping for removing unused docker containers, volumes and
images
.IP \[bu] 2
update check for pacman (ArchLinux specific, see \f[B]man
check_updates\f[R])
.PP
Provided systemd services mostly support mail notifications if they have
failed via \f[B]systemd_failure_notify\f[R].
.PP
See \f[I]/usr/share/doc/system-helpers\f[R] for example configurations
which should be copied inside \f[B]$HOME\f[R] or \f[B]/etc\f[R]
depending on the helper script.
.SH AUTHORS
Alexander Sch\[:a]ferdiek.

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 "systemd_check" "1" "January 2023" "systemd_check" ""
.hy
.SH NAME
.PP
systemd_check - Checks a set of systemd services, targets, mounts of
timers, and notifies if their state is not up and running.
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]systemd_check\f[R] [CONFIG_FILE (absolute path)]
.SH DESCRIPTION
.PP
\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.
It comes with systemd services.
.PP
If no \f[I]CONFIG_FILE\f[R] is provided, \f[B]systemd_check\f[R] tries
to read from \f[I]$HOME/.systemd_check.conf\f[R] and
\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
configuration file.
.PP
The following are at least required for the script to work:
.PD 0
.P
.PD
- \f[B]SYSTEMD_CHECK_LIST_FILE=\[lq]$HOME/.systemd_check.list\[rq]\f[R]
which lists to be checked systemd services, timers or targets separated
by lines.
.PD 0
.P
.PD
- \f[B]SYSTEMD_CHECK_MAIL_ENABLED=false\f[R] enables or disables sending
mail notifications.
- \f[B]SYSTEMD_CHECK_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.
.PD 0
.P
.PD
.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/.systemd_check.conf\f[R] and add
\f[I]SYSTEMD_CHECK_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/systemd_check\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

@ -0,0 +1,94 @@
.\" 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 "systemd_failure_notify" "1" "January 2023" "systemd_failure_notify" ""
.hy
.SH NAME
.PP
systemd_failure_notify - Notifies via mail or gotify when a service has
failed.
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]systemd_failure_notify\f[R] [CONFIG_FILE (absolute path)] [service
name]
.SH DESCRIPTION
.PP
\f[B]systemd_failure_notify\f[R] executes \f[I]mailx\f[R] or
\f[I]gotify\f[R] to send out notifications.
It comes with systemd services.
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].
.PP
If no \f[I]CONFIG_FILE\f[R] is provided,
\f[B]systemd_failure_notify\f[R] tries to read from
\f[I]$HOME/.systemd_failure_notify.conf\f[R] and
\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
configuration file.
.PP
The following are at least required for the script to work:
.PD 0
.P
.PD
- \f[B]SYSTEMD_FAILURE_NOTIFY_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]
.PP
By default, \f[B]SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED\f[R] is set to
\f[B]true\f[R].
Set it to \f[B]false\f[R] to use \f[I]gotify\f[R] only.\[ac]
.PP
The following are optional and integrate gotify-cli to send
notifications, it defaults to false: -
SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED=\[lq]true\[rq] // `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/.systemd_failure_notify.conf\f[R] and add
\f[I]SYSTEMD_FAILURE_NOTIFY_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/systemd_failure_notify\f[R].
.PP
Then, add \f[B]systemd_failure_notify\[at]serviceName\f[R] in a systemd
unit file in the \f[B]OnFailure\f[R] directive:
.PP
[Unit]
.PD 0
.P
.PD
OnFailure=systemd_failure_notify\[at]%n.service
.PD 0
.P
.PD
.SH EXIT VALUES
.TP
\f[B]0\f[R]
Success
.TP
\f[B]1\f[R]
Error
.SH AUTHORS
Alexander Sch\[:a]ferdiek.