Ok, so I'm building a webserver and MySQL server from scratch...
Server A is going to have Apache and PHP Server B is going to have MySQL Both servers are running Ubuntu 12.04 LTS server
I plan on letting my family and friends have their own accounts (like a REAL web host!) and have decided to attempt to script the account creation process. Now, I can do simple one liners in Linux or DOS batch script the heck out of what I want to do, but full blown shell scripts scare me.
So, here's what I have... Will it work without catastrophic meltdown???
REM Lets prompt for the user info...
echo -n "Please enter the new username: "
read user
echo -n "Enter the default password: "
read password
home=/var/www/$user
REM Create the user and assign the password
sudo useradd $user
net user $user $password
REM Create them an account on the MySQL server
database='$user'_db
mysql [mysql-server-hostname] -u root@[hostname] -p [pass] -e "create user '$user'@'%' identified by '$password';"
mysql [mysql-server-hostname] -u root@[hostname] -p [pass] -e "create database $database;"
mysql [mysql-server-hostname] -u root@[hostname] -p [pass] -e "grant all on '$database'.* to '$user'@%;"
REM Making some dirs
mkdir $home
mkdir $home/public_html
mkdir $home/public_ftp
usermod -m -d $home
REM Gotta let them have access
chown -R $user:$user $home
chmod 755 $home/public_html
chmod 755 $home/public_ftp
REM Add to some groups
useradd -G sftp $user
useradd -G ftp $user
useradd -G ssh $user
/etc/init.d/apache2 restart
REM
to#
(or, to be fancy, addREM() { :; }