Skip to content

Instantly share code, notes, and snippets.

Created November 14, 2013 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5ef4b235bddf04753101 to your computer and use it in GitHub Desktop.
Save anonymous/5ef4b235bddf04753101 to your computer and use it in GitHub Desktop.
#!/bin/bash
FTP_USER="$1";
FTP_PASSWORD="$2";
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> <ftp_password>";
[ -z "$FTP_PASSWORD" ] && DieWithError "Usage: $0 <ftp_login> <ftp_password>";
[ $CHECK_LOGIN -eq 0 ] && DieWithError "Error: the specified login does not exist";
echo -e "${FTP_PASSWORD}\n${FTP_PASSWORD}\n" | pure-pw passwd "${FTP_USER}" &> /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