사용자 계정 + mysql 계정 추가 스크립트사용자 계정 + mysql 계정 추가 스크립트
Posted at 2010. 10. 5. 12:59 | Posted in Server사용자 계정 + mysql 계정 추가 스크립트
사용자 계정 추가 쉘 스크립트
사용법 => /root/script/newuser 사용자ID
vi /root/script/newuser
------------------------------------------------------------------------------
#!/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
/usr/local/mysql/bin/mysql -uroot -p97081056 < ./mysql_useradd.sql
cat ./mysql_useradd.sql
rm -rf ./mysql_useradd.sql
'Server' 카테고리의 다른 글
리눅스 실행 레벨 (run level) (0) | 2010.10.05 |
---|---|
vsftp에서 500 OOPS: cannot change directory 오류가 나올 때 (0) | 2010.10.05 |
리눅스 시스템 시간 확인 및 시간 맞추기 (0) | 2010.10.05 |
ncftp 를 이용한 백업 스크립트 (0) | 2010.10.05 |
TAR명령. TAR압축묶기 압축풀기 (0) | 2010.10.05 |