diff --git a/etc/.gitignore b/etc/.gitignore index a6a6a88..1ed8b7f 100644 --- a/etc/.gitignore +++ b/etc/.gitignore @@ -50,7 +50,6 @@ /lynx.cfg /lynx.lss /mail.rc -/mailx.rc /man.conf /mke2fs.conf /modprobe.d/ diff --git a/etc/cron.daily/warn-git-status b/etc/cron.daily/warn-git-status index 7645bea..641ec13 100755 --- a/etc/cron.daily/warn-git-status +++ b/etc/cron.daily/warn-git-status @@ -1,9 +1,38 @@ #!/bin/bash -source /etc/mail.conf "git-status" || exit 1 +CHECK_DIRS=( '/' '/etc/slackpkg/templates' ) +OUTPUT_FILE="/tmp/${0##*/}-$$-$RANDOM" -CONFIGSTATUS="$(cd / && git status | egrep -ve "^(On branch|Your branch|No commits|nothing|$)" -e "\(use")" +# Remove the OUTPUT_FILE when done. +trap 'rm -f "$OUTPUT_FILE"' EXIT -[[ -z "$CONFIGSTATUS" ]] && exit 0 +# 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 +} -mailx "${MAILX_ARGS[@]}" -S from="$EMAIL_FROM" -s "git statuses" "${EMAIL_TO[@]}" <<<"$CONFIGSTATUS" +# 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 diff --git a/etc/mailx.rc b/etc/mailx.rc new file mode 100644 index 0000000..1b255a5 --- /dev/null +++ b/etc/mailx.rc @@ -0,0 +1,113 @@ +# Configuration file for Mailx (formerly "nail"). +# See mailx(1) for further options. + +# Do not move messages from the system mailbox to a local mbox. +set hold + +# Messages will be appended (rather than prepended) to mboxes. +# This should usually always be set. +# This has no effect unless 'hold' is unset again. +set append + +# Always ask for a subject when composing a message interactively. +set asksub + +# Confirm sending of messages. +set asksend + +# Assume a CRT-like terminal and invoke a pager. +set crt + +# Messages may be terminated by a dot. +set dot + +# Do not remove empty mail folders in the spool directory. +# This may be relevant for privacy since other users could +# otherwise create them with different permissions. +set keep + +# Do not remove empty mail folders. +set emptybox + +# Quote the original message in replies by "> " as usual on the Internet. +set indentprefix="> " + +# Automatically quote the text of the message that is responded to. +set quote + +# Outgoing messages are sent in UTF-8 if possible, otherwise LATIN1. +set sendcharsets=utf-8,iso-8859-1 + +# Display sender's real names in header summaries. +set showname + +# Display the recipients of messages sent by the user himself in +# header summaries. +set showto + +# Automatically check for new messages at each prompt, but avoid polling +# of IMAP servers or maildir folders. +set newmail=nopoll + +# If threaded mode is activated, automatically collapse thread. +set autocollapse + +# Mark messages that have been answered. +set markanswered + +# Hide some header fields which are uninteresting for most human readers. +ignore received in-reply-to message-id references +ignore mime-version content-transfer-encoding + +# Only include selected header fields when forwarding messages. +# headerpick forward retain subject date from to cc + +# Use a directory named 'mail' in the users homedir to hold mailboxes. +set folder=mail/ + +# Keep the comment/name part of email addresses when replying. +set fullnames + +# Use 'less' for paged output. +set PAGER=/usr/bin/less + +# When spawning an editor in compose mode, allow editing of headers. +set editheaders + +# Startup into interactive mode even if the (given) mailbox is empty. +set emptystart + +# Add more entries to the history as is done by default. +# The latter will cause the built-in editor to save those entries, too. +set history-gabby all history-gabby-persist + +# Try to circumvent false or missing MIME Content-Type descriptions. +# Do set a value for extended behaviour (see the manual). +#set mime-counter-evidence +set mime-counter-evidence=0b1111 + +# Do not move `save'd or `write'n message to $MBOX by default since this is +# likely to be irritating for most users today. +set keepsave + +# When replying, do not merge From: and To: of the original message +# into To:. Instead old From: -> new To:, old To: -> merge Cc:. +set recipients-in-cc + +# Whether a ‘Mail-Followup-To:’ header is honoured when group-replying. +set followup-to-honour=ask-yes + +# Whether a ‘Reply-To:’ header is honoured when replying. +set reply-to-honour=ask-yes + +# When sending a message, wait until the MTA (including the built-in SMTP one) +# exits before accepting further commands. Only with this variable set are +# errors reported by the MTA recognised! +set sendwait + +# Only include these selected header fields when printing messages. +retain date sender from to cc subject message-id mail-followup-to reply-to + +# Use an SMTP server rather than 'sendmail' to deliver mail. +# Set to the IP/Name of an SMTP server which will accept mail from this host. +# set smtp=mail.example.com diff --git a/etc/sv/syslogd/.gitignore b/etc/sv/syslogd/.gitignore deleted file mode 100644 index d8bcda4..0000000 --- a/etc/sv/syslogd/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/supervise/ diff --git a/etc/sv/syslogd/log/.gitignore b/etc/sv/syslogd/log/.gitignore deleted file mode 100644 index d8bcda4..0000000 --- a/etc/sv/syslogd/log/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/supervise/ diff --git a/etc/sv/syslogd/log/supervise/.gitignore b/etc/sv/syslogd/log/supervise/.gitignore new file mode 100644 index 0000000..a8a148e --- /dev/null +++ b/etc/sv/syslogd/log/supervise/.gitignore @@ -0,0 +1,6 @@ +/control +/lock +/ok +/pid +/stat +/status diff --git a/etc/sv/syslogd/supervise/.gitignore b/etc/sv/syslogd/supervise/.gitignore new file mode 100644 index 0000000..a8a148e --- /dev/null +++ b/etc/sv/syslogd/supervise/.gitignore @@ -0,0 +1,6 @@ +/control +/lock +/ok +/pid +/stat +/status