Skip to content

Instantly share code, notes, and snippets.

/remove_ftp_user.sh Secret

Created Nov 14, 2013
Embed
What would you like to do?
#!/bin/bash
FTP_USER="$1";
FTP_PASSWD_FILE="/etc/pure-ftpd/pureftpd.passwd";
CHECK_LOGIN=`cat "$FTP_PASSWD_FILE" | grep "$FTP_USER:" | cut -d ':' -f 1 | wc -l`;
DieWithError()
{
echo "$1" 1>&2;
exit 1;
}
[ -z "$FTP_USER" ] && DieWithError "Usage: $0 <ftp_login>";
[ $CHECK_LOGIN -eq 0 ] && DieWithError "Error: the specified login does not exist";
pure-pw userdel "${FTP_USER}" 2> /dev/null;
pure-pw mkdb > /dev/null 2>&1;
/etc/init.d/pure-ftpd restart > /dev/null 2>&1;
echo -e "Done!\n";
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment