move user password change to separate file, email hcoop-sysadmin
authormegacz <megacz>
Mon, 14 May 2007 23:51:28 +0000 (23:51 +0000)
committermegacz <megacz>
Mon, 14 May 2007 23:51:28 +0000 (23:51 +0000)
change-user-password [new file with mode: 0755]
create-user
make-account-for-fyodor-user

diff --git a/change-user-password b/change-user-password
new file mode 100755 (executable)
index 0000000..bb5b0c2
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash -ex
+#
+# Finally, set password for main user's principal
+# Aborting this operation is harmless. Just re-invoke cpw.
+#
+# kadmin.local doesn't report errors properly, so we have to
+# check manually
+# 
+USER=$1
+sudo rm -f /tmp/kadmin.out
+sudo kadmin.local -p root/admin -q "cpw $USER@HCOOP.NET" \
+  2>&1 | tee /tmp/kadmin.out
+cat /tmp/kadmin.out | grep '\(Password for .* changed\|Cannot reuse password while changing password\)'
+sudo rm -f /tmp/kadmin.out
index 6ffab03..177ad76 100755 (executable)
@@ -223,16 +223,4 @@ vos syncvldb deleuze
 fs checkvolumes
 ssh mire.hcoop.net fs checkvolumes
 
 fs checkvolumes
 ssh mire.hcoop.net fs checkvolumes
 
-#
-# Finally, set password for main user's principal
-# Aborting this operation is harmless. Just re-invoke cpw.
-#
-# kadmin.local doesn't report errors properly, so we have to
-# check manually
-# 
-sudo rm -f /tmp/kadmin.out
-sudo kadmin.local -p root/admin -q "cpw $USER@HCOOP.NET" \
-  2>&1 | tee /tmp/kadmin.out
-cat /tmp/kadmin.out | grep 'Password for .* changed'
-sudo rm -f /tmp/kadmin.out
 
 
index 94cd696..dc9569c 100755 (executable)
@@ -2,19 +2,25 @@
 
 ADMIN=`whoami | sed s/_.*//`
 echo "assuming that I am $ADMIN@fyodor..."
 
 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 ======================================================================
 
 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 $ADMIN@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 ========================================================
+    create-user $USER && \
+    (ssh $ADMIN@fyodor.hcoop.net cat /home/$USER/.mire-password\; cat /home/$USER/.mire-password |\
+     change-user-password $USER) && \
+     (echo == account created successfully ========================================================
       echo == deleting .mire-password =============================================================
       ssh $ADMIN@fyodor.hcoop.net 'echo -n > /home/$USER/.mire-password'
       echo == sending email to $USER@hcoop.net ====================================================
       echo == deleting .mire-password =============================================================
       ssh $ADMIN@fyodor.hcoop.net 'echo -n > /home/$USER/.mire-password'
       echo == sending email to $USER@hcoop.net ====================================================
-      mail -s 'your account on mire.hcoop.net has been created' $USER@hcoop.net <<EOF
+      echo w00t |\
+        mail -a 'From: Adam Megacz <megacz@hcoop.net>' \
+             -s "account created for user $USER" hcoop-sysadmin@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!
 
 ______________________________________________________________________________
 Enjoy!
 
 ______________________________________________________________________________