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