From aee5c859f06c2fa0507beac30eb150b3a3096f17 Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Sat, 11 Nov 2023 21:00:54 +0000 Subject: [PATCH] Symlink cron.daily scripts from /opt/bin. --- etc/cron.daily/cronjob-dehdrated | 1 + etc/cron.daily/cronjob-update-packages-list | 1 + etc/cron.daily/cronjob-warn-git-status | 1 + etc/cron.daily/dehydrated | 3 -- etc/cron.daily/update-packages-list | 26 -------------- etc/cron.daily/warn-git-status | 38 --------------------- 6 files changed, 3 insertions(+), 67 deletions(-) create mode 120000 etc/cron.daily/cronjob-dehdrated create mode 120000 etc/cron.daily/cronjob-update-packages-list create mode 120000 etc/cron.daily/cronjob-warn-git-status delete mode 100755 etc/cron.daily/dehydrated delete mode 100755 etc/cron.daily/update-packages-list delete mode 100755 etc/cron.daily/warn-git-status diff --git a/etc/cron.daily/cronjob-dehdrated b/etc/cron.daily/cronjob-dehdrated new file mode 120000 index 0000000..cef01bf --- /dev/null +++ b/etc/cron.daily/cronjob-dehdrated @@ -0,0 +1 @@ +/opt/bin/cronjob-dehdrated \ No newline at end of file diff --git a/etc/cron.daily/cronjob-update-packages-list b/etc/cron.daily/cronjob-update-packages-list new file mode 120000 index 0000000..4d6dae3 --- /dev/null +++ b/etc/cron.daily/cronjob-update-packages-list @@ -0,0 +1 @@ +/opt/bin/cronjob-update-packages-list \ No newline at end of file diff --git a/etc/cron.daily/cronjob-warn-git-status b/etc/cron.daily/cronjob-warn-git-status new file mode 120000 index 0000000..bfd5bbd --- /dev/null +++ b/etc/cron.daily/cronjob-warn-git-status @@ -0,0 +1 @@ +/opt/bin/cronjob-warn-git-status \ No newline at end of file diff --git a/etc/cron.daily/dehydrated b/etc/cron.daily/dehydrated deleted file mode 100755 index 92b623f..0000000 --- a/etc/cron.daily/dehydrated +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -/usr/sbin/dehydrated -c >/dev/null diff --git a/etc/cron.daily/update-packages-list b/etc/cron.daily/update-packages-list deleted file mode 100755 index 291b970..0000000 --- a/etc/cron.daily/update-packages-list +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# 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. -. /etc/os-release - -# Create package list depending on system type. -case "$ID" in - 'slackware') - /usr/sbin/slackpkg -batch=on -default_answer=y generate-template "$(hostname --short)" >/dev/null - ;; - 'void') - /usr/sbin/xbps-query -l | awk '{ print $2 }' | rev | cut -d- -f2- | rev >/etc/pkglist - ;; - *) - printf "%s: %s\\n" "${BASH_SOURCE[0]}" "Unsupported system." >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/etc/cron.daily/warn-git-status b/etc/cron.daily/warn-git-status deleted file mode 100755 index 641ec13..0000000 --- a/etc/cron.daily/warn-git-status +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -CHECK_DIRS=( '/' '/etc/slackpkg/templates' ) -OUTPUT_FILE="/tmp/${0##*/}-$$-$RANDOM" - -# Remove the OUTPUT_FILE when done. -trap 'rm -f "$OUTPUT_FILE"' EXIT - -# Source the mail configuration. -source /etc/mail.conf "git-status" 2>/dev/null || { - printf "%s: %s\\n" "${0##*/}" "Failed to source /etc/mail.conf" >&2 - exit 1 -} - -# Loop through the list and process. -for DIR in "${CHECK_DIRS[@]}"; do - [[ ! -e "$DIR" ]] || [[ ! -d "$DIR" ]] && continue - TMP_OUTPUT="$(cd "$DIR" && [[ "$(git rev-parse --show-toplevel)" == "$PWD" ]] && git status | grep -E -ve "^(On branch|Your branch|No commits|nothing|$)" -e "\(use")" - [[ -n "$TMP_OUTPUT" ]] && printf "%s:\\n%s\\n\\n" "$DIR" "$TMP_OUTPUT" >>"$OUTPUT_FILE" - unset TMP_OUTPUT -done - -[[ ! -s "$OUTPUT_FILE" ]] && { - exit 0 -} - -# Send the message. -if [[ -n "${EMAIL_TO[*]}" ]]; then - mailx "${MAILX_ARGS[@]}" -S "from=$EMAIL_FROM" -s "Git statuses" "${EMAIL_TO[@]}" <<<"$(cat "$OUTPUT_FILE")" 2>/dev/null || { - printf "%s: %s\\n" "${0##*/}" "mailx command failed" >&2 - exit 1 - } -else - printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2 - exit 1 -fi - -exit 0