X-Git-Url: http://git.pld-linux.org/?p=packages%2Frpm.git;a=blobdiff_plain;f=banner.sh;h=5c92c5c48d4ca7ecd30cb7cd93da94a0454ff049;hp=666f27539d537a89db1b12c7fe118361849231c0;hb=769d887949774544fe4a2606119ad6d18cefc527;hpb=e2b2282bbe779af7590b7879fb844abbc7dd9aeb diff --git a/banner.sh b/banner.sh index 666f275..5c92c5c 100644 --- a/banner.sh +++ b/banner.sh @@ -16,7 +16,8 @@ CONFIG=/etc/sysconfig/banner BANNERDIR="/var/lib/banner/" # egrep regexp EXCLUDEFILES="(rpmnew$|rpmsave$|~$)" - +STDOUT="1" # stdout by default +#STDOUT="2" # stderr by default # config paramaeters ########################## @@ -42,6 +43,11 @@ NEW_APPEND=0 NEW_BANNER="" NEW_SHOW=0 +case $STDOUT in + [1-9]) ;; + *) STDOUT="1" ;; +esac + #################################################### FUNCTIONS ######## Usage() @@ -58,22 +64,24 @@ Help() --all - all banners --delete - delete wanted banners -e ---exclude - exclude following banners (usefull with -a) +--exclude - exclude following banners (useful with -a) -h ---help - shows this help +--help - show this help -i ---include - cancels effect of -e (EXCLUDED banners will remain excluded) +--include - cancel effect of -e (EXCLUDED banners will remain excluded) -m ---make - makes a brand-new banner named as following para [1] (from stdin) +--make - make a brand-new banner named as following parameter [1] (from stdin) -M - same as above, but append if file exists -n ---names - shows names of the banners ---newer - all choosen banners should be newer than following para in seconds ---older - all choosen banners should be older than following para in seconds +--names - show names of the banners +--newer - all choosen banners should be newer than following parameter in seconds +--older - all choosen banners should be older than following parameter in seconds -s ---show - shows wanted banners +--show - show wanted banners +--stderr - send banner to stderr instead of stdout (or other) +--stdout - send banner to stdout instead of stderr (or other) -u ---usage - shows short help +--usage - show short help [1] - if there will be no slash ('/') in name then config dir will be used, else -- specified. @@ -86,10 +94,7 @@ Unknown parameter $1 EOF Help } -check_banner_name() -{ - echo "$1"|sed 's,.*/,,' -} + check_banners_mtime() { BANNERS="$1" @@ -137,19 +142,22 @@ make_banner() { BANNER="$1" SHOW="$2" - mkdir -p $(echo $BANNER|sed 's,/[^/]*$,,') + if [ ! -d "${BANNER%/*}" ]; then + mkdir -p "${BANNER%/*}" + fi + data=$(cat) if [ $NEW_APPEND -eq 0 ]; then - cat > $BANNER + echo "$data" > $BANNER else - cat >> $BANNER + echo "$data" >> $BANNER fi if [ $SHOW -eq 1 ];then - cat $BANNER + echo "$data" fi } show_banner() { - cat $BANNERDIR/$1 + cat $BANNERDIR/$1 >&$STDOUT } show_banners() { @@ -179,8 +187,8 @@ while [ ! -z $1 ]; do ;; -m|--make|-M) NEED_BANNER_LIST=0 - if [ "$(check_banner_name $2)" == "$2" ]; then - NEW_BANNER=$BANNERDIR/$(check_banner_name "$2") + if [[ $2 != */* ]]; then + NEW_BANNER="$BANNERDIR/${2##*/}" else NEW_BANNER="$2" fi @@ -223,6 +231,12 @@ while [ ! -z $1 ]; do NEW_SHOW=1 ACTION="show" ;; + --stdout) + STDOUT="1" + ;; + --stderr) + STDOUT="2" + ;; -u|--usage) Usage exit 0 @@ -233,9 +247,9 @@ while [ ! -z $1 ]; do ;; *) if [ $EXCLUDE_FLAG -eq 0 ];then - BANNERS="$BANNERS $(check_banner_name $1)" + BANNERS="$BANNERS ${1##*/}" else - NOBANNERS="$NOBANNERS $(check_banner_name $1)" + NOBANNERS="$NOBANNERS ${1##*/}" fi ;; esac