#!/bin/bash
#########################################################
#####웹호스팅사용자 셋팅스크립트: AutoMaster V 1.0
######################################################
# 1. 제작자
# -수퍼유저코리아 운영자 박성수 (nickname : 헐렁고수)
# - Email : papa@superuser.co.kr
# 2. 저작권
# 이 프로그램의 저작권은 위의 제작자(수퍼유저코리아)에게
# 있으며, 수퍼유저코리아(www.superuser.co.kr)의회원이
되신분에 한해 #사전허락없이 사용이 가능합니다.
# 단, 상업적인 사용은 수퍼유저코리아의 동의를 얻어야만 합니다.
#
#########################################################
# 변수선언
export hostip_address="211.174.58.43"
export name_server="ns.superuser.co.kr"
#임시파일 삭제
rm -f /tmp/httpd.conf_tempfile
rm -f /tmp/named.conf_tempfile
rm -f /tmp/zone_tempfile
rm -f /tmp/logfile_tempfile
rm -f /tmp/aw.cfg_tempfile
#임시파일 생성
touch /tmp/httpd.conf_tempfile
touch /tmp/named.conf_tempfile
touch /tmp/zone_tempfile
touch /tmp/logfile_tempfile
touch /tmp/aw.cfg_tempfile
#사용자생성및 패스워드 설정
/usr/sbin/useradd -m -s /bin/bash -d /home/$1 -g
webhost $1
echo " Please input mysql Administrator's passwd" passwd $1
#용량설정
edquota -u $1
#홈페이지디렉토리생성및 설정
chmod 701 /home/$1
# 홈디렉토리(/home/user)를 701로
설정하는 것이 좋습니다.
# 다른 일반사용자들은 cd 명령어로 들어올 수 없으며
# Apache(httpd)로 홈페이지는 보여줄수 있습니다.
# 디렉토리에서 rwx 의 x는 cd 가능을 의미하며,
# r은 들어와서 ls가능을 의미합니다.
mkdir /home/$1/www
chmod 705 /home/$1/www
chown $1:webhost /home/$1/www
mkdir /home/$1/www/weblog
chmod 705 /home/$1/www/weblog
chown $1:webhost /home/$1/www/weblog
#사용자의 접속통계를사용자의 관리자만이 볼수 있도록 접근제한을 설정합니다.
touch /home/$1/www/weblog/.htaccess
echo "AuthName \"$2 Administrator\"" >> /home/$1/www/weblog/.htaccess
echo "AuthType Basic" >> /home/$1/www/weblog/.htaccess
echo "AuthUserFile /home/$1/www/weblog/.htpasswd" >>
/home/$1/www/weblog/.htaccess
echo "AuthGroupFile /dev/null" >>
/home/$1/www/weblog/.htaccess
echo "<Limit GET POST>" >> /home/$1/www/weblog/.htaccess
echo "require valid-user" >> /home/$1/www/weblog/.htaccess
echo "</Limit>" >> /home/$1/www/weblog/.htaccess
echo " Please input Administrator's passwd"
htpasswd -c /home/$1/www/weblog/.htpasswd $1
cp /sbin/index.html /home/$1/www/index.html
chmod 755 /home/$1/www/index.html
chown $1:webhost /home/$1/www/index.html
mkdir /home/$1/www/cgi-bin
chmod 755 /home/$1/www/cgi-bin
chown $1:webhost /home/$1/www/cgi-bin
mkdir /home/$1/www_log
chmod 705 /home/$1/www_log
chown $1:webhost /home/$1/www_log
#가상호스트설정
#vi /usr/local/apache/conf/httpd.conf
echo "<VirtualHost $hostip_address>" >>
/tmp/httpd.conf_tempfile
echo " ServerAdmin $1@$2"
>> /tmp/httpd.conf_tempfile
echo " DocumentRoot /home/$1/www"
>> /tmp/httpd.conf_tempfile
echo " ServerName www.$2"
>> /tmp/httpd.conf_tempfile
echo " ErrorLog /home/$1/www_log/error_log"
>> /tmp/httpd.conf_tempfile
echo " CustomLog /home/$1/www_log/access_log
common" >> /tmp/httpd.conf_tempfile
echo "</VirtualHost>" >>
/tmp/httpd.conf_tempfile
cat /tmp/httpd.conf_tempfile >> /usr/local/apache/conf/httpd.conf
#도메인설정
#vi /etc/named.conf
echo "zone \"$2\" {" >>
/tmp/named.conf_tempfile
echo " type master;" >>
/tmp/named.conf_tempfile
echo " file
\"$2.zone\";" >>
/tmp/named.conf_tempfile
echo "};" >>
/tmp/named.conf_tempfile
cat /tmp/named.conf_tempfile >> /etc/named.conf
#cp /var/named/default.zone /var/named/$2.zone
#vi /var/named/$2.zone
#/var/named/domain.zone파일 생성
#echo "@ IN SOA www.$2.
$1.$2. (" >> /tmp/zone_tempfile
#SOA 바로위의 도메인을 ns.superuser.co.kr로 수정함. echo "$TTL 86400 " >> /tmp/zone_tempfile
echo "@ IN SOA ns.superuser.co.kr. $1.$2. (" >>
/tmp/zone_tempfile
echo " 20000402
; Serial" >> /tmp/zone_tempfile
echo " 21600 ; Refresh(6h)"
>> /tmp/zone_tempfile
echo " 900 ;
Retry(15min)" >> /tmp/zone_tempfile
echo " 604800 ; Expire(7d)" >>
/tmp/zone_tempfile
echo " 43200) ; Minimum(12h);" >>
/tmp/zone_tempfile
echo " IN NS $name_server."
>> /tmp/zone_tempfile
echo ";" >> /tmp/zone_tempfile
echo " IN A
$hostip_address" >> /tmp/zone_tempfile
echo " IN MX 0
$2." >> /tmp/zone_tempfile
echo "www IN A
$hostip_address" >> /tmp/zone_tempfile
echo " IN MX 0
$2." >> /tmp/zone_tempfile
cp /tmp/zone_tempfile /var/named/$2.zone
#메일설정(SMTP)
#vi /etc/sendmail.cw
echo $2 >> /etc/sendmail.cw
echo $2 >> /etc/mail/relay-domains
echo "webmaster@$2 $1" >>
/etc/mail/virtusertable
#로그분석설정
#vi /usr/local/aw/accesswatch-start
#accesswatch-start파일에 사용자의 로그분석 시작스크립트 입력
echo "$2로그분석중입니다."
>>
/tmp/logfile_tempfile
echo "/usr/local/aw/aw-parser.pl -c /usr/local/aw/cfg/$2.cfg"
>> /tmp/logfile_tempfile
echo "/usr/local/aw/aw-report.pl -c /usr/local/aw/cfg/$2.cfg"
>> /tmp/logfile_tempfile
cat /tmp/logfile_tempfile >>
/usr/local/aw/accesswatch-start
#/usr/local/aw/cfg디렉토리에 사용자의 로그분석환경설정파일
작성
#cp /usr/local/aw/cfg/default.cfg /usr/local/aw/cfg/$2.cfg
#vi /usr/local/aw/cfg/$2.cfg
echo "#################################################" >>
/tmp/aw.cfg_tempfile
echo "##### Accesswatch Config File Setup #####"
>> /tmp/aw.cfg_tempfile
echo "#################################################" >>
/tmp/aw.cfg_tempfile
echo "\$accessLog = \"/home/$1/www_log/access_log\";"
>> /tmp/aw.cfg_tempfile
echo "\$DNSlookups = 0;" >> /tmp/aw.cfg_tempfile
echo "\$defaultPage = \"index.html\";" >>
/tmp/aw.cfg_tempfile
echo "\$includeURL = \".*\";" >>
/tmp/aw.cfg_tempfile
echo "\$compressdata = 1;" >> /tmp/aw.cfg_tempfile
echo "\$compresscommand = \"gzip
-9fc\";" >> /tmp/aw.cfg_tempfile
echo "\$catcompresscommand = \"gunzip -c\";" >> /tmp/aw.cfg_tempfile
echo "\$compresssuffix = \"gz\";"
>> /tmp/aw.cfg_tempfile
echo "\$excludeURL = \".gif\|.jpg\|.jpeg\|.xbm\";"
>> /tmp/aw.cfg_tempfile
echo "\$reportBase = \"/home/$1/www/weblog\";" >>
/tmp/aw.cfg_tempfile
echo "\$siteName = \"www.$2\";" >>
/tmp/aw.cfg_tempfile
echo "\$siteBaseURL = \"http://www.$2\";" >>
/tmp/aw.cfg_tempfile
echo "\$orgname = \"www.$2\";" >>
/tmp/aw.cfg_tempfile
echo "\$orgdomain = \"$2\";" >>
/tmp/aw.cfg_tempfile
echo "\$excludeHosts = \"\";" >> /tmp/aw.cfg_tempfile
echo "################################################" >>
/tmp/aw.cfg_tempfile
echo "##### Program
Options #####"
>> /tmp/aw.cfg_tempfile
echo "################################################" >>
/tmp/aw.cfg_tempfile
echo "\$maxPagesToList = -1;" >> /tmp/aw.cfg_tempfile
echo "\$maxDomainsToList = -1;" >> /tmp/aw.cfg_tempfile
echo "\$maxHostsToList = 15;" >> /tmp/aw.cfg_tempfile
echo "\$maxRefsToList = 10;" >> /tmp/aw.cfg_tempfile
echo "\$maxAgentsToList = 15;" >> /tmp/aw.cfg_tempfile
echo "\$customFooter = <<EOM;" >> /tmp/aw.cfg_tempfile
echo "<!-- START custom footer -->" >>
/tmp/aw.cfg_tempfile
echo "$2" >> /tmp/aw.cfg_tempfile
echo "<!-- END custom footer -->" >>
/tmp/aw.cfg_tempfile
echo "EOM" >> /tmp/aw.cfg_tempfile
echo "1;" >> /tmp/aw.cfg_tempfile
echo "###############################################" >>
/tmp/aw.cfg_tempfile
echo "####### End - AccessWatch Custom Configuration #######"
>> /tmp/aw.cfg_tempfile
echo "###############################################" >>
/tmp/aw.cfg_tempfile
cp /tmp/aw.cfg_tempfile /usr/local/aw/cfg/$2.cfg
#User Counter datafile Setting (Version 0.31
upgrade)
touch /usr/local/apache/Counter/data/$1.dat
chmod 644 /usr/local/apache/Counter/data/$1.dat
chown nobody:webhost /usr/local/apache/Counter/data/$1.dat
cat /usr/local/apache/Counter/data/counter_default_digit.dat >> $1.dat
#사용자의 게시판을 생성합니다.
#게시판 작업1 게시판파일을 복사하고 권한및 파일수정을 합니다.
cd /home/nice/www/
cp -r niceboard /home/$1/www/niceboard/
cd /home/$1/www/
chown -R $1:webhost niceboard
cd /home/$1/www/niceboard/
mv nice.gif $1.gif
mv nice_icon $1_icon
mv nice.cfg $1.cfg
vi auth.inc
vi dbconn.inc
vi $1.cfg
#게시판 작업2 mysql데이터베이스에 사용자에게
필요한 DB작업을 실행합니다.
cd /usr/local/mysql/bin/
vi niceboard-create.sql
vi niceboard-create2.sql
mysql -u root -p niceboard < niceboard-create.sql
mysql -u root -p mysql < niceboard-create2.sql
#사용자의 방명록을 생성합니다.
#방명록작업1 방명록파일을 복사하고 권한및 파일을 수정합니다.
cd /home/nice/www/
cp -r nicebook /home/$1/www/
cd /home/$1/www/
chown -R $1:webhost nicebook
mv nice.cfg $1.cfg
mv nice.gif $1.gif
mv nice_icon $1_icon
cd /home/$1/www/nicebook/
vi auth.inc
vi dbconn.inc
vi $1.cfg
#방명록작업2 mysql데이터베이스에 사용자에게
필요한 DB작업을 실행합니다.
cd /usr/local/mysql/bin/
vi nicebook-create.sql
mysql -u root -p GUESTBOOK < nicebook-create.sql
#게시판 방명록 적용작업mysql reload
echo " Please input mysql Administrator's passwd"
./mysqladmin -u root -p reload
#변수 선언 해제(메모리에서 할당해제)
unset hostip_address
unset name_server
# 관련서버 restart
/etc/rc.d/init.d/named restart
/usr/local/apache/bin/apachectl restart
#메일설정 적용을위한 메일관련DB작업
makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable
|