diff --git a/colour-changelog b/colour-changelog index 92e6233..55bf4b4 100755 --- a/colour-changelog +++ b/colour-changelog @@ -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. diff --git a/cronjob-clean-php b/cronjob-clean-php index b47cc39..40010a6 100755 --- a/cronjob-clean-php +++ b/cronjob-clean-php @@ -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 diff --git a/cronjob-dehydrated b/cronjob-dehydrated index 7afa21c..482fc92 100755 --- a/cronjob-dehydrated +++ b/cronjob-dehydrated @@ -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 ) & diff --git a/cronjob-fix-log-acls b/cronjob-fix-log-acls index 4313f92..61d2a90 100755 --- a/cronjob-fix-log-acls +++ b/cronjob-fix-log-acls @@ -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 )) diff --git a/cronjob-rotate-logs-today-symlink b/cronjob-rotate-logs-today-symlink index f59a139..cd54374 100755 --- a/cronjob-rotate-logs-today-symlink +++ b/cronjob-rotate-logs-today-symlink @@ -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}" diff --git a/cronjob-update-mirrors-search-db b/cronjob-update-mirrors-search-db index 9ade33a..b44a3e2 100755 --- a/cronjob-update-mirrors-search-db +++ b/cronjob-update-mirrors-search-db @@ -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 diff --git a/cronjob-update-packages-list b/cronjob-update-packages-list index 203c69a..9a63b92 100755 --- a/cronjob-update-packages-list +++ b/cronjob-update-packages-list @@ -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 ]] && { diff --git a/cronjob-update-packages-list.new b/cronjob-update-packages-list.new deleted file mode 100644 index 5503f68..0000000 --- a/cronjob-update-packages-list.new +++ /dev/null @@ -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 diff --git a/cronjob-updatedb-mirrors b/cronjob-updatedb-mirrors deleted file mode 100755 index f4ea9a3..0000000 --- a/cronjob-updatedb-mirrors +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# Version: 0.1.0 -# Copyright (c) 2023: -# Darren 'Tadgy' Austin -# 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 diff --git a/cronjob-warn-git-status b/cronjob-warn-git-status index c4dd959..3a07040 100755 --- a/cronjob-warn-git-status +++ b/cronjob-warn-git-status @@ -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%%.*}\" " EMAIL_TO=("Systems' Administrator ") diff --git a/cronjob-warn-smtp-queue b/cronjob-warn-smtp-queue index f551661..859f2e8 100755 --- a/cronjob-warn-smtp-queue +++ b/cronjob-warn-smtp-queue @@ -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%%.*}\" " @@ -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 } diff --git a/do-backup b/do-backup index 0a8e35f..d0c8816 100755 --- a/do-backup +++ b/do-backup @@ -1,9 +1,4 @@ #!/bin/bash -# Version: 0.1.1 -# Copyright (c) 2023: -# Darren 'Tadgy' Austin -# Licensed under the terms of the GNU General Public License version 3. -# # Perform backup tasks in a generic way. # Base configuration. diff --git a/dovecot-service-checksuspended b/dovecot-service-checksuspended index 2af1775..da11b7e 100755 --- a/dovecot-service-checksuspended +++ b/dovecot-service-checksuspended @@ -1,9 +1,4 @@ #!/bin/bash -# Version: 0.1.0 -# Copyright (c) 2023: -# Darren 'Tadgy' Austin -# 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" diff --git a/firewall-initscript b/firewall-initscript index 25ee3cd..f19c2f1 100755 --- a/firewall-initscript +++ b/firewall-initscript @@ -1,4 +1,5 @@ #!/bin/bash +# Restore firewall state at boot, and store it at shutdown. ### BEGIN INIT INFO # Provides: firewall # Required-Start: $network diff --git a/git-auto-merge b/git-auto-merge index b993bf9..a2bac87 100755 --- a/git-auto-merge +++ b/git-auto-merge @@ -1,9 +1,4 @@ #!/bin/bash -# Version: 0.1.0 -# Copyright (c) 2023: -# Darren 'Tadgy' Austin -# 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. diff --git a/mirror b/mirror index 965c594..a2cafd7 100755 --- a/mirror +++ b/mirror @@ -1,4 +1,5 @@ #!/bin/bash +# Perform mirroring tasks for slackware.uk. # Version: 0.4.0 # Copyright (c) 2026: # Darren 'Tadgy' Austin diff --git a/mirror-new-slackware-release.gpg b/mirror-new-slackware-release.gpg index 992a9f4..4fda3fd 100644 Binary files a/mirror-new-slackware-release.gpg and b/mirror-new-slackware-release.gpg differ diff --git a/mirror-wrapper b/mirror-wrapper index d9de8a5..812479e 100755 --- a/mirror-wrapper +++ b/mirror-wrapper @@ -1,9 +1,4 @@ #!/bin/bash -# Version: 0.2.1 -# Copyright (c) 2023-2026: -# Darren 'Tadgy' Austin -# 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. diff --git a/notify-rsync-upload b/notify-rsync-upload new file mode 100755 index 0000000..d271c41 --- /dev/null +++ b/notify-rsync-upload @@ -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%%.*}\" " +EMAIL_TO=("Systems' Administrator ") +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 diff --git a/rsync-notify-upload b/rsync-notify-upload deleted file mode 100755 index 31c536f..0000000 --- a/rsync-notify-upload +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# Version: 0.1.0 -# Copyright (c) 2023: -# Darren 'Tadgy' Austin -# 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}" diff --git a/sbosrcarch-wrapper b/sbosrcarch-wrapper index 55fe5fa..9f16a9d 100755 --- a/sbosrcarch-wrapper +++ b/sbosrcarch-wrapper @@ -1,9 +1,4 @@ #!/bin/bash -# Version: 0.2.0 -# Copyright (c) 2023-2026: -# Darren 'Tadgy' Austin -# 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.