Compare commits
No commits in common. "0590fca7495f4821c0e751b8f3b924a970472b18" and "ac00e3ed38c44c9ad634e89edbc025a7bf1a3ce7" have entirely different histories.
0590fca749
...
ac00e3ed38
7 changed files with 24 additions and 95 deletions
|
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
[[ -d /var/lib/php/sessions ]] && find /var/lib/php/sessions -mmin +1440 -type f -print0 | xargs -0 rm -f
|
|
||||||
[[ -d /var/tmp/php-uploads ]] && find /var/tmp/php-uploads -mmin +1440 -type f -print0 | xargs -0 rm -f
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Run this job in the background.
|
|
||||||
( # Delay the run for 15 hours (from midnight) and then run at a random time within 3 hours after that.
|
# Delay the run for 15 hours (from midnight) and then run at a random time within 3 hours after that.
|
||||||
sleep $(( 54000 + (RANDOM % 10800) ))
|
sleep $(( 54000 + (RANDOM % 10800) ))
|
||||||
/opt/sbin/dehydrated -c >/dev/null ) &
|
|
||||||
|
/usr/sbin/dehydrated -c >/dev/null
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Default configuration.
|
|
||||||
LOGS_DIR="/data/logs"
|
|
||||||
|
|
||||||
# Process the directories in the $LOGS_DIR directory.
|
|
||||||
[[ -d "$LOGS_DIR" ]] && {
|
|
||||||
TODAY="$(printf "%(%Y/%m/%d)T")"
|
|
||||||
|
|
||||||
for DIR in "$LOGS_DIR"/*/; do
|
|
||||||
cd "$DIR" 2>/dev/null || {
|
|
||||||
printf "%s: %s\\n" "${0##*/}" "failed to change directory to '$DIR'" >&2
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create the new days' location.
|
|
||||||
umask 0755
|
|
||||||
# shellcheck disable=SC2174
|
|
||||||
mkdir -p -m 0755 "$LOGS_DIR/$TODAY" 2>/dev/null || {
|
|
||||||
printf "%s: %s\\n" "${0##*/}" "failed to create directory '$LOGS_DIR/$TODAY'" >&2
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create the 'today' symlink to the new location.
|
|
||||||
ln -sfn "$TODAY" "today" 2>/dev/null || {
|
|
||||||
printf "%s: %s\\n" "${0##*/}" "updating 'today' symlink failed in '$DIR'" >&2
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
# Source system info.
|
# Source system info.
|
||||||
# shellcheck disable=SC1091
|
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
|
|
||||||
# Create package list depending on system type.
|
# Create package list depending on system type.
|
||||||
|
|
@ -21,7 +20,7 @@ case "$ID" in
|
||||||
'slackware')
|
'slackware')
|
||||||
slackpkg -batch=on -default_answer=y generate-template "$(hostname --short)" >/dev/null
|
slackpkg -batch=on -default_answer=y generate-template "$(hostname --short)" >/dev/null
|
||||||
[[ -L /etc/pkglist ]] && rm -f /etc/pkglist
|
[[ -L /etc/pkglist ]] && rm -f /etc/pkglist
|
||||||
printf "%s\\n" /var/log/packages/* | rev | cut -d- -f4- | rev >/etc/pkglist
|
ls -1 /var/log/packages/ | rev | cut -d- -f4- | rev >/etc/pkglist
|
||||||
;;
|
;;
|
||||||
'void')
|
'void')
|
||||||
xbps-query -l | awk '{ print $2 }' | rev | cut -d- -f2- | rev >/etc/pkglist
|
xbps-query -l | awk '{ print $2 }' | rev | cut -d- -f2- | rev >/etc/pkglist
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Default configuration.
|
CHECK_DIRS=( '/' '/etc/slackpkg/templates' )
|
||||||
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 ]] && {
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
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"
|
OUTPUT_FILE="/tmp/${0##*/}-$$-$RANDOM"
|
||||||
|
|
||||||
# Remove the OUTPUT_FILE when done.
|
# Remove the OUTPUT_FILE when done.
|
||||||
trap 'rm -f "$OUTPUT_FILE"' EXIT
|
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.
|
# Loop through the list and process.
|
||||||
for DIR in "${CHECK_DIRS[@]}"; do
|
for DIR in "${CHECK_DIRS[@]}"; do
|
||||||
[[ ! -e "$DIR" ]] || [[ ! -d "$DIR" ]] && continue
|
[[ ! -e "$DIR" ]] || [[ ! -d "$DIR" ]] && continue
|
||||||
|
|
@ -27,27 +20,16 @@ for DIR in "${CHECK_DIRS[@]}"; do
|
||||||
unset TMP_OUTPUT
|
unset TMP_OUTPUT
|
||||||
done
|
done
|
||||||
|
|
||||||
# If there's no output, do nothing.
|
|
||||||
[[ ! -s "$OUTPUT_FILE" ]] && {
|
[[ ! -s "$OUTPUT_FILE" ]] && {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Send the message.
|
# Send the message.
|
||||||
if [[ -n "${EMAIL_TO[*]}" ]]; then
|
if [[ -n "${EMAIL_TO[*]}" ]]; then
|
||||||
if hash mailx >/dev/null 2>&1; then
|
mailx "${MAILX_ARGS[@]}" -S "from=$EMAIL_FROM" -s "Git statuses" "${EMAIL_TO[@]}" <<<"$(cat "$OUTPUT_FILE")" 2>/dev/null || {
|
||||||
mailx -S "from=$EMAIL_FROM" -s "Mail queue" "${EMAIL_TO[@]}" <"$OUTPUT_FILE" 2>/dev/null || {
|
|
||||||
printf "%s: %s\\n" "${0##*/}" "mailx command failed" >&2
|
printf "%s: %s\\n" "${0##*/}" "mailx command failed" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
elif hash mail >/dev/null 2>&1; then
|
|
||||||
mail -r "$EMAIL_FROM" -s "Mail queue" "${EMAIL_TO[@]}" <"$OUTPUT_FILE" 2>/dev/null || {
|
|
||||||
printf "%s: %s\\n" "${0##*/}" "mail command failed" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printf "%s: %s\\n" "${0##*/}" "no mailer command found" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2
|
printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,15 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Default configuration.
|
# Source the mail configuration.
|
||||||
EMAIL_TO=('sysadmin@slackware.uk')
|
source /etc/mail.conf "mail-queue" 2>/dev/null || {
|
||||||
EMAIL_FROM="\"Server: ${HOSTNAME%%.*}\" <noreply@slackware.uk>"
|
printf "%s: %s\\n" "${0##*/}" "Failed to source /etc/mail.conf" >&2
|
||||||
|
|
||||||
# Allow /etc/default/warn-smtp-queue to override default configuration.
|
|
||||||
[[ -e /etc/default/warn-smtp-queue ]] && {
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
source /etc/default/warn-smtp-queue || {
|
|
||||||
printf "%s: %s\\n" "${0##*/}" "failed reading /etc/default/warn-smtp-queue" >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Don't do anything unless 'mailq' is installed.
|
# Don't do anything unless 'mailq' is installed.
|
||||||
hash mailq 2>/dev/null && {
|
hash mailq 2>/dev/null && {
|
||||||
# Prevent a race with other cron jobs that produce emails.
|
# Prevent a race with other cron jobs that produce emails.
|
||||||
sleep $(( 10 + (RANDOM % 30) ))
|
sleep $(( RANDOM % 180 ))
|
||||||
|
|
||||||
# Get the queue
|
# Get the queue
|
||||||
TMP_OUTPUT="$(mailq)"
|
TMP_OUTPUT="$(mailq)"
|
||||||
|
|
@ -25,20 +18,10 @@ hash mailq 2>/dev/null && {
|
||||||
|
|
||||||
# Send the message.
|
# Send the message.
|
||||||
if [[ -n "${EMAIL_TO[*]}" ]]; then
|
if [[ -n "${EMAIL_TO[*]}" ]]; then
|
||||||
if hash mailx >/dev/null 2>&1; then
|
mailx "${MAILX_ARGS[@]}" -S "from=$EMAIL_FROM" -s "Mail queue" "${EMAIL_TO[@]}" <<<"$TMP_OUTPUT" 2>/dev/null || {
|
||||||
mailx -S "from=$EMAIL_FROM" -s "Mail queue" "${EMAIL_TO[@]}" <<<"$TMP_OUTPUT" 2>/dev/null || {
|
|
||||||
printf "%s: %s\\n" "${0##*/}" "mailx command failed" >&2
|
printf "%s: %s\\n" "${0##*/}" "mailx command failed" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
elif hash mail >/dev/null 2>&1; then
|
|
||||||
mail -r "$EMAIL_FROM" -s "Mail queue" "${EMAIL_TO[@]}" <<<"$TMP_OUTPUT" 2>/dev/null || {
|
|
||||||
printf "%s: %s\\n" "${0##*/}" "mail command failed" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printf "%s: %s\\n" "${0##*/}" "no mailer command found" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2
|
printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue