create-user: Make DAV lock directories on both mire and deleuze
[hcoop/scripts.git] / create-user
index a83c524..ff57c9d 100755 (executable)
@@ -19,6 +19,16 @@ if test -z "$USER"; then
        exit 1
 fi
 
+#
+# Helper functions
+#
+
+# Run a command on both mire and deleuze; assumes that no escaping is
+# needed.
+function mire_and_deleuze() {
+    $*
+    ssh mire.hcoop.net $*
+}
 
 #
 # Kerberos principals
@@ -134,23 +144,34 @@ sudo chmod 440            /etc/keytabs/user.daemon/$USER
 vos examine user.$USER 2>/dev/null || \
   vos create deleuze.hcoop.net /vicepa user.$USER -maxquota 400000
 mkdir -p `dirname $HOMEPATH`
-fs ls $HOMEPATH || fs mkm $HOMEPATH user.$USER
-chown $USER $HOMEPATH
+fs ls $HOMEPATH || test -L $HOMEPATH || fs mkm $HOMEPATH user.$USER
+chown $USER:nogroup $HOMEPATH
 fs sa $HOMEPATH $USER            all
 fs sa $HOMEPATH system:anyuser   l
 
 # Apache logs
 mkdir -p $HOMEPATH/logs/apache
-fs sa    $HOMEPATH/logs/apache $USER.daemon rlwidk
+chown $USER:nogroup $HOMEPATH/logs/apache
+fs sa $HOMEPATH/logs/apache $USER.daemon rlwidk
 
 # public_html
-mkdir -p $HOMEPATH/public_html/
+mkdir -p $HOMEPATH/public_html
+chown $USER:nogroup $HOMEPATH/public_html
 fs sa $HOMEPATH/public_html system:anyuser rl
-mkdir -p $HOMEPATH/.procmail.d/
-fs sa $HOMEPATH/.procmail.d/ system:anyuser rl
+
+# .procmail.d
+mkdir -p $HOMEPATH/.procmail.d
+chown $USER:nogroup $HOMEPATH/.procmail.d
+fs sa $HOMEPATH/.procmail.d system:anyuser rl
+
+# .public
 mkdir -p $HOMEPATH/.public/
-fs sa $HOMEPATH/.public/ system:anyuser rl
-mkdir -p $HOMEPATH/.public/.domtool/
+chown $USER:nogroup $HOMEPATH/.public
+fs sa $HOMEPATH/.public system:anyuser rl
+
+# .domtool
+mkdir -p $HOMEPATH/.public/.domtool
+chown $USER:nogroup $HOMEPATH/.public/.domtool
 test -e $HOMEPATH/.domtool || \
     test -L $HOMEPATH/.domtool || \
         ln -s $HOMEPATH/.public/.domtool $HOMEPATH/.domtool
@@ -161,6 +182,8 @@ vos examine mail.$USER 2>/dev/null || \
 mkdir -p `dirname $MAILPATH`
 fs ls $MAILPATH || fs mkm $MAILPATH         mail.$USER
 fs ls $HOMEPATH/Maildir || fs mkm $HOMEPATH/Maildir mail.$USER
+chown $USER:nogroup $MAILPATH
+chown $USER:nogroup $HOMEPATH/Maildir
 fs sa $MAILPATH $USER        all
 fs sa $MAILPATH $USER.daemon all
 
@@ -207,13 +230,14 @@ vos syncserv deleuze
 vos syncvldb deleuze
 
 # refresh volume location cache (takes ~2hrs otherwise)
-fs checkvolumes
-ssh mire.hcoop.net fs checkvolumes
-
-# Technically this is not idempotent.  This is not *too* bad because
-# of the fact that in AFS non-system:administrators users can't change
-# the group/owner of a file anyways.  However, users still might want
-# to know which other users created certain files (in, say, a dropbox
-# or something like that).  FIMXE.
-chown -R $USER:nogroup $HOMEPATH
-chown -R $USER:nogroup $MAILPATH
+mire_and_deleuze fs checkvolumes
+
+#
+# Non-AFS files and directories
+#
+
+# Make per-user apache DAV lock directory -- the directory must be
+# both user and group-writable, which is silly.
+mire_and_deleuze sudo mkdir -p /var/lock/apache2/dav/$USER
+mire_and_deleuze sudo chown $USER:www-data /var/lock/apache2/dav/$USER
+mire_and_deleuze sudo chmod ug=rwx,o= /var/lock/apache2/dav/$USER