Fail properly in all scripts when required commands are not available
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4d47fd31db
commit
71977c9dca
13 changed files with 100 additions and 11 deletions
|
@ -13,11 +13,6 @@ EOF
|
||||||
|
|
||||||
set -e;
|
set -e;
|
||||||
|
|
||||||
HOSTNAME=$(hostname)
|
|
||||||
DISK_SPACE_ALERT_MAIL_ADDRESS="";
|
|
||||||
DISK_SPACE_ALERT_THRESHOLD=93
|
|
||||||
DISK_SPACE_ALERT_MOUNTPOINTS=("/")
|
|
||||||
|
|
||||||
# check for config file
|
# check for config file
|
||||||
apply_config() {
|
apply_config() {
|
||||||
local config=$1;
|
local config=$1;
|
||||||
|
@ -55,7 +50,20 @@ source_config() {
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_required() {
|
||||||
|
type hostname &> /dev/null || { echo "Requiring 'hostname' but it's not installed"; exit 1; }
|
||||||
|
type mailx &> /dev/null || { echo "Requiring 'mailx' 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"
|
source_config "$1" "$HOME/.disk_space_alert.conf" "/etc/disk_space_alert.conf"
|
||||||
|
check_required
|
||||||
|
|
||||||
|
HOSTNAME=$(hostname)
|
||||||
|
DISK_SPACE_ALERT_MAIL_ADDRESS="";
|
||||||
|
DISK_SPACE_ALERT_THRESHOLD=93
|
||||||
|
DISK_SPACE_ALERT_MOUNTPOINTS=("/")
|
||||||
|
|
||||||
for point in "${DISK_SPACE_ALERT_MOUNTPOINTS[@]}"
|
for point in "${DISK_SPACE_ALERT_MOUNTPOINTS[@]}"
|
||||||
do
|
do
|
||||||
|
|
|
@ -13,7 +13,6 @@ EOF
|
||||||
|
|
||||||
set -e;
|
set -e;
|
||||||
|
|
||||||
HOSTNAME=$(hostname)
|
|
||||||
DOCKER_CHECK_LIST_FILE="$HOME/.docker_check.list"
|
DOCKER_CHECK_LIST_FILE="$HOME/.docker_check.list"
|
||||||
DOCKER_CHECK_GLOBAL_LIST_FILE="/etc/docker_check.list"
|
DOCKER_CHECK_GLOBAL_LIST_FILE="/etc/docker_check.list"
|
||||||
DOCKER_CHECK_NOTIFY_LEVELS=("UNKNOWN" "WARNING" "CRITICAL")
|
DOCKER_CHECK_NOTIFY_LEVELS=("UNKNOWN" "WARNING" "CRITICAL")
|
||||||
|
@ -58,7 +57,17 @@ source_config() {
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_required() {
|
||||||
|
type hostname &> /dev/null || { echo "Requiring 'hostname' but it's not installed"; exit 1; }
|
||||||
|
type mailx &> /dev/null || { echo "Requiring 'mailx' 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"
|
source_config "$1" "$HOME/.docker_check.conf" "/etc/docker_check.conf"
|
||||||
|
check_required
|
||||||
|
|
||||||
|
HOSTNAME=$(hostname)
|
||||||
|
|
||||||
listFileToUse=""
|
listFileToUse=""
|
||||||
if [[ -f "$DOCKER_CHECK_LIST_FILE" ]]; then
|
if [[ -f "$DOCKER_CHECK_LIST_FILE" ]]; then
|
||||||
|
|
|
@ -67,6 +67,8 @@ check_required() {
|
||||||
echo "DOCKER_COMPOSE_UPDATE_COMMAND is required"
|
echo "DOCKER_COMPOSE_UPDATE_COMMAND is required"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
type docker-compose &> /dev/null || { echo "Requiring 'docker-compose' but it's not installed"; exit 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
# check requirements
|
# check requirements
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
check_required() {
|
||||||
|
type docker &> /dev/null || { echo "Requiring 'docker' but it's not installed"; exit 1; }
|
||||||
|
type yes &> /dev/null || { echo "Requiring 'yes' but it's not installed"; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
check_required
|
||||||
|
|
||||||
echo "Doing docker housekeeping for containers, images and volumes";
|
echo "Doing docker housekeeping for containers, images and volumes";
|
||||||
|
|
||||||
yes | docker container prune
|
yes | docker container prune
|
||||||
|
|
|
@ -82,6 +82,12 @@ check_required() {
|
||||||
echo "DYNV6_HOSTNAME is required"
|
echo "DYNV6_HOSTNAME is required"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
type hostname &> /dev/null || { echo "Requiring 'hostname' but it's not installed"; exit 1; }
|
||||||
|
type mailx &> /dev/null || { echo "Requiring 'mailx' but it's not installed"; exit 1; }
|
||||||
|
type ip &> /dev/null || { echo "Requiring 'ip' but it's not installed"; exit 1; }
|
||||||
|
type grep &> /dev/null || { echo "Requiring 'grep' but it's not installed"; exit 1; }
|
||||||
|
type curl &> /dev/null || { echo "Requiring 'curl' but it's not installed"; exit 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
# check requirements
|
# check requirements
|
||||||
|
|
|
@ -13,8 +13,6 @@ EOF
|
||||||
|
|
||||||
set -e;
|
set -e;
|
||||||
|
|
||||||
HOSTNAME=$(hostname)
|
|
||||||
SUBJECT="[memory $HOSTNAME] memory is low"
|
|
||||||
MEMORY_USAGE_ALERT_MAIL_ADDRESS="";
|
MEMORY_USAGE_ALERT_MAIL_ADDRESS="";
|
||||||
MEMORY_USAGE_ALERT_THRESHOLD=512;
|
MEMORY_USAGE_ALERT_THRESHOLD=512;
|
||||||
|
|
||||||
|
@ -56,7 +54,17 @@ source_config() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_required() {
|
||||||
|
type hostname &> /dev/null || { echo "Requiring 'hostname' but it's not installed"; exit 1; }
|
||||||
|
type mailx &> /dev/null || { echo "Requiring 'mailx' 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"
|
source_config "$1" "$HOME/.memory_usage_alert.conf" "/etc/memory_usage_alert.conf"
|
||||||
|
check_required
|
||||||
|
|
||||||
|
HOSTNAME=$(hostname)
|
||||||
|
SUBJECT="[memory $HOSTNAME] memory is low"
|
||||||
|
|
||||||
# DO NOT TOUCH BELOW
|
# DO NOT TOUCH BELOW
|
||||||
total=$(free -mt | grep Total | awk '{print $2}')
|
total=$(free -mt | grep Total | awk '{print $2}')
|
||||||
|
|
|
@ -6,6 +6,13 @@
|
||||||
# - align with umask 022 (755 on folders, 644 on files)
|
# - align with umask 022 (755 on folders, 644 on files)
|
||||||
# - keep +x flag for already executable files if enabled (default)
|
# - keep +x flag for already executable files if enabled (default)
|
||||||
|
|
||||||
|
check_required() {
|
||||||
|
type find &> /dev/null || { echo "Requiring 'find' but it's not installed"; exit 1; }
|
||||||
|
type chmod &> /dev/null || { echo "Requiring 'chmod' but it's not installed"; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
check_required
|
||||||
|
|
||||||
DIR="$1"
|
DIR="$1"
|
||||||
KEEP_EXECUTABLE_FILES="$2"
|
KEEP_EXECUTABLE_FILES="$2"
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,13 @@
|
||||||
# - keep +x flag for already executable files if enabled (default, otherwise set to no)
|
# - keep +x flag for already executable files if enabled (default, otherwise set to no)
|
||||||
# - set 700 (only allow owner to go into directory)
|
# - set 700 (only allow owner to go into directory)
|
||||||
|
|
||||||
|
check_required() {
|
||||||
|
type find &> /dev/null || { echo "Requiring 'find' but it's not installed"; exit 1; }
|
||||||
|
type chmod &> /dev/null || { echo "Requiring 'chmod' but it's not installed"; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
check_required
|
||||||
|
|
||||||
DIR="$1"
|
DIR="$1"
|
||||||
KEEP_EXECUTABLE_FILES="$2"
|
KEEP_EXECUTABLE_FILES="$2"
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ EOF
|
||||||
|
|
||||||
set -e;
|
set -e;
|
||||||
|
|
||||||
HOSTNAME=$(hostname)
|
|
||||||
SMARTCTL_TESTS_LONG_MAIL_ADDRESS="";
|
SMARTCTL_TESTS_LONG_MAIL_ADDRESS="";
|
||||||
SMARTCTL_TESTS_LONG_DEVICES=(sda)
|
SMARTCTL_TESTS_LONG_DEVICES=(sda)
|
||||||
|
|
||||||
|
@ -63,8 +62,17 @@ source_config() {
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_required() {
|
||||||
|
type hostname &> /dev/null || { echo "Requiring 'hostname' but it's not installed"; exit 1; }
|
||||||
|
type mailx &> /dev/null || { echo "Requiring 'mailx' 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"
|
source_config "$1" "$HOME/.smartctl_tests_long.conf" "/etc/smartctl_tests_long.conf"
|
||||||
|
|
||||||
|
HOSTNAME=$(hostname)
|
||||||
|
|
||||||
echo "Starting long tests for ...";
|
echo "Starting long tests for ...";
|
||||||
|
|
||||||
for d in "${SMARTCTL_TESTS_LONG_DEVICES[@]}"; do
|
for d in "${SMARTCTL_TESTS_LONG_DEVICES[@]}"; do
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
check_required() {
|
||||||
|
type hostname &> /dev/null || { echo "Requiring 'hostname' but it's not installed"; exit 1; }
|
||||||
|
type mailx &> /dev/null || { echo "Requiring 'mailx' but it's not installed"; exit 1; }
|
||||||
|
type wall &> /dev/null || { echo "Requiring 'wall' but it's not installed"; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
check_required
|
||||||
|
|
||||||
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"
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
set -e;
|
set -e;
|
||||||
|
|
||||||
|
check_required() {
|
||||||
|
type openssl &> /dev/null || { echo "Requiring 'openssl' but it's not installed"; exit 1; }
|
||||||
|
type ssh-keygen &> /dev/null || { echo "Requiring 'ssh-keygen' but it's not installed"; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
name=$1;
|
name=$1;
|
||||||
encryption=$2;
|
encryption=$2;
|
||||||
|
|
||||||
|
@ -14,5 +19,7 @@ if [[ -z ${encryption} ]]; then
|
||||||
encryption=4096;
|
encryption=4096;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
check_required
|
||||||
|
|
||||||
openssl genrsa -out "${name}" "${encryption}"
|
openssl genrsa -out "${name}" "${encryption}"
|
||||||
ssh-keygen -y -f "${name}" > "${name}.pub"
|
ssh-keygen -y -f "${name}" > "${name}.pub"
|
|
@ -19,8 +19,6 @@ SYSTEMD_CHECK_LIST_FILE="$HOME/.systemd_check.list"
|
||||||
SYSTEMD_CHECK_GLOBAL_LIST_FILE="/etc/systemd_check.list"
|
SYSTEMD_CHECK_GLOBAL_LIST_FILE="/etc/systemd_check.list"
|
||||||
SYSTEMD_CHECK_MAIL_ENABLED=fase
|
SYSTEMD_CHECK_MAIL_ENABLED=fase
|
||||||
SYSTEMD_CHECK_MAIL_ADDRESS=""
|
SYSTEMD_CHECK_MAIL_ADDRESS=""
|
||||||
SYSTEMD_CHECK_HOSTNAME=$(hostname)
|
|
||||||
SYSTEMD_CHECK_USER=$(whoami)
|
|
||||||
SYSTEMD_CHECK_SERVICES=()
|
SYSTEMD_CHECK_SERVICES=()
|
||||||
|
|
||||||
# check for config file
|
# check for config file
|
||||||
|
@ -60,7 +58,19 @@ source_config() {
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_required() {
|
||||||
|
type hostname &> /dev/null || { echo "Requiring 'hostname' but it's not installed"; exit 1; }
|
||||||
|
type mailx &> /dev/null || { echo "Requiring 'mailx' but it's not installed"; exit 1; }
|
||||||
|
type whoami &> /dev/null || { echo "Requiring 'whoami' 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"
|
source_config "$1" "$HOME/.systemd_check.conf" "/etc/systemd_check.conf"
|
||||||
|
check_required
|
||||||
|
|
||||||
|
SYSTEMD_CHECK_HOSTNAME=$(hostname)
|
||||||
|
SYSTEMD_CHECK_USER=$(whoami)
|
||||||
|
|
||||||
listFileToUse=""
|
listFileToUse=""
|
||||||
if [[ -f "$SYSTEMD_CHECK_LIST_FILE" ]]; then
|
if [[ -f "$SYSTEMD_CHECK_LIST_FILE" ]]; then
|
||||||
|
|
|
@ -58,6 +58,8 @@ check_requirements() {
|
||||||
if [[ "${gotifyEnabled}" == "true" ]]; then
|
if [[ "${gotifyEnabled}" == "true" ]]; then
|
||||||
type gotify &> /dev/null || { echo "Requiring 'gotify' but it's not installed"; exit 1; }
|
type gotify &> /dev/null || { echo "Requiring 'gotify' but it's not installed"; exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
type whoami &> /dev/null || { echo "Requiring 'whoami' but it's not installed"; exit 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
source_config() {
|
source_config() {
|
||||||
|
|
Loading…
Reference in a new issue