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,
99 echo "$1"|sed 's,.*/,,'
101 check_banners_mtime()
107 for BANNER in $BANNERS;do
108 STAT=$(stat -c %Y "$BANNERDIR/$BANNER")
109 if [ $OLDER != "no" -a $(( $DATE - $STAT )) -lt $OLDER ]; then
112 if [ $NEWER != "no" -a $(( $DATE - $STAT )) -gt $NEWER ]; then
121 rm -rf $(get_banner_location_list "$BANNER")
123 get_all_banner_list()
125 ls "$BANNERDIR" | grep -E -v "$EXCLUDEFILES"
131 for BANNER in $BANNERS; do
132 if [ -r "$BANNERDIR/$BANNER" ];then
133 echo $NOBANNERS | grep -q $BANNER || echo $BANNER
137 get_banner_location_list()
140 for BANNER in $BANNERS; do
141 echo "$BANNERDIR/$BANNER"
148 mkdir -p $(echo $BANNER|sed 's,/[^/]*$,,')
150 if [ $NEW_APPEND -eq 0 ]; then
151 echo "$data" > $BANNER
153 echo "$data" >> $BANNER
155 if [ $SHOW -eq 1 ];then
161 cat $BANNERDIR/$1 >&$STDOUT
169 ######################################################## MAIN ########
170 while [ ! -z $1 ]; do
191 if [ "$(check_banner_name $2)" == "$2" ]; then
192 NEW_BANNER=$BANNERDIR/$(check_banner_name "$2")
197 if [ "$1" == "-M" ];then
202 if [ -z "$NEW_BANNER" ];then
215 if [ -z "$CHOOSE_NEWER" ];then
224 if [ -z "$CHOOSE_OLDER" ];then
250 if [ $EXCLUDE_FLAG -eq 0 ];then
251 BANNERS="$BANNERS $(check_banner_name $1)"
253 NOBANNERS="$NOBANNERS $(check_banner_name $1)"
260 if [ $ALL_BANNERS -ne 0 ]; then
261 BANNERS=`get_all_banner_list`
263 if [ $NEED_BANNER_LIST -ne 0 ];then
264 BANNER_LIST=`get_banner_list "$BANNERS" "$NOBANNERS"`
266 if [ $NEED_MTIME_CHECK -ne 0 ];then
267 BANNER_LIST=`check_banners_mtime "$BANNER_LIST" "$CHOOSE_OLDER" "$CHOOSE_NEWER"`
272 delete_banners $BANNER_LIST;
275 make_banner $NEW_BANNER $NEW_SHOW;
281 show_banners $BANNER_LIST;