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"
No comments:
Post a Comment