3 # Please send bug reports 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) [options] [banners]
63 -a, --all - all banners
64 -d, --delete - delete specified banners
65 -e, --exclude - exclude following banners (useful with -a)
66 -h, --help - show this help
67 -i, --include - cancel effect of -e (EXCLUDED banners will remain excluded)
68 -m, --make - make a brand-new banner named as following parameter [1] (from stdin)
69 -M - same as above, but append if file exists
70 -n, --names - show names of the banners
71 --newer - all choosen banners should be newer than following parameter in seconds
72 --older - all choosen banners should be older than following parameter in seconds
73 -s, --show - show specified banners
74 --stderr - send banner to stderr instead of stdout (or other)
75 --stdout - send banner to stdout instead of stderr (or other)
76 -u, --usage - show short help
78 [1] if there is no slash ('/') in the given name default dir ($BANNERDIR) is used,
79 otherwise the one that's specified
96 for BANNER in $BANNERS;do
97 STAT=$(stat -c %Y "$BANNERDIR/$BANNER")
98 if [ $OLDER != "no" -a $(( $DATE - $STAT )) -lt $OLDER ]; then
101 if [ $NEWER != "no" -a $(( $DATE - $STAT )) -gt $NEWER ]; then
110 rm -rf $(get_banner_location_list "$BANNER")
112 get_all_banner_list()
114 ls "$BANNERDIR" | grep -E -v "$EXCLUDEFILES"
120 for BANNER in $BANNERS; do
121 if [ -r "$BANNERDIR/$BANNER" ]; then
122 echo $NOBANNERS | grep -q $BANNER || echo $BANNER
126 get_banner_location_list()
129 for BANNER in $BANNERS; do
130 echo "$BANNERDIR/$BANNER"
137 if [ ! -d "${BANNER%/*}" ]; then
138 mkdir -p "${BANNER%/*}"
141 if [ $NEW_APPEND -eq 0 ]; then
142 echo "$data" > $BANNER
144 echo "$data" >> $BANNER
146 if [ $SHOW -eq 1 ]; then
152 cat "$BANNERDIR/$1" >&$STDOUT
161 ######################################################### MAIN ########
162 while [ -n "$1" ]; do
183 if [[ "$2" != */* ]]; then
184 NEW_BANNER="$BANNERDIR/${2##*/}"
189 if [ "$1" = "-M" ]; then
194 if [ -z "$NEW_BANNER" ]; then
207 if [ -z "$CHOOSE_NEWER" ]; then
216 if [ -z "$CHOOSE_OLDER" ]; then
242 if [ $EXCLUDE_FLAG -eq 0 ]; then
243 BANNERS="$BANNERS ${1##*/}"
245 NOBANNERS="$NOBANNERS ${1##*/}"
252 if [ $ALL_BANNERS -ne 0 ]; then
253 BANNERS=`get_all_banner_list`
255 if [ $NEED_BANNER_LIST -ne 0 ]; then
256 BANNER_LIST=`get_banner_list "$BANNERS" "$NOBANNERS"`
258 if [ $NEED_MTIME_CHECK -ne 0 ]; then
259 BANNER_LIST=`check_banners_mtime "$BANNER_LIST" "$CHOOSE_OLDER" "$CHOOSE_NEWER"`
264 delete_banners $BANNER_LIST
267 make_banner $NEW_BANNER $NEW_SHOW
273 show_banners $BANNER_LIST