웹마스터 팁

계정 추가하는 부분입니다.
편리님이 만드신 부분에 계정 쿼터부분 조금 업데이트하였습니다.

#File Name : adduser.sh
#!/bin/bash
# Usage : ./adduser.sh id password e-mail
# 2002/11/3 최초 작성 (created by 편리)
# 2002/11/4 제로보드 설치지원 추가,
#                메일보내기 지원, 안내페이지 변경, 사용자 체크
# 2002/12/4 (updated by mildsoft, powerjava )
# 날짜와 시간 얻기
dateis=$(date -I)
timeis=$(date | awk '{print $4}')

# 사용자 계정 생성 ( 사용자 체크 )
# public_html 은 /etc/skel/ 에 위치해서 계정생성시 자동으로 생성
# public_html 퍼미션은 /etc/skel 생성 후 퍼미션 지정 해주면 지정해준 퍼미션으로 생성됨
# user 추가시 해당 유저 디렉토리 퍼미션은 /etc/login.defs 에 UMASK    076 을 추가해 퍼미션이701 로 생성  된다.

        if useradd -g hosting $1
        then
        echo $2 | /usr/bin/passwd --stdin $1

# 제로보드 설치 지원
#        echo -n "Zeroboard Install - [Y/N](default N) : "
#        read zero
#        if [ "$zero" = "y" ] || [ "$zero" = "Y" ]; then
#                 cp -R /home/참조할계정/public_html/bbs/ /home/$1/public_html/
#                 chmod 707 /home/$1/public_html/bbs
#        fi

# weblogs 디렉토리 생성 (webalizer 실행 결과 출력 디렉토리)
         mkdir /home/$1/public_html/weblogs

# Mysql 에 새로운 DB 를 추가합니다.
        touch /tmp/mysql_dbusersetup_temp
        echo "create database $1;" >> /tmp/mysql_dbusersetup_temp
        echo "insert into db values('localhost','$1','$1','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');" >> /tmp/mysql_dbusersetup_temp
        echo "insert into user values('localhost','$1',password('$2'),'N','N','N','N','N','N','N','N','N','N','N','N','N'+ ','N');" >> /tmp/mysql_dbusersetup_temp
        /usr/bin/mysql -u root -p@비번 mysql < /tmp/mysql_dbusersetup_temp
        rm -f /tmp/mysql_dbusersetup_temp
        /usr/bin/mysqladmin -u root -p@비번 reload

# quota 설정
         edquota -p 참조할계정 `awk -F: '$3 > 499 {print $1}' /etc/passwd`

# 아파치 가상호스트 추가 (httpd.conf 마지막에 include conf/vhost.conf 추가 )
         echo " " >> /etc/httpd/conf/ezca.conf
         echo "<VirtualHost 211.214.161.67>" >> /etc/httpd/conf/ezca.conf
         echo "    ServerAdmin $3" >> /etc/httpd/conf/ezca.conf
         echo "    DocumentRoot /home/$1/public_html" >> /etc/httpd/conf/ezca.conf
         echo "    ServerName  $1.ezca.net" >> /etc/httpd/conf/ezca.conf
         echo "    ThrottlePolicy Volume 1000M 1d" >> /etc/httpd/conf/ezca.conf
         echo "    ErrorLog /var/weblog/$1-error_log" >> /etc/httpd/conf/ezca.conf
         echo "    CustomLog /var/weblog/$1-access_log common env=!not_log" >> /etc/httpd/conf/ezca.conf
         echo "</VirtualHost>" >> /etc/httpd/conf/ezca.conf

# 사용자별 Webalizer 설정
        echo "LogFile        /var/weblog/$1-access_log" >> /etc/webalizer/$1-webalizer.conf
        echo "LogType   clf" >> /etc/webalizer/$1-webalizer.conf
        echo "OutputDir      /home/$1/public_html/weblogs" >> /etc/webalizer/$1-webalizer.conf
        echo "HistoryName       webalizer.hist" >> /etc/webalizer/$1-webalizer.conf
        echo "Incremental       yes" >> /etc/webalizer/$1-webalizer.conf
        echo "IncrementalName   webalizer.current" >> /etc/webalizer/$1-webalizer.conf
        echo "HostName       $1.ezca.net" >> /etc/webalizer/$1-webalizer.conf
        echo "PageType  htm*" >> /etc/webalizer/$1-webalizer.conf
        echo "PageType  cgi" >> /etc/webalizer/$1-webalizer.conf
        echo "PageType  php" >> /etc/webalizer/$1-webalizer.conf
        echo "PageType  php3" >> /etc/webalizer/$1-webalizer.conf

        echo "/usr/bin/webalizer -c /etc/webalizer/$1-webalizer.conf" >> /root/webalizer.cron
       chmod 755 /home/$1/public_html/weblogs
# 안내페이지( index.html) 생성
# /etc/skel/public_html 에 index.html 과 gif 파일 위치
# index.html 파일에 아래 안내페이지 내용 전의 tag 는 이미 포함되어 있음
# 아래 내용은 그 다음부터 추가되는 것임

        echo "                 <td><p><b>EZCA의 가족이 되신 것을 진심으로 축하드립니다!!<br>" >> /home/$1/public_html/index.html
        echo "                          현재($dateis $timeis) $1 님의 계정 세팅 작업이 완료되었습니다.<br>" >> /home/$1/public_html/index.html
        echo "                          아래 내용은 신청하신 정보입니다.</b><br><br>" >> /home/$1/public_html/index.html
        echo "                          ID : $1 / 신청하신 Password / E-mail : $3<br>" >> /home/$1/public_html/index.html
        echo "                          웹주소 : http://$1.ezca.net<br>" >> /home/$1/public_html/index.html
        echo "                          FTP : ftp.ezca.net / SSH : ssh.ezca.net <br>" >> /home/$1/public_html/index.html
      #  if [ "$zero" = "y" ] || [ "$zero" = "Y" ]; then
      #  echo "                          제로보드 설치지원 : <a
#href=http://$1.ezca.net/bbs/install.php target=_blank>제로보드설치</a><br><br>" >>
#/home/$1/public_html/index.html
#       else
        echo "                          <br>" >> /home/$1/public_html/index.html
  #      fi
        echo "                          <b>기타 문의 사항은 </b><a href=http://ezca.net><b>http://ezca.net</b></a><b> 을 방문해 주시기 바랍니다</b></p>" >> /home/$1/public_html/index.html
        echo "                          </td>" >> /home/$1/public_html/index.html
        echo "              </tr>" >> /home/$1/public_html/index.html
        echo "            </table>" >> /home/$1/public_html/index.html
        echo "          </td>" >> /home/$1/public_html/index.html
        echo "          <td bgcolor=#76CBED width=1></td>" >> /home/$1/public_html/index.html
        echo "        </tr>" >> /home/$1/public_html/index.html
        echo "        <tr>" >> /home/$1/public_html/index.html
        echo "          <td colspan=3><img src=title_error02.gif width=586 height=9 border=0></td>" >> /home/$1/public_html/index.html
        echo "        </tr>" >> /home/$1/public_html/index.html
        echo "      </table>" >> /home/$1/public_html/index.html
        echo "     </td>" >> /home/$1/public_html/index.html
        echo "  </tr>" >> /home/$1/public_html/index.html
        echo "</table>" >> /home/$1/public_html/index.html
        echo "        </td>" >> /home/$1/public_html/index.html
        echo "    </tr>" >> /home/$1/public_html/index.html
        echo "</table>" >> /home/$1/public_html/index.html
        echo " </body>" >> /home/$1/public_html/index.html
        echo "</html>" >> /home/$1/public_html/index.html
        chmod 755 /home/$1/public_html/index.html  
# 계정 발급 완료 메일 보내기
        title="계정 발급 안내 입니다."          # 메일 제목

        echo " 계정 발급 및 세팅이 완료되었습니다." > /tmp/contents         # 보낼 메일 내용
        echo " ==================================" >> /tmp/contents      # 보낼 메일 내용
        echo " 계정 세팅이 완료 되었습니다. ($dateis $timeis)" >> /tmp/contents
        echo " 아래는 신청하신 정보입니다. 확인해보세요." >> /tmp/contents
        echo " 확인 후 일치하지 않으면 메일 (mildsoft@korea.com) 주세요.</b>" >> /tmp/contents
        echo " " >> /tmp/contents
        echo " ID : $1" >> /tmp/contents
        echo " PASS : $2" >> /tmp/contents
        echo " e-mail : $3" >> /tmp/contents
        echo " " >> /tmp/contents
        echo " WEB주소 : http://$1.ezca.net" >> /tmp/contents
        echo " FTP주소 : ftp.ezca.net " >> /tmp/contents
        echo " SSH주소 : ssh.ezca.net " >> /tmp/contents
        echo " " >> /tmp/contents
        echo " 웹주소로 접속하면 안내페이지를 보실 수 있습니다." >> /tmp/contents
        echo " " >> /tmp/contents
        echo " 트래픽 보기 : http://$1.ezca.net/throttle-me">>/tmp/contents
        echo " " >>/tmp/contents
        echo " DB 관리: http://$1.ezca.net/phpMyAdmin/">>/tmp/contents
        echo " " >>/tmp/contents
        echo " DB 아이디와 패스워드는 계정 과 동일합니다.">>/tmp/contents
        echo " " >>/tmp/contents
    
        echo " 기타 궁금하신 점은 http://ezca.net 을 방문해주세요." >> /tmp/contents

        cat /tmp/contents >> /tmp/data.txt
        rm -f /tmp/contents

        mail -s "$title" $3 < /tmp/data.txt
        rm -f /tmp/data.txt

# 아파치 서버 재 구동
         /etc/init.d/httpd restart

        exit 0

         else
         echo " User $1 already exist!!"
         exit 1

        fi
계정 삭제하는 부분입니다.
위에 소스랑 연동됩니다.
#!/bin/bash
# Usage : ./deluser.sh id email
# Create by mildsoft ( mildsoft@korea.com)
# 2002/12/2 최초 작성

# 날짜와 시간 얻기
dateis=$(date -I)
timeis=$(date | awk '{print $4}')

# 사용자 계정 삭제

     if userdel -r $1
     then

         clear
         echo ">> UserDEL Setting Ok!!"
         echo "----------------------------------------------------------"


# Mysql 에 있는 DB 삭제.
        touch /tmp/mysql_dbusersetup_temp
        echo "drop database $1;" >> /tmp/mysql_dbusersetup_temp
        echo "delete from db where Db = '$1';" >> /tmp/mysql_dbusersetup_temp
        echo "delete from user where User = '$1';" >> /tmp/mysql_dbusersetup_temp
        /usr/bin/mysql -u root -p@비번 mysql < /tmp/mysql_dbusersetup_temp
        rm -f /tmp/mysql_dbusersetup_temp
        /usr/bin/mysqladmin -u root -p@비번 reload


# 아파치 가상호스트 추가 (httpd.conf 마지막에 include conf/ezca.conf 추가 )
        php -q deluser.php login=$1

# 사용자별 Webalizer 설정
                rm -f /etc/webalizer/$1-webalizer.conf
                
# 안내페이지( index.html) 생성
# /etc/skel/public_html 에 index.html 과 gif 파일 위치
# index.html 파일에 아래 안내페이지 내용 전의 tag 는 이미 포함되어 있음
# 아래 내용은 그 다음부터 추가되는 것임

# 계정 발급 완료 메일 보내기
        title="계정 삭제 통보 입니다."          # 메일 제목

        echo " 계정 삭제가 완료되었습니다." > /tmp/contents         # 보낼 메일 내용
        echo " ==================================" >> /tmp/contents      # 보낼 메일 내용
        echo " 계정이 삭제되었습니다. ($dateis $timeis)" >> /tmp/contents

        cat /tmp/contents >> /tmp/data.txt
        rm -f /tmp/contents

        mail -s "$title" $2 < /tmp/data.txt
        rm -f /tmp/data.txt

# 아파치 서버 재 구동
         /etc/init.d/httpd restart

        exit 0

         else
         echo " User $1 already deleted!!"
         exit 1

        fi

php script 부분입니다.
apache 모듈로 인스톨되어서 php 명령어가 안먹히면
lynx를 통해서 강제실행시키세요 ^^

#!/usr/local/bin/php -q
<?php
// Create by mildsoft ( mildsoft@korea.com)

        function get_commandline()
        {
                global $argc, $argv;
        
                for ($i=0; $i<$argc; $i++)
                {
                        $my_args = array();
                        if (ereg("(.*)=(.*)", $argv[$i], $my_args))
                        {
                        $GLOBALS[$my_args[1]] = $my_args[2];
                        }
                }
        }

        function zWriteFile($filename, $str) {
                $f = fopen($filename,"w");
                $lock=flock($f,2);
                if($lock) {
                        fwrite($f,$str);
                }
                flock($f,3);
                fclose($f);
        }
        
        get_commandline();

        $vhost_path = "/etc/httpd/conf/ezca.conf";
        $domain_name = ".ezca.net";
        
        $f=fopen($vhost_path,"r");
        $vhost = fread($f,filesize($vhost_path));
        fclose($f);

        list($front_part,$end_part) = split("$login$domain_name",$vhost);

        $arr_front = split('<VirtualHost',$front_part);
        $cnt_front = count($arr_front);
        $tar_front = '<VirtualHost'.$arr_front[$cnt_front-1];

        $arr_end = split('</VirtualHost>',$end_part);
        $tar_end = $arr_end[0].'</VirtualHost>';

        $tar_ref = "$tar_front$login$domain_name$tar_end";
        $result_ref = eregi_replace("n$tar_ref","",$vhost);
        
        zWriteFile($vhost_path, $result_ref);

        $webcron_path = "/root/webalizer.cron";
        $f=fopen($webcron_path,"r");
        $webcron = fread($f,filesize($webcron_path));
        fclose($f);

        $result_ref2 = eregi_replace("n/usr/bin/webalizer -c /etc/webalizer/$login-webalizer.conf","",$webcron);

        zWriteFile($webcron_path, $result_ref2);
?>
제목 글쓴이 날짜
XE 위키 댓글 삭제 오류수정 [1] 뒤뒤 2013.08.03
[애드온]글 , 댓글 삭제시 휴지통으로 보내기 [13] file 민채아빠 2013.01.16
방명록 모듈 1.5.1.1에서 비회원이 남긴글 삭제하기 조슈아킴 2013.02.14
Admin 페이지에서 사이트맵 삭제가 안될 때 file FontBox 2012.10.06
게시판 확장변수 설명 삭제 안 되는 버그 해결방법 sejin7940 2012.08.30
회원가입폼 비밀번호 찾기 질문/답변 삭제및 필수항목 선택 (송동우님 팁) 때린데 또때려 2012.04.08
bodex 게시판 댓글 삭제 안 되는 문제(해결) NA답답이 2012.01.28
관리권한 가져도 댓글이 수정/삭제 안 되는 경우.. [4] sejin7940 2011.02.14
삭제문제~ [2] 달맞이꽃 2007.08.15
사용자 계정 자동 삭제 (servu4.0) 이성헌 2005.12.15
서버의 지워지지 않는 파일삭제 - 명령어 이성헌 2005.12.15
[계정삭제 스크립터] 편리님이 만드신 계정추가랑 연동됩니다. [4] file 김동현 2002.12.04
리눅스 mysql 사용자 계정주기/삭제하기 [4] 정인배 2002.11.22
[Lindox] 실수로 기본 명령어삭제시 강제 복구하기 NeSTY♨™ 2002.11.05
특정 파일(ex: mp3,avi,mpg)만 찾아서 자동으로 삭제하기! 임현 2002.06.27
MySQL DB(디비)와 Table(테이블) Delete(삭제/초기화)하는 방법 [16] 차카게살자 2002.01.01
웹 계정에서 지워지지 않는 폴더 및 파일 삭제하는 방법 [3] Rising.kr 2008.01.24
[PHP 동영상강의] 38. 삭제시 비밀번호 물어보기 [6] 서기 2006.01.26
[PHP 동영상강의] 33. 자료를 삭제해보자. [6] 서기 2006.01.12
서브디렉토리,파일까지 모두 삭제하는 함수. [5] Lepas 2004.08.24