Hello guys,
I've got a little problem using user_create_post.sh. When a user is created I want a database created and sql file inserted. I use the following user_create_post.sh and it works:
Now we have different resellers so some of the resellers wants a different sql file inserted.
I made the following script
This doesn't work. When I change the creator to creator='reseller' it works. Can somebody help me out?
I've got a little problem using user_create_post.sh. When a user is created I want a database created and sql file inserted. I use the following user_create_post.sh and it works:
Code:
# Read DA mysql connection
DA_MYSQL=/usr/local/directadmin/conf/mysql.conf
DA_USER=`cat $DA_MYSQL | grep user= | cut -d= -f2`
DA_PASS=`cat $DA_MYSQL | grep passwd= | cut -d= -f2`
NEW_DB="${username}_database"
NEW_USER="${username}@localhost"
# create database
mysql -u $DA_USER -p$DA_PASS --execute="CREATE DATABASE $NEW_DB"
#create user
mysql -u $DA_USER -p$DA_PASS --execute="GRANT ALL on $NEW_DB.* to $NEW_USER identified by '${passwd}'"
#create default user
NEW_USER="${username}_usr@localhost"
mysql -u $DA_USER -p$DA_PASS --execute="GRANT ALL on $NEW_DB.* to $NEW_USER identified by '${passwd}'"
#create default layout
mysql -u$DA_USER -p$DA_PASS $NEW_DB < /home/sql.sql
Now we have different resellers so some of the resellers wants a different sql file inserted.
I made the following script
Code:
#!/bin/sh
creator=`grep creator /usr/local/directadmin/data/users/${username}/user.conf | cut -f2 -d"="`
DA_MYSQL=/usr/local/directadmin/conf/mysql.conf
DA_USER=`cat $DA_MYSQL | grep user= | cut -d= -f2`
DA_PASS=`cat $DA_MYSQL | grep passwd= | cut -d= -f2`
NEW_DB="${username}_database"
NEW_USER="${username}@localhost"
# create database
mysql -u $DA_USER -p$DA_PASS --execute="CREATE DATABASE $NEW_DB"
#create user
mysql -u $DA_USER -p$DA_PASS --execute="GRANT ALL on $NEW_DB.* to $NEW_USER identified by '${passwd}'"
#create default user
NEW_USER="${username}_usr@localhost"
mysql -u $DA_USER -p$DA_PASS --execute="GRANT ALL on $NEW_DB.* to $NEW_USER identified by '${passwd}'"
if [ "$creator" = "reseller" ]; then
#create default layout
mysql -u$DA_USER -p$DA_PASS $NEW_DB < /home/reseller.sql
fi
This doesn't work. When I change the creator to creator='reseller' it works. Can somebody help me out?