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 mkdir -p "${BANNER%/*}"
147 if [ $NEW_APPEND -eq 0 ]; then
148 echo "$data" > $BANNER
150 echo "$data" >> $BANNER
152 if [ $SHOW -eq 1 ];then
158 cat $BANNERDIR/$1 >&$STDOUT
166 ######################################################## MAIN ########
167 while [ ! -z $1 ]; do
188 if [[ $2 != */* ]]; then
189 NEW_BANNER="$BANNERDIR/${2##*/}"
194 if [ "$1" == "-M" ];then
199 if [ -z "$NEW_BANNER" ];then
212 if [ -z "$CHOOSE_NEWER" ];then
221 if [ -z "$CHOOSE_OLDER" ];then
247 if [ $EXCLUDE_FLAG -eq 0 ];then
248 BANNERS="$BANNERS ${1##*/}"
250 NOBANNERS="$NOBANNERS ${1##*/}"
257 if [ $ALL_BANNERS -ne 0 ]; then
258 BANNERS=`get_all_banner_list`
260 if [ $NEED_BANNER_LIST -ne 0 ];then
261 BANNER_LIST=`get_banner_list "$BANNERS" "$NOBANNERS"`
263 if [ $NEED_MTIME_CHECK -ne 0 ];then
264 BANNER_LIST=`check_banners_mtime "$BANNER_LIST" "$CHOOSE_OLDER" "$CHOOSE_NEWER"`
269 delete_banners $BANNER_LIST;
272 make_banner $NEW_BANNER $NEW_SHOW;
278 show_banners $BANNER_LIST;