Created
January 24, 2017 11:29
-
-
Save niamtokik/f2aa639af456b6c2cd20d8fceed0aa90 to your computer and use it in GitHub Desktop.
simple, quick and dirty netbsd standard cvs update wrapper with mail alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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