Use symlinks into git repos for /opt/sbin/*
This commit is contained in:
parent
b0266e1637
commit
734c809238
8 changed files with 25 additions and 832 deletions
|
|
@ -1,44 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Default configuration.
|
||||
CHECK_DIRS=('/')
|
||||
EMAIL_TO=('sysadmin@slackware.uk')
|
||||
EMAIL_FROM="\"Server: ${HOSTNAME%%.*}\" <noreply@slackware.uk>"
|
||||
|
||||
# Allow /etc/default/warn-git-status to override default configuration.
|
||||
[[ -e /etc/default/warn-git-status ]] && {
|
||||
source /etc/default/warn-git-status || {
|
||||
printf "%s: %s\\n" "${0##*/}" "failed reading /etc/default/warn-git-status" >&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
OUTPUT_FILE="/tmp/${0##*/}-$$-$RANDOM"
|
||||
|
||||
# Remove the OUTPUT_FILE when done.
|
||||
trap 'rm -f "$OUTPUT_FILE"' EXIT
|
||||
|
||||
# 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
|
||||
mail -r "$EMAIL_FROM" -s "Git statuses" "${EMAIL_TO[@]}" <"$OUTPUT_FILE" >/dev/null 2>&1 || {
|
||||
printf "%s: %s\\n" "${0##*/}" "mail command failed" >&2
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
1
opt/sbin/cronjob-warn-git-status
Symbolic link
1
opt/sbin/cronjob-warn-git-status
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../usr/src/random-scripts.git/cronjob-warn-git-status
|
||||
Loading…
Add table
Add a link
Reference in a new issue