Update apache-sync-logs script
[hcoop/scripts.git] / make-account-for-fyodor-user
index 132974b..4cd370e 100755 (executable)
@@ -1,13 +1,75 @@
 #!/bin/bash
 
-for USERHOME in `ssh megacz@fyodor.hcoop.net cd /home\; find */.mire-password -size +0`; do
+ADMIN=`whoami | sed s/_.*//`
+echo "assuming that I am $ADMIN@fyodor..."
+export PATH=/afs/hcoop.net/common/etc/scripts/:$PATH
+
+for USERHOME in `ssh $ADMIN@fyodor.hcoop.net cd /home\; find */.mire-password -size +0`; do
   USER=`dirname $USERHOME`
+  PATHBITS=`echo $USER | head -c 1`/`echo $USER | head -c 2`/$USER
 
   echo == creating user $USER ======================================================================
-  (ssh megacz@fyodor.hcoop.net cat /home/$USER/.mire-password\; cat /home/$USER/.mire-password) | \
-    /afs/hcoop.net/common/etc/scripts/create-user $USER && (
-      echo == account created successfully ========================================================
+    echo ssh $ADMIN@fyodor.hcoop.net "cat /home/$USER/.mire-password"
+    ssh $ADMIN@fyodor.hcoop.net "cat /home/$USER/.mire-password" || \
+     (echo == sending complaint to $USER@hcoop.net ====================================================;\
+      echo 'please have a fyodor admin fix it (Adam Megacz is not a fyodor admin)' |\
+        mail -a 'From: Adam Megacz <megacz@hcoop.net>' \
+             -c admins@hcoop.net \
+             -s "you have damaged the permissions on your ~/.mire-password" $USER@hcoop.net)
+    ssh $ADMIN@fyodor.hcoop.net 'cat /home/$USER/.mire-password' && \
+    create-user $USER && \
+    (ssh $ADMIN@fyodor.hcoop.net "(cat /home/$USER/.mire-password;echo)|head -n 1;(cat /home/$USER/.mire-password;echo)|head -n 1" |\
+     change-user-password "$USER") && \
+     (echo == account created successfully ========================================================
       echo == deleting .mire-password =============================================================
-      ssh megacz@fyodor.hcoop.net 'echo -n > /home/$USER/.mire-password'
+      ssh $ADMIN@fyodor.hcoop.net "echo -n > /home/$USER/.mire-password"
+      echo == sending email to $USER@hcoop.net ====================================================
+      echo w00t |\
+        mail -a 'From: Adam Megacz <megacz@hcoop.net>' \
+             -s "account created for user $USER" admins@hcoop.net
+      mail -a 'From: Adam Megacz <megacz@hcoop.net>' \
+           -s 'your account on mire.hcoop.net has been created' $USER@hcoop.net <<EOF
+Enjoy!
+
+______________________________________________________________________________
+BETA STATUS
+
+Please remember that mire accounts are still in "beta testing", so we
+cannot (yet) guarantee uptime or service.  Please do not migrate
+any important services to your mire account.
+
+______________________________________________________________________________
+SSH Access
+
+You can access your new account by typing:
+
+  ssh $USER@mire.hcoop.net
+
+... using the password previously in fyodor:~/.mire-password.  For
+security, that file has been blanked out.
+
+______________________________________________________________________________
+AFS (direct) Access
+
+Your AFS filespace is located at:
+
+  /afs/hcoop.net/user/$PATHBITS/
+
+If you like, you can access this storage directly from your local
+machine, without having to use ssh or scp.  To do so, follow the
+instructions at the link below, substituting "HCOOP.NET" and
+"hcoop.net" for the realm name and cell name, respectively.
+Capitalization matters.
+
+  http://research.cs.berkeley.edu/doc/afs/
+
+Sincerely,
+
+  - your hcoop admins
+
+EOF
+      echo
+      echo
+      echo
     )
 done