Computer/Linux

우분투 사용자 추가 스크립

ICARUS㈜ 2008. 11. 17. 16:26
반응형

#!/bin/bash
clear

echo ==================================================================
echo "                     UserAdd Process Start                      "
echo ==================================================================

echo -n "User Name : "
read username

useradd $username

echo ------------------------

echo PassWord Setting

echo ------------------------
passwd $username

 echo ==================================================================
echo "                     www root directory making                      "
echo ==================================================================

echo

echo -n "www root Directory path : "

echo /home/$username/public_html

mkdir -p /home/$username/public_html

 

echo ==================================================================
echo "             root directory setting & test index.php making     "
echo ==================================================================

chmod 775 /home/$username
chmod 775 /home/$username/public_html
chown $username.$username /home/$username/public_html

echo " " >>/home/$username/public_html/index.php
echo "<? phpinfo(); ?>" >> /home/$username/public_html/index.php

chown $username.$username /home/$username/public_html/index.php
chmod 775 /home/$username/public_html/index.php

 

echo checking -----------------------------------------------------------

ls -al /home/$username

echo checking -----------------------------------------------------------

ls -al /home/$username/public_html

 


echo ==================================================================
echo "                        MySQL useradd"
echo ==================================================================

echo "Username : $username"

echo "dbname : $username"

echo -n "User p/w : "
read userpw

echo " " >> mysql_useradd.sql

echo "use mysql" >> mysql_useradd.sql

echo "create database $username;" >> mysql_useradd.sql

echo "insert into user (host, user, password) values ('localhost', '$username', password('$userpw'));" >> mysql_useradd.sql

echo "insert into db values ('localhost', '$username', '$username', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');" >> mysql_useradd.sql

echo "FLUSH PRIVILEGES;" >> mysql_useradd.sql

mysql -uroot -p97081056 < ./mysql_useradd.sql

cat ./mysql_useradd.sql
rm -rf ./mysql_useradd.sql

apache2 서비스 오류=======================
 /etc/apache2/mods-enabled 여기에서
ln -s ../mods-available/userdir.load
ln -s ../mods-available/userdir.conf
우선해결

mysql User 사용자 추가시 오류발생 ==============
DB 계정 생성은 수동으로 처리합니다.

mysql> GRANT ALL PRIVILEGES ON *.* TO '사용자명'@'localhost' IDENTIFIED BY '패스워드' WITH GRANT OPTION;

FLUSH PRIVILEGES;