add support for DragonFly and OpenBSD
DragonFly is a FreeBSD derivative, so the same `du` flags as for FreeBSD and Darwin apply. OpenBSD does not support exclusion. The correct invocation for in-place `sed` without backup varies. GNU Sed allows just leaving out the suffix, but BSD Sed requires an empty suffix (which in turn GNU Sed doesn't accept). OpenBSD Sed has no in-place option, use `ed` instead. `mail` works the same on all BSD. explicitly list `bash` dependency, it's not installed on most BSD by default.
This commit is contained in:
parent
0f11e6f163
commit
4f90cc7440
2 changed files with 36 additions and 11 deletions
|
|
@ -36,7 +36,7 @@ Be sure to make the script executable (`chmod +x`) before you hit the gas.
|
|||
## Requirements
|
||||
|
||||
* [duplicity](http://duplicity.nongnu.org/)
|
||||
* Basic utilities like: [which](http://unixhelp.ed.ac.uk/CGI/man-cgi?which) and [tee](http://linux.die.net/man/1/tee) (should already be available on most Linux systems)
|
||||
* Basic utilities like: [bash](https://www.gnu.org/software/bash/), [which](http://unixhelp.ed.ac.uk/CGI/man-cgi?which) and [tee](http://linux.die.net/man/1/tee) (should already be available on most Linux systems)
|
||||
* [gpg](http://www.gnupg.org/) *`optional`*
|
||||
* [Amazon S3](http://aws.amazon.com/s3/) *`optional`*
|
||||
* [s3cmd](http://s3tools.org/s3cmd) *`optional`*
|
||||
|
|
|
|||
|
|
@ -297,11 +297,14 @@ email_logfile()
|
|||
EMAIL_FROM=${EMAIL_FROM:+"-r ${EMAIL_FROM}"}
|
||||
cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" $EMAIL_FROM ${EMAIL_TO}
|
||||
elif [ "$MAIL" = "mail" ]; then
|
||||
if [[ `uname` == "FreeBSD" || `uname` == 'Darwin' ]]; then
|
||||
cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" ${EMAIL_TO} --
|
||||
else
|
||||
case `uname` in
|
||||
FreeBSD|Darwin|DragonFly|OpenBSD)
|
||||
cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" ${EMAIL_TO} --
|
||||
;;
|
||||
*)
|
||||
cat ${LOGFILE} | ${MAILCMD} -s """${EMAIL_SUBJECT}""" $EMAIL_FROM ${EMAIL_TO} -- -f ${EMAIL_FROM}
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
elif [[ "$MAIL" = "sendmail" ]]; then
|
||||
(echo """Subject: ${EMAIL_SUBJECT}""" ; cat ${LOGFILE}) | ${MAILCMD} -f ${EMAIL_FROM} ${EMAIL_TO}
|
||||
elif [ "$MAIL" = "nail" ]; then
|
||||
|
|
@ -337,10 +340,18 @@ get_source_file_size()
|
|||
OLDIFS=$IFS
|
||||
IFS=$(echo -en "\t\n")
|
||||
|
||||
DUEXCFLAG="--exclude-from="
|
||||
if [[ `uname` == 'FreeBSD' || `uname` == 'Darwin' ]]; then
|
||||
DUEXCFLAG="-I "
|
||||
fi
|
||||
case `uname` in
|
||||
FreeBSD|Darwin|DragonFly)
|
||||
DUEXCFLAG="-I -"
|
||||
;;
|
||||
OpenBSD)
|
||||
echo "WARNING: OpenBSD du does not support exclusion, sizes may be off" >> ${LOGFILE}
|
||||
DUEXCFLAG=""
|
||||
;;
|
||||
*)
|
||||
DUEXCFLAG="--exclude-from=-"
|
||||
;;
|
||||
esac
|
||||
|
||||
for exclude in ${EXCLIST[@]}; do
|
||||
DUEXCLIST="${DUEXCLIST}${exclude}\n"
|
||||
|
|
@ -349,7 +360,7 @@ get_source_file_size()
|
|||
for include in ${INCLIST[@]}
|
||||
do
|
||||
echo -e '"'$DUEXCLIST'"' | \
|
||||
du -hs ${DUEXCFLAG}"-" ${include} | \
|
||||
du -hs ${DUEXCFLAG} ${include} | \
|
||||
awk '{ FS="\t"; $0=$0; print $1"\t"$2 }' \
|
||||
>> ${LOGFILE}
|
||||
done
|
||||
|
|
@ -479,7 +490,21 @@ get_file_sizes()
|
|||
get_source_file_size
|
||||
get_remote_file_size
|
||||
|
||||
sed -i -e '/^--*$/d' ${LOGFILE}
|
||||
case `uname` in
|
||||
FreeBSD|Darwin|DragonFly)
|
||||
sed -i '' -e '/^--*$/d' ${LOGFILE}
|
||||
;;
|
||||
OpenBSD)
|
||||
ed -s ${LOGFILE} <<-"EOF"
|
||||
g/^--*$/d
|
||||
w
|
||||
q
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
sed -i -e '/^--*$/d' ${LOGFILE}
|
||||
;;
|
||||
esac
|
||||
chown ${LOG_FILE_OWNER} ${LOGFILE}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue