Change name of cronjob scripts.
This commit is contained in:
parent
4bce06332e
commit
903576a1bd
5 changed files with 0 additions and 0 deletions
38
cronjob-warn-git-status
Executable file
38
cronjob-warn-git-status
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/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
|
||||
Loading…
Add table
Add a link
Reference in a new issue