X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=update_lists;h=d398991011de6864759149ede8de7300ab1cc48c;hb=dcce90e77c92202b5fadca48de6fd1cefc41ff79;hp=d23aa247006c1e8424a23af3d1c9c2fccc661f3f;hpb=c4719886fc4a24d60fd7f1966926f7dd09ef551c;p=bin.git diff --git a/update_lists b/update_lists index d23aa24..d398991 100755 --- a/update_lists +++ b/update_lists @@ -1,16 +1,17 @@ -#!/bin/sh +#!/bin/bash -cd ~/Maildir -# Build lists sublists -find lists -maxdepth 1 -mindepth 1 -type d |perl -ne 'chomp; $a = $_; $b = $a; $b =~ s/\//./g; qx(ln -sf $a .$b)' -# Build bugs sublists -find bugs -maxdepth 1 -mindepth 1 -type d |perl -ne 'chomp; $a = $_; $b = $a; $b =~ s/\//./g; qx(ln -sf $a .$b)' - -# Remove dead lists -#find ~/Maildir/lists/ -type d -maxdepth 1 -mindepth 1|xargs -n 1 -i sh -c '(( $(find "{}" -type f -iname "*" |wc -l) <= 1 )) && rm -rf "{}"' - -find ~/Maildir/lists/ -maxdepth 1 -mindepth 1 -type d|xargs -n 1 -i sh -c 'A={}; (( $(find $A -type f -name "*" -not -name "dovecot*" | wc -l) == 0 )) && rm -rf $A' -find ~/Maildir/bugs/ -maxdepth 1 -mindepth 1 -type d|xargs -n 1 -i sh -c 'A={}; (( $(find $A -type f -name "*" -not -name "dovecot*" |wc -l) == 0 )) && rm -rf $A' +for listdir in lists bugs; do + ( cd ~/Maildir; + find $listdir -maxdepth 1 -mindepth 1 -type d | \ + perl -ne 'chomp; $a = $_; $b = $a; $b =~ s/\./_/g; $b =~ s/\//./g; qx(ln -sf "$a" ".$b")'; + ); + ( cd ~/Maildir/$listdir; + find . -maxdepth 1 -mindepth 1 -type d| \ + xargs -n 1 -i bash -c 'A={}; (( $(find "$A" -type f -name "*" -not -name "dovecot*" -not -name ".imap*" -not -name ".customflags" | wc -l) == 0 )) && rm -rf "$A"'; + ); +done; # Remove broken symlinks -find . -maxdepth 1 -mindepth 1 -type l -iname '.*' -not -xtype d -print0 |xargs -0 rm -f \ No newline at end of file +(cd ~/Maildir; + find . -maxdepth 1 -mindepth 1 -type l -iname '.*' -not -xtype d -delete; +);