catsync support
[clinton/scripts.git] / change-user-password
1 #!/bin/bash -ex
2 #
3 # Finally, set password for main user's principal
4 # Aborting this operation is harmless. Just re-invoke cpw.
5 #
6 # kadmin.local doesn't report errors properly, so we have to
7 # check manually
8 #
9 USER=$1
10 sudo rm -f /tmp/kadmin.out
11 sudo kadmin.local -p root/admin -q "cpw $USER@HCOOP.NET" \
12 2>&1 | tee /tmp/kadmin.out
13 cat /tmp/kadmin.out | grep 'is too short while changing' && \
14 (echo == sending complaint to $USER@hcoop.net ====================================================;\
15 echo 'please change it' |\
16 mail -a 'From: Adam Megacz <megacz@hcoop.net>' \
17 -c admins@hcoop.net \
18 -s "your ~/.mire-password is too short" $USER@hcoop.net) || \
19 true
20 cat /tmp/kadmin.out | grep '\(Password for .* changed\|Cannot reuse password while changing password\)'
21 sudo rm -f /tmp/kadmin.out