Created
April 24, 2014 02:11
-
-
Save brianoz/11239130 to your computer and use it in GitHub Desktop.
cpanel lock email account via email address - very basic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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