Commit 70e29d7c authored by Vitaly Lipatov's avatar Vitaly Lipatov

add restore_jabberd password script

parent 3230488b
#!/bin/sh
# Written by Vitaly Lipatov <lav@etersoft.ru>, 2012
# restore jabber user password:
# ./restore_jabberd_passwd.sh LOGIN [e-mail]
# supports only im.etersoft.ru now
DB_USER=eter_jabber
DB_PASS=S7PCfhJj9v9eUMsm
DB_HOST=mysql.priv.etersoft.ru
DB=eter_jabber
REALM=im.etersoft.ru
EMAIL=lav@etersoft.ru
mysql_query()
{
echo "$@" |
mysql -s -N --default-character-set=utf8 --user=$DB_USER --password=$DB_PASS --host $DB_HOST $DB
}
LOGIN=$1
FORCEEMAIL=$2
PASSWORD=$(mysql_query "SELECT password FROM authreg WHERE \`username\` = \"$LOGIN\" AND \`realm\` = \"$REALM\" ")
test -n "$PASSWORD" || exit
echo "Password: $PASSWORD"
if [ -z "$FORCEEMAIL" ] ; then
USEREMAIL=$(mysql_query "SELECT email FROM vcard WHERE \`collection-owner\` = '$LOGIN@$REALM' ")
else
USEREMAIL=$FORCEEMAIL
fi
test -n "$USEREMAIL" || fatal "E-mail is missed in user vcard. You can run this script with user e-email as second arg."
echo "E-mail: $USEREMAIL"
EMAIL=$EMAIL mutt $USEREMAIL -s "Jabber password from im.etersoft.ru" << EOF
Hello,
Your password recovery request for $LOGIN@$REALM jabber account has handled.
Your current password phrase is '$PASSWORD'.
Please, change it immediately via your Jabber client.
With best regards,
Etersoft robot,
$(LANG=C date)
EOF
echo "Mailed from $EMAIL to $USEREMAIL"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment