create-user: Set up shared SpamAssassin directory for everyone
[hcoop/scripts.git] / create-user
index ff57c9d..d811558 100755 (executable)
@@ -187,6 +187,27 @@ chown $USER:nogroup $HOMEPATH/Maildir
 fs sa $MAILPATH $USER        all
 fs sa $MAILPATH $USER.daemon all
 
+# Set up shared SpamAssassin folder
+if test -f $HOMEPATH/Maildir/shared-maildirs; then
+    # Deal with case where user rsync'd their Maildir from fyodor
+    pattern='^SpamAssassin     /home/spamd'
+    file=$HOMEPATH/Maildir/shared-maildirs
+    if grep $pattern $file; then
+        sed -i -r -e \
+            's!^(SpamAssassin  )/home/spamd!\1/var/local/lib/spamd!1' \
+            $file
+    fi
+    for dir in $HOMEPATH/Maildir/shared-folders/SpamAssassin/*; do
+        dest=/var/local/lib/spamd/Maildir/.$(basename $dir)
+        if test "$(readlink $dir/shared)" != "$dest"; then
+            ln -sf $dest $dir/shared
+        fi
+    done
+else
+    maildirmake --add SpamAssassin=/var/local/lib/spamd/Maildir \
+        $HOMEPATH/Maildir
+fi
+
 # DATABASE VOLUME
 if ! vos examine db.$USER >/dev/null 2>/dev/null; then
   mkdir -p `dirname /afs/.hcoop.net/common/.databases/$PATHBITS`