Showing posts with label ftp. Show all posts
Showing posts with label ftp. Show all posts

Thursday, 25 November 2010

vsftpd centos mysql user create script

If you have settup Vsftpd with mysql you will like a small script which creates the user folder and user/password in mysql

hope it helps someone..

#!/bin/bash

EXPECTED_ARGS=2
E_BADARGS=65
MYSQL=`which mysql`

mkdir /home/vsftpd/$1
chown -R vsftpd:vsftpd /home/vsftpd

Q1="USE vsftpd;"
Q2="INSERT INTO accounts (username, pass) VALUES('$1', md5('$2'));"
Q3="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}"

if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: $0 user password"
exit $E_BADARGS
fi

$MYSQL -uroot -p -e "$SQL"