Migrate users from /etc/shadow

Use the following script adapted from zimbra wiki:

make-migration.sh
#!/bin/bash

# customize these to your needs:
domain="zimbra.example.com"
# get cos_id with command zmprov gc <COSname>, eg. zmprov gc default | grep zimbraId
cos_id="e00428a1-0c00-11d9-836a-000d93afea2a"
shadow="shadow.text"

script="import-shadow.sh"
x=0
echo '' > $script

for entry in `cat $shadow`
do
    user=`echo $entry|cut -f1 -d":"`
    pass=`echo $entry|cut -f2 -d":"`

    if [ "x$pass" != "x*" ]
    then
        if [ "x$pass" != "x$!" -a "x$pass" != "x$!!" ]
        then
            echo "zmprov ca $user@$domain temppasswordQAZXSW displayName $user zimbraCOSid $cos_id" >> $script
            echo "zmprov ma $user@$domain userPassword '{crypt}$pass'" >> $script
            x=$[x+1]
        fi
    fi
done

echo
echo
echo "$x accounts exported to \"$PWD/$script\""

echo ''
echo "Run $script to do the import."
zimbra/migrate_from_shadow.txt · Last modified: 2011-12-03 19:21 by admin
Back to top
GNU Free Documentation License 1.3
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0