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$|~$)"
22 ##########################
24 if [ -r $CONFIG ]; then
30 ##########################
45 #################################################### FUNCTIONS ########
50 Usage: $(basename $0) [opitions] [banners]
59 --delete - delete wanted banners
61 --exclude - exclude following banners (usefull with -a)
63 --help - shows this help
65 --include - cancels effect of -e (EXCLUDED banners will remain excluded)
67 --make - makes a brand-new banner named as following para [1] (from stdin)
68 -M - same as above, but append if file exists
70 --names - shows names of the banners
71 --newer - all choosen banners should be newer than following para in seconds
72 --older - all choosen banners should be older than following para in seconds
74 --show - shows wanted banners
76 --usage - shows short help
78 [1] - if there will be no slash ('/') in name then config dir will be used,
91 echo "$1"|sed 's,.*/,,'
99 for BANNER in $BANNERS;do
100 STAT=$(stat -c %Y "$BANNERDIR/$BANNER")
101 if [ $OLDER != "no" -a $(( $DATE - $STAT )) -lt $OLDER ]; then
104 if [ $NEWER != "no" -a $(( $DATE - $STAT )) -gt $NEWER ]; then
113 rm -rf $(get_banner_location_list "$BANNER")
115 get_all_banner_list()
117 ls "$BANNERDIR" | grep -E -v "$EXCLUDEFILES"
123 for BANNER in $BANNERS; do
124 if [ -r "$BANNERDIR/$BANNER" ];then
125 echo $NOBANNERS | grep -q $BANNER || echo $BANNER
129 get_banner_location_list()
132 for BANNER in $BANNERS; do
133 echo "$BANNERDIR/$BANNER"
140 mkdir -p $(echo $BANNER|sed 's,/[^/]*$,,')
141 if [ $NEW_APPEND -eq 0 ]; then
146 if [ $SHOW -eq 1 ];then
160 ######################################################## MAIN ########
161 while [ ! -z $1 ]; do
182 if [ "$(check_banner_name $2)" == "$2" ]; then
183 NEW_BANNER=$BANNERDIR/$(check_banner_name "$2")
188 if [ "$1" == "-M" ];then
193 if [ -z "$NEW_BANNER" ];then
206 if [ -z "$CHOOSE_NEWER" ];then
215 if [ -z "$CHOOSE_OLDER" ];then
235 if [ $EXCLUDE_FLAG -eq 0 ];then
236 BANNERS="$BANNERS $(check_banner_name $1)"
238 NOBANNERS="$NOBANNERS $(check_banner_name $1)"
245 if [ $ALL_BANNERS -ne 0 ]; then
246 BANNERS=`get_all_banner_list`
248 if [ $NEED_BANNER_LIST -ne 0 ];then
249 BANNER_LIST=`get_banner_list "$BANNERS" "$NOBANNERS"`
251 if [ $NEED_MTIME_CHECK -ne 0 ];then
252 BANNER_LIST=`check_banners_mtime "$BANNER_LIST" "$CHOOSE_OLDER" "$CHOOSE_NEWER"`
257 delete_banners $BANNER_LIST;
260 make_banner $NEW_BANNER $NEW_SHOW;
266 show_banners $BANNER_LIST;