Skip to content

Instantly share code, notes, and snippets.

@brianoz
Created April 24, 2014 02:11
Show Gist options
  • Save brianoz/11239130 to your computer and use it in GitHub Desktop.
Save brianoz/11239130 to your computer and use it in GitHub Desktop.
cpanel lock email account via email address - very basic
#! /bin/sh
# lock email account password
# usage: lockemailpass [email protected]
# arg taken is [email protected]
# lock email password for account
for email
do
user=${email%%@*} # extract user
domain=${email##*@} # extract domain
# find cpanel account
account=$(grep "^$domain: " /etc/userdomains | awk '{ print $2 }')
# work out path of shadow file under user account
# assumes user home is /home
epath=/home/$account/etc/$domain
sed -i -e '/^$user:/s/:/:!/' $epath/shadow
done
# sanitized:
# [svr:/home/acct/etc/domain.com.au]# grep mead passwd
# jmeade:x:760:755::/home/acct/mail/domain.com.au/jmeade:/bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment