Skip to content

Instantly share code, notes, and snippets.

@niamtokik
Created January 24, 2017 11:29
Show Gist options
  • Save niamtokik/f2aa639af456b6c2cd20d8fceed0aa90 to your computer and use it in GitHub Desktop.
Save niamtokik/f2aa639af456b6c2cd20d8fceed0aa90 to your computer and use it in GitHub Desktop.
simple, quick and dirty netbsd standard cvs update wrapper with mail alert
#!/bin/sh
######################################################################
# simple cvs update wrapper for netbsd #
######################################################################
ALERT_MAIL="yes"
ALERT_USER="root"
CVS_OPTS="-qz3"
CVS="cvs ${CVS_OPTS}"
_alert_mail() {
if [ "${ALERT_MAIL}" = "yes" ]
then
test -z "${ALERT_USER}" && ALERT_USER="root"
while read line
do
echo ${line}
done 2>&1 | mail -s "cvs update - ${1} - $(date)" "${ALERT_USER}"
fi
}
_update_cvs() {
local path release
path="${1}"
test -z "${path}" && _usage
release="${2}"
test -z "${release}" && _usage
cd "${path}"
eval ${CVS} update -dP -r"${release}" \
| _alert_mail "${path}"
}
_update_src() {
local release
release="${1}"
test -z "${release}" && _usage
_update_cvs /usr/src "${release}"
}
_update_pkgsrc() {
local release
release="${1}"
test -z "${release}" && _usage
_update_cvs /usr/pkgsrc "${release}"
}
_usage() {
printf -- 'usage: %s [%s|%s|%s]\n' \
"${0}" \
'cvs $path $release' \
'src $release' \
'pkgsrc $release'
exit 1
}
test -z "${1}" && _usage
arg="${1}"
shift
case "${arg}"
in
cvs) _update_cvs "${1}" "${2}";;
src) _update_src "${1}";;
pkgsrc) _update_pkgsrc "${1}";;
*) _usage;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment