3 # bug reports send to pzurowski@pld-linux.org or pld-devel-* lists
7 # >> PLACE STANDARD GPL DISCLAIMER H E R E . <<
9 CONFIG=/etc/sysconfig/banner
11 ####################################################### CONFIG ########
14 ##########################
16 BANNERDIR="/var/lib/banner/"
18 EXCLUDEFILES="(rpmnew$|rpmsave$|~$)"
19 STDOUT="1" # stdout by default
20 #STDOUT="2" # stderr by default
23 ##########################
25 if [ -r $CONFIG ]; then
31 ##########################
51 #################################################### FUNCTIONS ########
56 Usage: $(basename $0) [opitions] [banners]
65 --delete - delete wanted banners
67 --exclude - exclude following banners (useful with -a)
69 --help - show this help
71 --include - cancel effect of -e (EXCLUDED banners will remain excluded)
73 --make - make a brand-new banner named as following parameter [1] (from stdin)
74 -M - same as above, but append if file exists
76 --names - show names of the banners
77 --newer - all choosen banners should be newer than following parameter in seconds
78 --older - all choosen banners should be older than following parameter in seconds
80 --show - show wanted banners
81 --stderr - send banner to stderr instead of stdout (or other)
82 --stdout - send banner to stdout instead of stderr (or other)
84 --usage - show short help
86 [1] - if there will be no slash ('/') in name then config dir will be used,
104 for BANNER in $BANNERS;do
105 STAT=$(stat -c %Y "$BANNERDIR/$BANNER")
106 if [ $OLDER != "no" -a $(( $DATE - $STAT )) -lt $OLDER ]; then
109 if [ $NEWER != "no" -a $(( $DATE - $STAT )) -gt $NEWER ]; then
118 rm -rf $(get_banner_location_list "$BANNER")
120 get_all_banner_list()
122 ls "$BANNERDIR" | grep -E -v "$EXCLUDEFILES"
128 for BANNER in $BANNERS; do
129 if [ -r "$BANNERDIR/$BANNER" ];then
130 echo $NOBANNERS | grep -q $BANNER || echo $BANNER
134 get_banner_location_list()
137 for BANNER in $BANNERS; do
138 echo "$BANNERDIR/$BANNER"
145 if [ ! -d "${BANNER%/*}" ]; then
146 mkdir -p "${BANNER%/*}"
149 if [ $NEW_APPEND -eq 0 ]; then
150 echo "$data" > $BANNER
152 echo "$data" >> $BANNER
154 if [ $SHOW -eq 1 ];then
160 cat $BANNERDIR/$1 >&$STDOUT
168 ######################################################## MAIN ########
169 while [ ! -z $1 ]; do
190 if [[ $2 != */* ]]; then
191 NEW_BANNER="$BANNERDIR/${2##*/}"
196 if [ "$1" == "-M" ];then
201 if [ -z "$NEW_BANNER" ];then
214 if [ -z "$CHOOSE_NEWER" ];then
223 if [ -z "$CHOOSE_OLDER" ];then
249 if [ $EXCLUDE_FLAG -eq 0 ];then
250 BANNERS="$BANNERS ${1##*/}"
252 NOBANNERS="$NOBANNERS ${1##*/}"
259 if [ $ALL_BANNERS -ne 0 ]; then
260 BANNERS=`get_all_banner_list`
262 if [ $NEED_BANNER_LIST -ne 0 ];then
263 BANNER_LIST=`get_banner_list "$BANNERS" "$NOBANNERS"`
265 if [ $NEED_MTIME_CHECK -ne 0 ];then
266 BANNER_LIST=`check_banners_mtime "$BANNER_LIST" "$CHOOSE_OLDER" "$CHOOSE_NEWER"`
271 delete_banners $BANNER_LIST;
274 make_banner $NEW_BANNER $NEW_SHOW;
280 show_banners $BANNER_LIST;