Update configs for Phil.
This commit is contained in:
parent
f4a8693bfa
commit
98737ad12d
33 changed files with 455 additions and 201 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue