#!/bin/bash # BASH script for the creation of a Jabber user account, user.xml # Written by Van Aug-2003 # Referenced JEP-0054 and Psi 0.9 vCard XML output for vCard # generation. You may need to tweak the vCard format for your # particular environment! # Change the variables below to reflect your environment: FQDN="im.vanemery.com" JABFILE="$1.xml" PATHTOJAB="/usr/local/jabber" echo "" if [ "$1" = "" ] ; then echo "Must specify a user name... (Example: jabadd romeo)" echo "" exit 0 ; fi cd $PATHTOJAB/spool/$FQDN if [ -f "$JABFILE" ] ; then echo -n "User file exists. Would you like to overwrite? [y|n] " read YESORNO echo "" case $YESORNO in y|Y|yes|YES|Yes) rm -f $JABFILE echo "XML file deleted..." echo "" ;; *) echo "Exiting..." echo "" exit 0 ;; esac ; fi # Ask for Password echo -n "User's password: " read JABPASS echo "" if [ -z "$JABPASS" ] ; then echo "Password cannot be empty string..." echo "" exit 0 ; fi # Ask if vcard info shall be entered echo -n "Do you want to input vCard info? [y|n] " read VCYESNO case $VCYESNO in y|Y|yes|YES|Yes) echo "" echo "**Note** Fields may be left blank" echo "" echo -n "User's last name: " read LASTNAME echo -n "User's first name: " read FIRSTNAME FULLNAME="$FIRSTNAME $LASTNAME" echo -n "Nickname: " read NICKNAME echo -n "Description/Comments: " read DESCRIPTION echo -n "e-mail address: " read EMAIL echo -n "Web URL: " read URL echo -n "Organization: " read ORGANIZATION echo -n "Department: " read DEPT echo -n "Title: " read TITLE echo -n "Role: " read ROLE echo -n "Phone Number: " read PHONE echo "" echo "Creating userfile with VCard..." ;; *) echo "" echo "Creating userfile..." ;; esac # Generate Timestamp (This is done in GMT/UTC) JABDATE=`date -u +%Y%m%d`T`date -u +%T` # Put together the XML file SEC1="$JABPASS" SEC2="" SEC3="$1" SEC4="$JABPASS" SEC5="registered" VC1="" VC2="$FULLNAME" VC3="$LASTNAME$FIRSTNAME" VC4="$NICKNAME" VC5="" VC6="" VC7="$PHONE" VC8="$EMAIL" VC9="$TITLE" VC10="$ROLE" VC11="$ORGANIZATION$DEPT" VC12="$URL" VC13="$DESCRIPTION" VC14="" echo -e "\n$SEC1\n$SEC2\n$SEC3\n$SEC4\n$SEC5\n$VC1\n$VC2\n$VC3\n$VC4\n$VC5\n$VC6\n$VC7\n$VC8\n$VC9\n$VC10\n$VC11\n$VC12\n$VC13\n$VC14\n" > $JABFILE chown jabber:jabber $JABFILE chmod 0664 $JABFILE echo "" echo "User file $JABFILE created..." echo "" # End BASH Script