Many small updates to various scripts.

deleted:    cronjob-update-packages-list.new
deleted:    cronjob-updatedb-mirrors
renamed:    rsync-notify-upload -> notify-rsync-upload
modified:   colour-changelog
modified:   cronjob-clean-php
modified:   cronjob-dehydrated
modified:   cronjob-fix-log-acls
modified:   cronjob-rotate-logs-today-symlink
modified:   cronjob-update-mirrors-search-db
modified:   cronjob-update-packages-list
modified:   cronjob-warn-git-status
modified:   cronjob-warn-smtp-queue
modified:   do-backup
modified:   dovecot-service-checksuspended
modified:   firewall-initscript
modified:   git-auto-merge
modified:   mirror
modified:   mirror-new-slackware-release.gpg
modified:   mirror-wrapper
modified:   notify-rsync-upload
modified:   sbosrcarch-wrapper
This commit is contained in:
Darren 'Tadgy' Austin 2026-05-22 00:27:36 +01:00
commit 041ebf1b1a
21 changed files with 83 additions and 181 deletions

View file

@ -11,7 +11,7 @@
# Defaults.
CHANGELOG_URL="https://ftp.osuosl.org/pub/slackware/slackware64-current/ChangeLog.txt"
# CHANGELOG_URL="https://slackware.uk/slackware/slackware64-current/ChangeLog.txt"
REFRESH_INTERVAL="600"
REFRESH_INTERVAL="300"
MAX_LINES="10000000" # Should cover the whole ChangeLog.
# Colourise at most MAX_LINES of the ChangeLog.

View file

@ -1,4 +1,5 @@
#!/bin/bash
# Clean up the php session and upload directories.
[[ -d /var/lib/php/sessions ]] && find /var/lib/php/sessions -mmin +1440 -type f -print0 | xargs -0 rm -f
[[ -d /var/tmp/php-uploads ]] && find /var/tmp/php-uploads -mmin +1440 -type f -print0 | xargs -0 rm -f

View file

@ -1,5 +1,6 @@
#!/bin/bash
# Run this job in the background.
# Run dehydrated after a delay.
( # Delay the run for 15 hours (from midnight) and then run at a random time within 3 hours after that.
sleep $(( 54000 + (RANDOM % 10800) ))
/opt/sbin/dehydrated -c >/dev/null ) &

View file

@ -1,4 +1,5 @@
#!/bin/bash
# Set ACLs on /var/log files and directories.
# Sleep for up to a couple of minutes to prevent a race condition with other cron jobs.
sleep $(( RANDOM % 120 ))

View file

@ -1,4 +1,5 @@
#!/bin/bash
# Create a new symlink to today's logs, for ease of browsing.
# Default configuration.
LOGS_DIR="/data/logs"
@ -10,23 +11,28 @@ LOGS_DIR="/data/logs"
for DIR in "$LOGS_DIR"/*/; do
cd "$DIR" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "failed to change directory to '$DIR'" >&2
ERR=1
continue
}
# Logs are for root only.
umask 022
# Create the new days' location.
umask 0755
# shellcheck disable=SC2174
mkdir -p -m 0755 "$LOGS_DIR/$TODAY" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "failed to create directory '$LOGS_DIR/$TODAY'" >&2
ERR=1
continue
}
# Create the 'today' symlink to the new location.
ln -sfn "$TODAY" "today" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "updating 'today' symlink failed in '$DIR'" >&2
ERR=1
continue
}
done
}
exit 0
exit "${ERR:-0}"

View file

@ -1,16 +1,21 @@
#!/bin/bash
# Update the 'locate' database used for the search backend on slackware.uk.
# Default configuration.
SCANDIR="/data/depository"
DBFILE="/data/sites/slackware.uk/files/search.db"
RAND="$$$RANDOM"
if ionice -c3 nice -n 19 /opt/bin/updatedb -l no -o /data/sites/slackware.uk/files/search.db.$RAND -U /data/depository >/dev/null 2>&1; then
mv /data/sites/slackware.uk/files/search.db.$RAND /data/sites/slackware.uk/files/search.db 2>/dev/null || {
if ionice -c3 nice -n 19 /opt/bin/updatedb -l no -o "$DBFILE.$RAND" -U "$SCANDIR" >/dev/null 2>&1; then
mv "$DBFILE.$RAND" "$DBFILE" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "failed to move mirrors search database into place" >&2
rm -f /data/sites/slackware.uk/files/search.db.$RAND
rm -f "$DBFILE.$RAND"
exit 1
}
else
printf "%s: %s\\n" "${0##*/}" "mirrors search database update failed" >&2
rm -f "/data/sites/slackware.uk/files/search.db.$RAND"
rm -f "$DBFILE.$RAND"
exit 1
fi

View file

@ -1,4 +1,5 @@
#!/bin/bash
# Update the /etc/pkglist file, the record of installed packages on the system.
# Check for an /etc/os-release.
[[ ! -e /etc/os-release ]] && {

View file

@ -1,55 +0,0 @@
#!/bin/bash
# FIXME: This is broken.
# Check for an /etc/os-release.
[[ ! -e /etc/os-release ]] && {
printf "%s: %s\\n" "${BASH_SOURCE[0]}" "No /etc/os-release to determine system." >&2
exit 1
}
# Source system info.
# shellcheck disable=SC1091
. /etc/os-release
PKGLIST_CUR_MD5="$(md5sum /etc/pkglist 2>/dev/null)"
TEMPLATE_CUR_MD5="$(md5sum /etc/slackpkg/templates/$(hostname --short).template 2>/dev/null)"
# Create package list depending on system type.
case "$ID" in
'alpine')
apk list -I | cut -d' ' -f1 | rev | cut -d- -f3- | rev >/etc/pkglist || exit 1
;;
'debian'|'devuan'|'ubuntu')
dpkg-query --show --showformat='${Package}\n' >/etc/pkglist || exit 1
;;
'slackware')
[[ -L /etc/pkglist ]] && rm -f /etc/pkglist
printf "%s\\n" /var/log/packages/* | rev | cut -d- -f4- | rev >/etc/pkglist || exit 1
slackpkg -batch=on -default_answer=y generate-template "$(hostname --short)" >/dev/null || exit 1
;;
'void')
xbps-query -l | awk '{ print $2 }' | rev | cut -d- -f2- | rev >/etc/pkglist || exit 1
;;
*)
printf "%s: %s\\n" "${BASH_SOURCE[0]}" "Unsupported system." >&2
exit 1
;;
esac
cd /etc || exot 1
git rev-parse --show-toplevel >/dev/null 2>&1 && {
[[ -z "$PKGLIST_CUR_MD5" ]] && [[ -e pkglist ]] && {
git add pkglist >/dev/null || exit 1
}
[[ -z "$TEMPLATE_CUR_MD5" ]] && [[ -e "slackpkg/templates/$(hostname --short).template" ]] && {
git add "slackpkg/templates/$(hostname --short).template" >/dev/null || exit 1
}
{ [[ -e pkglist ]] && [[ "$(md5sum pkglist 2>/dev/null)" != "$PKGLIST_CUR_MD5" ]]; } || \
{ [[ -e "slackpkg/templates/$(hostname --short).template" ]] && \
[[ "$(md5sum "slackpkg/templates/$(hostname --short).template" 2>/dev/null)" != "$TEMPLATE_CUR_MD5" ]]; } && {
git commit -m "Update pkglist (and/or." pkglist >/dev/null || exit 1
}
}
exit 0

View file

@ -1,26 +0,0 @@
#!/bin/bash
# Version: 0.1.0
# Copyright (c) 2023:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
#
# Update the locate database used specifically for the search interface on slackware.uk.
# Configuration.
DBFILE="/run/mirrors.db"
FILETREE="/storage/md0"
COMMAND="/usr/bin/updatedb"
# Sanity check.
[[ ! -x "$COMMAND" ]] && {
printf "%s: '%s' %s\\n" "${0##*/}" "$COMMAND" "is not executable" >&2
exit 1
}
# Update the database.
nice -n 19 ionice -c3 "$COMMAND" -l 0 -o "$DBFILE" -U "$FILETREE" || {
printf "%s: %s\\n" "${0##*/}" "failed to update locate database" >&2
exit 1
}
exit 0

View file

@ -1,6 +1,8 @@
#!/bin/bash
# Email the status of various git repositories on the system.
# Configuration.
# Default configuration.
# This can be overridden in /etc/default/warn-git-status.
EMAIL_FROM="\"Server: ${HOSTNAME%%.*}\" <noreply@slackware.uk.net>"
EMAIL_TO=("Systems' Administrator <sysadmin@slackware.uk>")

View file

@ -1,6 +1,8 @@
#!/bin/bash
# Send an email with the status of the SMTP queue on the system.
# Default configuration.
# This can be overridden in /etc/default/warn-smtp-queue.
EMAIL_TO=('sysadmin@slackware.uk')
EMAIL_FROM="\"Server: ${HOSTNAME%%.*}\" <noreply@slackware.uk>"
@ -24,23 +26,13 @@ hash mailq 2>/dev/null && {
[[ -z "$TMP_OUTPUT" ]] && exit 0
# Send the message.
if [[ -n "${EMAIL_TO[*]}" ]]; then
if hash mailx >/dev/null 2>&1; then
mailx -S "from=$EMAIL_FROM" -s "Mail queue" "${EMAIL_TO[@]}" <<<"$TMP_OUTPUT" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "mailx command failed" >&2
exit 1
}
elif hash mail >/dev/null 2>&1; then
mail -r "$EMAIL_FROM" -s "Mail queue" "${EMAIL_TO[@]}" <<<"$TMP_OUTPUT" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "mail command failed" >&2
exit 1
}
else
printf "%s: %s\\n" "${0##*/}" "no mailer command found" >&2
if [[ -n "$EMAIL_FROM" ]] && [[ -n "${EMAIL_TO[*]}" ]]; then
mail -r "$EMAIL_FROM" -s "Mail queue" "${EMAIL_TO[@]}" <<<"$TMP_OUTPUT" >/dev/null 2>&1 || {
printf "%s: %s\\n" "${0##*/}" "mail command failed" >&2
exit 1
fi
}
else
printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2
printf "%s: %s\\n" "${0##*/}" "no sender and/or recipient configured for mail delivery" >&2
exit 1
fi
}

View file

@ -1,9 +1,4 @@
#!/bin/bash
# Version: 0.1.1
# Copyright (c) 2023:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
#
# Perform backup tasks in a generic way.
# Base configuration.

View file

@ -1,9 +1,4 @@
#!/bin/bash
# Version: 0.1.0
# Copyright (c) 2023:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
#
# A Dovecot service script to check whether a domain or user has been suspended from being able to use mail.
VIRTUAL_DIR="/etc/virtual"

View file

@ -1,4 +1,5 @@
#!/bin/bash
# Restore firewall state at boot, and store it at shutdown.
### BEGIN INIT INFO
# Provides: firewall
# Required-Start: $network

View file

@ -1,9 +1,4 @@
#!/bin/bash
# Version: 0.1.0
# Copyright (c) 2023:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
#
# Automatically fetch and merge (if possible) upstream changes into a local git repository.
# What platform we're running on.

1
mirror
View file

@ -1,4 +1,5 @@
#!/bin/bash
# Perform mirroring tasks for slackware.uk.
# Version: 0.4.0
# Copyright (c) 2026:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>

Binary file not shown.

View file

@ -1,9 +1,4 @@
#!/bin/bash
# Version: 0.2.1
# Copyright (c) 2023-2026:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
#
# Wrapper around /opt/bin/mirror to keep a log of the mirroring session, and email it.
# Configuration.

48
notify-rsync-upload Executable file
View file

@ -0,0 +1,48 @@
#!/bin/bash
# Send an email notification whenever someone pushes an update to rsyncd.
# Default configuration.
# This can be overridden in /etc/default/notify-rsync-upload.
EMAIL_FROM="\"Server: ${HOSTNAME%%.*}\" <noreply@slackware.uk.net>"
EMAIL_TO=("Systems' Administrator <sysadmin@slackware.uk>")
LOGSDIR="/var/log/duplication/rsync-uploads"
# Read /etc/default/notify-rsync-upload if it exists.
[[ -e /etc/default/notify-rsync-upload ]] && {
# shellcheck disable=SC1091
source /etc/default/notify-rsync-upload || {
printf "%s: %s\\n" "${0##*/}" "failed reading /etc/default/notify-rsync-upload" >&2
exit 1
}
}
# Make sure the logs directory exists.
mkdir -p "$LOGSDIR" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "Failed to create logs directory" >&2
exit 1
}
# Update the log with this upload date/time.
printf "%s - %s\\n" "$(printf "%(%c)T")" "{RSYNC_USER_NAME:-(none)}@${RSYNC_HOST_NAME:-$RSYNC_HOST_ADDR}" >>"$LOGSDIR/${RSYNC_MODULE_NAME%%-upload}"
# Determine the subject of the message.
if (( RSYNC_EXIT_STATUS == 0 )); then
EMAIL_SUBJECT="Upload success: ${RSYNC_MODULE_NAME%%-upload}"
elif (( RSYNC_EXIT_STATUS == -1 )); then
EMAIL_SUBJECT="Upload error: ${RSYNC_MODULE_NAME%%-upload}"
else
EMAIL_SUBJECT="Upload failure: ${RSYNC_MODULE_NAME%%-upload}"
fi
# Send the message.
if [[ -n "$EMAIL_FROM" ]] && (( "${#EMAIL_TO[@]}" != 0 )); then
printf "%s:\\t%s\\n%s:\\t\\t%s\\n%s:\\t%s\\n%s:\\t\\t%s\\n" "Auth'd user" "$RSYNC_USER_NAME@$RSYNC_HOST_NAME [$RSYNC_HOST_ADDR]" "Module" "$RSYNC_MODULE_NAME ($RSYNC_MODULE_PATH)" "Exit code" "$RSYNC_EXIT_STATUS" "PID" "$RSYNC_PID" | mail -r "$EMAIL_FROM" -s "$EMAIL_SUBJECT" "${EMAIL_TO[@]}" >/dev/null 2>&1 || {
printf "%s: %s\\n" "${0##*/}" "mail command failed" >&2
exit 1
}
else
printf "%s: %s\\n" "${0##*/}" "no sender and/or recipient configured for mail delivery" >&2
exit 1
fi
exit 0

View file

@ -1,51 +0,0 @@
#!/bin/bash
# Version: 0.1.0
# Copyright (c) 2023:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
#
# Send an email notification whenever someone pushes an update to rsync.
# shellcheck disable=SC2154
# Configuration.
LOGSDIR="/var/log/suplication/rsync-uploads"
# Source the mail configuration.
source /etc/mail.conf "notify-upload" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "Failed to source /etc/mail.conf" >&2
exit 1
}
# Make sure the logs directory exists.
mkdir -p "$LOGSDIR" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "Failed to create logs directory" >&2
exit 1
}
# Update the log with this upload date/time.
printf "%s - %s\\n" "$(date)" "{RSYNC_USER_NAME:-(none)}@${RSYNC_HOST_NAME:-$RSYNC_HOST_ADDR}" >>"$LOGSDIR/${RSYNC_MODULE_NAME%%-upload}"
# Determine the subject of the message.
if (( RSYNC_EXIT_STATUS == 0 )); then
EMAIL_SUBJECT="Upload success: ${RSYNC_MODULE_NAME%%-upload}"
elif (( RSYNC_EXIT_STATUS == -1 )); then
EMAIL_SUBJECT="Upload error: ${RSYNC_MODULE_NAME%%-upload}"
else
EMAIL_SUBJECT="Upload failure: ${RSYNC_MODULE_NAME%%-upload}"
fi
# Send the message.
if [[ -n "${EMAIL_TO[*]}" ]]; then
mailx "${MAILX_ARGS[@]}" -S "from=$EMAIL_FROM" -s "$EMAIL_SUBJECT" "${EMAIL_TO[@]}" <<-EOF 2>/dev/null || \
{ printf "%s: %s\\n" "${0##*/}" "mailx command failed" >&2; RET=1; }
Auth'd User: $RSYNC_USER_NAME@$RSYNC_HOST_NAME [$RSYNC_HOST_ADDR]
Module: $RSYNC_MODULE_NAME ($RSYNC_MODULE_PATH)
Exit code: $RSYNC_EXIT_STATUS
PID: $RSYNC_PID
EOF
else
printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2
RET=1
fi
exit "${RET:-0}"

View file

@ -1,9 +1,4 @@
#!/bin/bash
# Version: 0.2.0
# Copyright (c) 2023-2026:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
#
# Wrapper around /opt/bin/sbosrcarch to keep a log of the session, and email it.
# Configuration.