X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=functions.sh;h=06e42be40ffb895236213055f32efe777a4cc548;hb=38de75c0ef647a2ecbe153fda14a3caae345497b;hp=805a066f9b9914cc16498b484d900701434643ae;hpb=879b1838fe975233ab19c9e5b29e813a18193372;p=carnet-tools-cn.git diff --git a/functions.sh b/functions.sh index 805a066..06e42be 100644 --- a/functions.sh +++ b/functions.sh @@ -132,3 +132,50 @@ cp_check_and_sed() { done return $ret } + +# by jelly, Sun, 20 Mar 2005 20:12:19 +0100 +cp_echo () { + [ "$CP_SCRIPT_DEBUG" ] && set -vx + if [ "x$1" = "x-mailonly" -o "x$1" = "x-m" ]; then + shift + else + echo "$*" + fi + CP_NOTICE="$CP_NOTICE$1" + if [ `echo -n "$*" | wc -l` -eq 0 ]; then + CP_NOTICE="$CP_NOTICE +" + fi +} + +# by jelly, Sun, 20 Mar 2005 20:12:19 +0100 +cp_mail () { + [ "$CP_SCRIPT_DEBUG" ] && set -vx + local pkg version quiet + if [ "x$1" = "x-q" ]; then + quiet=1 + shift + fi + [ -n "$1" ] && pkg="$1" # barf if no package + [ -n "$2" ] && version=" $2" || true + if [ "$(echo $CP_NOTICE|wc -w)" -gt 0 ]; then + [ -n "$quiet" ] || echo "Mailing upgrade output to root." + CP_NOTICE="From: $pkg postinst script +To: root +Subject: $pkg$version package install log +Date: $(/bin/date +'%a, %d %b %Y %H:%M:%S %z') + +Hello! + +The $pkg package has been successfully installed on your computer. +For your convenience, a partial output of the last $pkg installation +is included below. + +---------- +$CP_NOTICE +----------" + + echo "$CP_NOTICE" | /usr/sbin/sendmail -t & + sleep 1 + fi +}