12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043 |
- #!/bin/bash
- # Author: yeho <lj2007331 AT gmail.com>
- # BLOG: https://blog.linuxeye.com
- #
- # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
- #
- # Project home page:
- # https://oneinstack.com
- # https://github.com/lj2007331/oneinstack
- export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
- clear
- printf "
- #######################################################################
- # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
- # For more information please visit https://oneinstack.com #
- #######################################################################
- "
- . ./options.conf
- . ./include/color.sh
- . ./include/check_dir.sh
- . ./include/check_os.sh
- . ./include/get_char.sh
- # Check if user is root
- [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
- Usage() {
- printf "
- Usage: $0 [ ${CMSG}add${CEND} | ${CMSG}del${CEND} ]
- ${CMSG}add${CEND} --->Add Virtualhost
- ${CMSG}del${CEND} --->Delete Virtualhost
- "
- }
- Choose_env() {
- if [ -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
- Number=111
- while :; do echo
- echo 'Please choose to use environment:'
- echo -e "\t${CMSG}1${CEND}. Use php"
- echo -e "\t${CMSG}2${CEND}. Use java"
- echo -e "\t${CMSG}3${CEND}. Use hhvm"
- read -p "Please input a number:(Default 1 press Enter) " Choose_number
- [ -z "$Choose_number" ] && Choose_number=1
- if [[ ! $Choose_number =~ ^[1-3]$ ]];then
- echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
- else
- break
- fi
- done
- [ "$Choose_number" == '1' ] && NGX_FLAG=php
- [ "$Choose_number" == '2' ] && NGX_FLAG=java
- [ "$Choose_number" == '3' ] && NGX_FLAG=hhvm
- elif [ -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ];then
- Number=110
- while :; do echo
- echo 'Please choose to use environment:'
- echo -e "\t${CMSG}1${CEND}. Use php"
- echo -e "\t${CMSG}2${CEND}. Use java"
- read -p "Please input a number:(Default 1 press Enter) " Choose_number
- [ -z "$Choose_number" ] && Choose_number=1
- if [[ ! $Choose_number =~ ^[1-2]$ ]];then
- echo "${CWARNING}input error! Please only input number 1,2${CEND}"
- else
- break
- fi
- done
- [ "$Choose_number" == '1' ] && NGX_FLAG=php
- [ "$Choose_number" == '2' ] && NGX_FLAG=java
- elif [ -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ];then
- Number=100
- NGX_FLAG=php
- elif [ -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
- Number=101
- while :; do echo
- echo 'Please choose to use environment:'
- echo -e "\t${CMSG}1${CEND}. Use php"
- echo -e "\t${CMSG}2${CEND}. Use hhvm"
- read -p "Please input a number:(Default 1 press Enter) " Choose_number
- [ -z "$Choose_number" ] && Choose_number=1
- if [[ ! $Choose_number =~ ^[1-2]$ ]];then
- echo "${CWARNING}input error! Please only input number 1,2${CEND}"
- else
- break
- fi
- done
- [ "$Choose_number" == '1' ] && NGX_FLAG=php
- [ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
- elif [ ! -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
- Number=011
- while :; do echo
- echo 'Please choose to use environment:'
- echo -e "\t${CMSG}1${CEND}. Use java"
- echo -e "\t${CMSG}2${CEND}. Use hhvm"
- read -p "Please input a number:(Default 1 press Enter) " Choose_number
- [ -z "$Choose_number" ] && Choose_number=1
- if [[ ! $Choose_number =~ ^[1-2]$ ]];then
- echo "${CWARNING}input error! Please only input number 1,2${CEND}"
- else
- break
- fi
- done
- [ "$Choose_number" == '1' ] && NGX_FLAG=java
- [ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
- elif [ ! -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ];then
- Number=010
- NGX_FLAG=java
- elif [ ! -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
- Number=001
- NGX_FLAG=hhvm
- else
- Number=000
- NGX_FLAG=php
- fi
- if [ "$NGX_FLAG" == 'php' ];then
- NGX_CONF=$(echo -e "location ~ [^/]\.php(/|$) {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n }")
- elif [ "$NGX_FLAG" == 'java' ];then
- NGX_CONF=$(echo -e "location ~ {\n proxy_pass http://127.0.0.1:8080;\n include proxy.conf;\n }")
- elif [ "$NGX_FLAG" == 'hhvm' ];then
- NGX_CONF=$(echo -e "location ~ .*\.(php|php5)?$ {\n fastcgi_pass unix:/var/log/hhvm/sock;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\n include fastcgi_params;\n }")
- fi
- }
- Create_self_SSL() {
- printf "
- You are about to be asked to enter information that will be incorporated
- into your certificate request.
- What you are about to enter is what is called a Distinguished Name or a DN.
- There are quite a few fields but you can leave some blank
- For some fields there will be a default value,
- If you enter '.', the field will be left blank.
- "
- echo
- read -p "Country Name (2 letter code) [CN]: " SELFSIGNEDSSL_C
- [ -z "$SELFSIGNEDSSL_C" ] && SELFSIGNEDSSL_C=CN
- echo
- read -p "State or Province Name (full name) [Shanghai]: " SELFSIGNEDSSL_ST
- [ -z "$SELFSIGNEDSSL_ST" ] && SELFSIGNEDSSL_ST=Shanghai
- echo
- read -p "Locality Name (eg, city) [Shanghai]: " SELFSIGNEDSSL_L
- [ -z "$SELFSIGNEDSSL_L" ] && SELFSIGNEDSSL_L=Shanghai
- echo
- read -p "Organization Name (eg, company) [LinuxEye Inc.]: " SELFSIGNEDSSL_O
- [ -z "$SELFSIGNEDSSL_O" ] && SELFSIGNEDSSL_O='LinuxEye Inc.'
- echo
- read -p "Organizational Unit Name (eg, section) [IT Dept.]: " SELFSIGNEDSSL_OU
- [ -z "$SELFSIGNEDSSL_OU" ] && SELFSIGNEDSSL_OU='IT Dept.'
- openssl req -new -newkey rsa:2048 -sha256 -nodes -out $PATH_SSL/${domain}.csr -keyout $PATH_SSL/${domain}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${domain}" > /dev/null 2>&1
- /bin/cp $PATH_SSL/${domain}.csr{,_bk.`date +%Y-%m-%d_%H%M`}
- /bin/cp $PATH_SSL/${domain}.key{,_bk.`date +%Y-%m-%d_%H%M`}
- openssl x509 -req -days 36500 -sha256 -in $PATH_SSL/${domain}.csr -signkey $PATH_SSL/${domain}.key -out $PATH_SSL/${domain}.crt > /dev/null 2>&1
- }
- Create_SSL() {
- if [ -e "/usr/local/bin/certbot-auto" -a -e "/root/.local/share/letsencrypt/bin/letsencrypt" ];then
- while :; do echo
- read -p "Do you want to use a Let's Encrypt certificate? [y/n]: " letsencrypt_yn
- if [[ ! $letsencrypt_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- if [ "$letsencrypt_yn" == 'y' ];then
- PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
- for D in $domain $moredomainame
- do
- Domain_IPADDR=`ping $D -c1 | sed '1{s/[^(]*(//;s/).*//;q}'`
- [ "$PUBLIC_IPADDR" != "$Domain_IPADDR" ] && { echo; echo "${CFAILURE}DNS problem: NXDOMAIN looking up A for $D${CEND}"; echo; exit 1; }
- done
- #add Email
- while :
- do
- echo
- read -p "Please enter Administrator Email(example: admin@linuxeye.com): " Admin_Email
- if [ -z "`echo $Admin_Email | grep '.*@.*\..*'`" ]; then
- echo "${CWARNING}input error! ${CEND}"
- else
- break
- fi
- done
- [ "$moredomainame_yn" == 'y' ] && moredomainame_D="`for D in $moredomainame; do echo -d $D; done`"
- [ "$nginx_ssl_yn" == 'y' ] && S=nginx
- [ "$apache_ssl_yn" == 'y' ] && S=httpd
- [ ! -d "$wwwroot_dir/$domain/.well-known" ] && mkdir -p $wwwroot_dir/$domain/.well-known;chown -R $run_user.$run_user $wwwroot_dir/$domain/.well-known
- certbot-auto certonly --standalone --agree-tos --email $Admin_Email -d $domain $moredomainame_D --pre-hook "service $S stop" --post-hook "service $S start"
- if [ -s "/etc/letsencrypt/live/$domain/cert.pem" ];then
- [ -e "$PATH_SSL/$domain.crt" ] && rm -rf $PATH_SSL/$domain.{crt,key}
- ln -s /etc/letsencrypt/live/$domain/fullchain.pem $PATH_SSL/$domain.crt
- ln -s /etc/letsencrypt/live/$domain/privkey.pem $PATH_SSL/$domain.key
- if [ -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/conf/httpd.conf" ];then
- Cron_Command='/etc/init.d/nginx reload;/etc/init.d/httpd graceful'
- elif [ -e "$web_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ];then
- Cron_Command='/etc/init.d/nginx reload'
- elif [ ! -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/conf/httpd.conf" ];then
- Cron_Command='/etc/init.d/httpd graceful'
- fi
- [ "$OS" == 'CentOS' ] && Cron_file=/var/spool/cron/root || Cron_file=/var/spool/cron/crontabs/root
- [ -z "`grep "$domain $moredomainame_D" $Cron_file`" ] && echo "0 10 * * 1 /usr/local/bin/certbot-auto certonly -a webroot --agree-tos --renew-by-default --webroot-path=$wwwroot_dir/$domain -d $domain $moredomainame_D;$Cron_Command" >> $Cron_file
- else
- echo "${CFAILURE}Error: Let's Encrypt SSL certificate installation failed${CEND}"
- exit 1
- fi
- else
- Create_self_SSL
- fi
- else
- Create_self_SSL
- fi
- }
- Print_ssl() {
- if [ "$letsencrypt_yn" == 'y' ];then
- echo "`printf "%-30s" "Let's Encrypt SSL Certificate:"`${CMSG}/etc/letsencrypt/live/$domain/fullchain.pem${CEND}"
- echo "`printf "%-30s" "SSL Private Key:"`${CMSG}/etc/letsencrypt/live/$domain/privkey.pem${CEND}"
- else
- echo "`printf "%-30s" "Self-signed SSL Certificate:"`${CMSG}$PATH_SSL/${domain}.crt${CEND}"
- echo "`printf "%-30s" "SSL Private Key:"`${CMSG}$PATH_SSL/${domain}.key${CEND}"
- echo "`printf "%-30s" "SSL CSR File:"`${CMSG}$PATH_SSL/${domain}.csr${CEND}"
- fi
- }
- Input_Add_domain() {
- if [ -e "$web_install_dir/sbin/nginx" ];then
- while :; do echo
- read -p "Do you want to setup SSL under Nginx? [y/n]: " nginx_ssl_yn
- if [[ ! $nginx_ssl_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- elif [ ! -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/bin/apachectl" ];then
- while :; do echo
- read -p "Do you want to setup SSL under Apache? [y/n]: " apache_ssl_yn
- if [[ ! $apache_ssl_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- fi
- [ "$apache_ssl_yn" == 'y' ] && { PATH_SSL=$apache_install_dir/conf/ssl; [ ! -d "$PATH_SSL" ] && mkdir $PATH_SSL; }
- [ "$nginx_ssl_yn" == 'y' ] && { PATH_SSL=$web_install_dir/conf/ssl; [ ! -d "$PATH_SSL" ] && mkdir $PATH_SSL; }
- while :; do echo
- read -p "Please input domain(example: www.linuxeye.com): " domain
- if [ -z "`echo $domain | grep '.*\..*'`" ]; then
- echo "${CWARNING}input error! ${CEND}"
- else
- break
- fi
- done
- if [ -e "$web_install_dir/conf/vhost/$domain.conf" -o -e "$apache_install_dir/conf/vhost/$domain.conf" -o -e "$tomcat_install_dir/conf/vhost/$domain.xml" ]; then
- [ -e "$web_install_dir/conf/vhost/$domain.conf" ] && echo -e "$domain in the Nginx/Tengine/OpenResty already exist! \nYou can delete ${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND} and re-create"
- [ -e "$apache_install_dir/conf/vhost/$domain.conf" ] && echo -e "$domain in the Apache already exist! \nYou can delete ${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND} and re-create"
- [ -e "$tomcat_install_dir/conf/vhost/$domain.xml" ] && echo -e "$domain in the Tomcat already exist! \nYou can delete ${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND} and re-create"
- exit
- else
- echo "domain=$domain"
- fi
- while :; do echo
- read -p "Do you want to add more domain name? [y/n]: " moredomainame_yn
- if [[ ! $moredomainame_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- if [ "$moredomainame_yn" == 'y' ]; then
- while :; do echo
- read -p "Type domainname or IP(example: linuxeye.com 121.43.8.8): " moredomain
- if [ -z "`echo $moredomain | grep '.*\..*'`" ]; then
- echo "${CWARNING}input error! ${CEND}"
- else
- [ "$moredomain" == "$domain" ] && echo "${CWARNING}Domain name already exists! ${CND}" && continue
- echo domain list="$moredomain"
- moredomainame=" $moredomain"
- break
- fi
- done
- Apache_Domain_alias=ServerAlias$moredomainame
- Tomcat_Domain_alias=$(for D in `echo $moredomainame`; do echo "<Alias>$D</Alias>"; done)
- if [ -e "$web_install_dir/sbin/nginx" ];then
- while :; do echo
- read -p "Do you want to redirect from $moredomain to $domain? [y/n]: " redirect_yn
- if [[ ! $redirect_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- [ "$redirect_yn" == 'y' ] && Nginx_redirect=$(echo -e "if (\$host != $domain) {\n rewrite ^/(.*)\$ \$scheme://$domain/\$1 permanent;\n }")
- fi
- fi
- if [ "$nginx_ssl_yn" == 'y' ]; then
- if [[ "$($web_install_dir/sbin/nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]]; then
- LISTENOPT='443 ssl http2'
- else
- LISTENOPT='443 ssl spdy'
- fi
- Create_SSL
- Nginx_conf=$(echo -e "listen $LISTENOPT;\nssl_certificate $PATH_SSL/$domain.crt;\nssl_certificate_key $PATH_SSL/$domain.key;\nssl_protocols TLSv1 TLSv1.1 TLSv1.2;\nssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;\nssl_prefer_server_ciphers on;\nssl_session_timeout 10m;\nssl_session_cache builtin:1000 shared:SSL:10m;\nssl_buffer_size 1400;\nadd_header Strict-Transport-Security max-age=15768000;\nssl_stapling on;\nssl_stapling_verify on;\n")
- Apache_SSL=$(echo -e "SSLEngine on\n SSLCertificateFile \"$PATH_SSL/$domain.crt\"\n SSLCertificateKeyFile \"$PATH_SSL/$domain.key\"")
- elif [ "$apache_ssl_yn" == 'y' ]; then
- Create_SSL
- Apache_SSL=$(echo -e "SSLEngine on\n SSLCertificateFile \"$PATH_SSL/$domain.crt\"\n SSLCertificateKeyFile \"$PATH_SSL/$domain.key\"")
- [ -z "`grep 'Listen 443' $apache_install_dir/conf/httpd.conf`" ] && sed -i "s@Listen 80@&\nListen 443@" $apache_install_dir/conf/httpd.conf
- [ -z "`grep 'ServerName 0.0.0.0:443' $apache_install_dir/conf/httpd.conf`" ] && sed -i "s@ServerName 0.0.0.0:80@&\nServerName 0.0.0.0:443@" $apache_install_dir/conf/httpd.conf
- else
- Nginx_conf='listen 80;'
- fi
- while :; do echo
- echo "Please input the directory for the domain:$domain :"
- read -p "(Default directory: $wwwroot_dir/$domain): " vhostdir
- if [ -n "$vhostdir" -a -z "`echo $vhostdir | grep '^/'`" ];then
- echo "${CWARNING}input error! Press Enter to continue...${CEND}"
- else
- if [ -z "$vhostdir" ]; then
- vhostdir="$wwwroot_dir/$domain"
- echo "Virtual Host Directory=${CMSG}$vhostdir${CEND}"
- fi
- echo
- echo "Create Virtul Host directory......"
- mkdir -p $vhostdir
- echo "set permissions of Virtual Host directory......"
- chown -R ${run_user}.$run_user $vhostdir
- break
- fi
- done
- }
- Nginx_anti_hotlinking() {
- while :; do echo
- read -p "Do you want to add hotlink protection? [y/n]: " anti_hotlinking_yn
- if [[ ! $anti_hotlinking_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- if [ -n "`echo $domain | grep '.*\..*\..*'`" ];then
- domain_allow="*.${domain#*.} $domain"
- else
- domain_allow="*.$domain $domain"
- fi
- if [ "$anti_hotlinking_yn" == 'y' ];then
- if [ "$moredomainame_yn" == 'y' ]; then
- domain_allow_all=$domain_allow$moredomainame
- else
- domain_allow_all=$domain_allow
- fi
- anti_hotlinking=$(echo -e "location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {\n valid_referers none blocked $domain_allow_all;\n if (\$invalid_referer) {\n #rewrite ^/ http://www.linuxeye.com/403.html;\n return 403;\n }\n }")
- else
- anti_hotlinking=
- fi
- }
- Nginx_rewrite() {
- [ ! -d "$web_install_dir/conf/rewrite" ] && mkdir $web_install_dir/conf/rewrite
- while :; do echo
- read -p "Allow Rewrite rule? [y/n]: " rewrite_yn
- if [[ ! $rewrite_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- if [ "$rewrite_yn" == 'n' ];then
- rewrite="none"
- touch "$web_install_dir/conf/rewrite/$rewrite.conf"
- else
- echo
- echo "Please input the rewrite of programme :"
- echo "${CMSG}wordpress${CEND},${CMSG}discuz${CEND},${CMSG}opencart${CEND},${CMSG}thinkphp${CEND},${CMSG}laravel${CEND},${CMSG}typecho${CEND},${CMSG}ecshop${CEND},${CMSG}drupal${CEND},${CMSG}joomla${CEND} rewrite was exist."
- read -p "(Default rewrite: other):" rewrite
- if [ "$rewrite" == "" ]; then
- rewrite="other"
- fi
- echo "You choose rewrite=${CMSG}$rewrite${CEND}"
- [ "$NGX_FLAG" == 'php' -a "$rewrite" == "thinkphp" ] && NGX_CONF=$(echo -e "location ~ \.php {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi_params;\n set \$real_script_name \$fastcgi_script_name;\n if (\$fastcgi_script_name ~ \"^(.+?\.php)(/.+)\$\") {\n set \$real_script_name \$1;\n #set \$path_info \$2;\n }\n fastcgi_param SCRIPT_FILENAME \$document_root\$real_script_name;\n fastcgi_param SCRIPT_NAME \$real_script_name;\n #fastcgi_param PATH_INFO \$path_info;\n }")
- if [ -e "config/$rewrite.conf" ];then
- /bin/cp config/$rewrite.conf $web_install_dir/conf/rewrite/$rewrite.conf
- else
- touch "$web_install_dir/conf/rewrite/$rewrite.conf"
- fi
- fi
- }
- Nginx_log() {
- while :; do echo
- read -p "Allow Nginx/Tengine/OpenResty access_log? [y/n]: " access_yn
- if [[ ! $access_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- if [ "$access_yn" == 'n' ]; then
- N_log="access_log off;"
- else
- N_log="access_log $wwwlogs_dir/${domain}_nginx.log combined;"
- echo "You access log file=${CMSG}$wwwlogs_dir/${domain}_nginx.log${CEND}"
- fi
- }
- Create_nginx_tomcat_conf() {
- [ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
- cat > $web_install_dir/conf/vhost/$domain.conf << EOF
- server {
- $Nginx_conf
- server_name $domain$moredomainame;
- $N_log
- index index.html index.htm index.jsp;
- root $vhostdir;
- $Nginx_redirect
- $anti_hotlinking
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
- expires 30d;
- access_log off;
- }
- location ~ .*\.(js|css)?$ {
- expires 7d;
- access_log off;
- }
- $NGX_CONF
- }
- EOF
- if [ "$nginx_ssl_yn" == 'y' -a "$redirect_yn" == 'y' ];then
- cat >> $web_install_dir/conf/vhost/$domain.conf << EOF
- server {
- listen 80;
- server_name $domain$moredomainame;
- rewrite ^/(.*) https://$domain/\$1 permanent;
- }
- EOF
- elif [ "$nginx_ssl_yn" == 'y' ];then
- cat >> $web_install_dir/conf/vhost/$domain.conf << EOF
- server {
- listen 80;
- server_name $domain$moredomainame;
- $N_log
- index index.html index.htm index.jsp;
- root $vhostdir;
- $Nginx_redirect
- $anti_hotlinking
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
- expires 30d;
- access_log off;
- }
- location ~ .*\.(js|css)?$ {
- expires 7d;
- access_log off;
- }
- $NGX_CONF
- }
- EOF
- fi
- cat > $tomcat_install_dir/conf/vhost/$domain.xml << EOF
- <Host name="$domain" appBase="webapps" unpackWARs="true" autoDeploy="true"> $Tomcat_Domain_alias
- <Context path="" docBase="$vhostdir" debug="0" reloadable="false" crossContext="true"/>
- <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
- prefix="${domain}_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
- </Host>
- EOF
- [ -z "`grep -o "vhost-${domain} SYSTEM" $tomcat_install_dir/conf/server.xml`" ] && sed -i "/vhost-localhost SYSTEM/a<\!ENTITY vhost-${domain} SYSTEM \"file://$tomcat_install_dir/conf/vhost/$domain.xml\">" $tomcat_install_dir/conf/server.xml
- [ -z "`grep -o "vhost-${domain};" $tomcat_install_dir/conf/server.xml`" ] && sed -i "s@vhost-localhost;@&\n \&vhost-${domain};@" $tomcat_install_dir/conf/server.xml
- echo
- $web_install_dir/sbin/nginx -t
- if [ $? == 0 ];then
- echo "Reload Nginx......"
- $web_install_dir/sbin/nginx -s reload
- /etc/init.d/tomcat restart
- else
- rm -rf $web_install_dir/conf/vhost/$domain.conf
- echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
- exit 1
- fi
- printf "
- #######################################################################
- # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
- # For more information please visit https://oneinstack.com #
- #######################################################################
- "
- echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
- echo "`printf "%-30s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
- echo "`printf "%-30s" "Tomcat Virtualhost conf:"`${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND}"
- echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
- [ "$nginx_ssl_yn" == 'y' ] && Print_ssl
- }
- Create_tomcat_conf() {
- cat > $tomcat_install_dir/conf/vhost/$domain.xml << EOF
- <Host name="$domain" appBase="webapps" unpackWARs="true" autoDeploy="true"> $Tomcat_Domain_alias
- <Context path="" docBase="$vhostdir" debug="0" reloadable="false" crossContext="true"/>
- <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
- prefix="${domain}_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
- </Host>
- EOF
- [ -z "`grep -o "vhost-${domain} SYSTEM" $tomcat_install_dir/conf/server.xml`" ] && sed -i "/vhost-localhost SYSTEM/a<\!ENTITY vhost-${domain} SYSTEM \"file://$tomcat_install_dir/conf/vhost/$domain.xml\">" $tomcat_install_dir/conf/server.xml
- [ -z "`grep -o "vhost-${domain};" $tomcat_install_dir/conf/server.xml`" ] && sed -i "s@vhost-localhost;@&\n \&vhost-${domain};@" $tomcat_install_dir/conf/server.xml
- echo
- /etc/init.d/tomcat restart
- printf "
- #######################################################################
- # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
- # For more information please visit https://oneinstack.com #
- #######################################################################
- "
- echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
- echo "`printf "%-30s" "Tomcat Virtualhost conf:"`${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND}"
- echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
- echo "`printf "%-30s" "index url:"`${CMSG}http://${domain}:8080/${CEND}"
- }
- Create_nginx_php-fpm_hhvm_conf() {
- [ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
- cat > $web_install_dir/conf/vhost/$domain.conf << EOF
- server {
- $Nginx_conf
- server_name $domain$moredomainame;
- $N_log
- index index.html index.htm index.php;
- include $web_install_dir/conf/rewrite/$rewrite.conf;
- root $vhostdir;
- $Nginx_redirect
- $anti_hotlinking
- $NGX_CONF
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
- expires 30d;
- access_log off;
- }
- location ~ .*\.(js|css)?$ {
- expires 7d;
- access_log off;
- }
- }
- EOF
- if [ "$nginx_ssl_yn" == 'y' -a "$redirect_yn" == 'y' ];then
- cat >> $web_install_dir/conf/vhost/$domain.conf << EOF
- server {
- listen 80;
- server_name $domain$moredomainame;
- rewrite ^/(.*) https://$domain/\$1 permanent;
- }
- EOF
- elif [ "$nginx_ssl_yn" == 'y' ];then
- cat >> $web_install_dir/conf/vhost/$domain.conf << EOF
- server {
- listen 80;
- server_name $domain$moredomainame;
- $N_log
- index index.html index.htm index.php;
- include $web_install_dir/conf/rewrite/$rewrite.conf;
- root $vhostdir;
- $Nginx_redirect
- $anti_hotlinking
- $NGX_CONF
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
- expires 30d;
- access_log off;
- }
- location ~ .*\.(js|css)?$ {
- expires 7d;
- access_log off;
- }
- }
- EOF
- fi
- echo
- $web_install_dir/sbin/nginx -t
- if [ $? == 0 ];then
- echo "Reload Nginx......"
- $web_install_dir/sbin/nginx -s reload
- else
- rm -rf $web_install_dir/conf/vhost/$domain.conf
- echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
- exit 1
- fi
- printf "
- #######################################################################
- # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
- # For more information please visit https://oneinstack.com #
- #######################################################################
- "
- echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
- echo "`printf "%-30s" "Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
- echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
- [ "$rewrite_yn" == 'y' ] && echo "`printf "%-30s" "Rewrite rule:"`${CMSG}$web_install_dir/conf/rewrite/$rewrite.conf${CEND}"
- [ "$nginx_ssl_yn" == 'y' ] && Print_ssl
- }
- Apache_log() {
- while :; do echo
- read -p "Allow Apache access_log? [y/n]: " access_yn
- if [[ ! $access_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- if [ "$access_yn" == 'n' ]; then
- A_log='CustomLog "/dev/null" common'
- else
- A_log="CustomLog \"$wwwlogs_dir/${domain}_apache.log\" common"
- echo "You access log file=$wwwlogs_dir/${domain}_apache.log"
- fi
- }
- Create_apache_conf() {
- [ "`$apache_install_dir/bin/apachectl -v | awk -F'.' /version/'{print $2}'`" == '4' ] && R_TMP='Require all granted' || R_TMP=
- [ ! -d $apache_install_dir/conf/vhost ] && mkdir $apache_install_dir/conf/vhost
- cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
- <VirtualHost *:80>
- ServerAdmin admin@linuxeye.com
- DocumentRoot "$vhostdir"
- ServerName $domain
- $Apache_Domain_alias
- ErrorLog "$wwwlogs_dir/${domain}_error_apache.log"
- $A_log
- <Directory "$vhostdir">
- SetOutputFilter DEFLATE
- Options FollowSymLinks ExecCGI
- $R_TMP
- AllowOverride All
- Order allow,deny
- Allow from all
- DirectoryIndex index.html index.php
- </Directory>
- </VirtualHost>
- EOF
- [ "$apache_ssl_yn" == 'y' ] && cat >> $apache_install_dir/conf/vhost/$domain.conf << EOF
- <VirtualHost *:443>
- ServerAdmin admin@linuxeye.com
- DocumentRoot "$vhostdir"
- ServerName $domain
- $Apache_Domain_alias
- $Apache_SSL
- ErrorLog "$wwwlogs_dir/${domain}_error_apache.log"
- $A_log
- <Directory "$vhostdir">
- SetOutputFilter DEFLATE
- Options FollowSymLinks ExecCGI
- $R_TMP
- AllowOverride All
- Order allow,deny
- Allow from all
- DirectoryIndex index.html index.php
- </Directory>
- </VirtualHost>
- EOF
- echo
- $apache_install_dir/bin/apachectl -t
- if [ $? == 0 ];then
- echo "Restart Apache......"
- /etc/init.d/httpd restart
- else
- rm -rf $apache_install_dir/conf/vhost/$domain.conf
- echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
- exit 1
- fi
- printf "
- #######################################################################
- # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
- # For more information please visit https://oneinstack.com #
- #######################################################################
- "
- echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
- echo "`printf "%-30s" "Virtualhost conf:"`${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND}"
- echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
- }
- Create_nginx_apache_mod-php_conf() {
- # Nginx/Tengine/OpenResty
- [ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
- cat > $web_install_dir/conf/vhost/$domain.conf << EOF
- server {
- $Nginx_conf
- server_name $domain$moredomainame;
- $N_log
- index index.html index.htm index.php;
- root $vhostdir;
- $Nginx_redirect
- $anti_hotlinking
- location / {
- try_files \$uri @apache;
- }
- location @apache {
- proxy_pass http://127.0.0.1:88;
- include proxy.conf;
- }
- location ~ .*\.(php|php5|cgi|pl)?$ {
- proxy_pass http://127.0.0.1:88;
- include proxy.conf;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
- expires 30d;
- access_log off;
- }
- location ~ .*\.(js|css)?$ {
- expires 7d;
- access_log off;
- }
- }
- EOF
- if [ "$nginx_ssl_yn" == 'y' -a "$redirect_yn" == 'y' ];then
- cat >> $web_install_dir/conf/vhost/$domain.conf << EOF
- server {
- listen 80;
- server_name $domain$moredomainame;
- rewrite ^/(.*) https://$domain/\$1 permanent;
- }
- EOF
- elif [ "$nginx_ssl_yn" == 'y' ];then
- cat >> $web_install_dir/conf/vhost/$domain.conf << EOF
- server {
- listen 80;
- server_name $domain$moredomainame;
- $N_log
- index index.html index.htm index.php;
- root $vhostdir;
- $Nginx_redirect
- $anti_hotlinking
- location / {
- try_files \$uri @apache;
- }
- location @apache {
- proxy_pass http://127.0.0.1:88;
- include proxy.conf;
- }
- location ~ .*\.(php|php5|cgi|pl)?$ {
- proxy_pass http://127.0.0.1:88;
- include proxy.conf;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
- expires 30d;
- access_log off;
- }
- location ~ .*\.(js|css)?$ {
- expires 7d;
- access_log off;
- }
- }
- EOF
- fi
- echo
- $web_install_dir/sbin/nginx -t
- if [ $? == 0 ];then
- echo "Reload Nginx......"
- $web_install_dir/sbin/nginx -s reload
- else
- rm -rf $web_install_dir/conf/vhost/$domain.conf
- echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
- fi
- # Apache
- [ "`$apache_install_dir/bin/apachectl -v | awk -F'.' /version/'{print $2}'`" == '4' ] && R_TMP='Require all granted' || R_TMP=
- [ ! -d $apache_install_dir/conf/vhost ] && mkdir $apache_install_dir/conf/vhost
- cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
- <VirtualHost *:88>
- ServerAdmin admin@linuxeye.com
- DocumentRoot "$vhostdir"
- ServerName $domain
- $Apache_Domain_alias
- $Apache_SSL
- ErrorLog "$wwwlogs_dir/${domain}_error_apache.log"
- $A_log
- <Directory "$vhostdir">
- SetOutputFilter DEFLATE
- Options FollowSymLinks ExecCGI
- $R_TMP
- AllowOverride All
- Order allow,deny
- Allow from all
- DirectoryIndex index.html index.php
- </Directory>
- </VirtualHost>
- EOF
- echo
- $apache_install_dir/bin/apachectl -t
- if [ $? == 0 ];then
- echo "Restart Apache......"
- /etc/init.d/httpd restart
- else
- rm -rf $apache_install_dir/conf/vhost/$domain.conf
- exit 1
- fi
- printf "
- #######################################################################
- # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
- # For more information please visit https://oneinstack.com #
- #######################################################################
- "
- echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
- echo "`printf "%-30s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
- echo "`printf "%-30s" "Apache Virtualhost conf:"`${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND}"
- echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
- [ "$rewrite_yn" == 'y' ] && echo "`printf "%-28s" "Rewrite rule:"`${CMSG}$web_install_dir/conf/rewrite/$rewrite.conf${CEND}"
- [ "$nginx_ssl_yn" == 'y' ] && Print_ssl
- }
- Add_Vhost() {
- if [ -e "$web_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ];then
- Choose_env
- Input_Add_domain
- Nginx_anti_hotlinking
- if [ "$NGX_FLAG" == 'java' ];then
- Nginx_log
- Create_nginx_tomcat_conf
- else
- Nginx_rewrite
- Nginx_log
- Create_nginx_php-fpm_hhvm_conf
- fi
- elif [ ! -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/conf/httpd.conf" ];then
- Choose_env
- Input_Add_domain
- Apache_log
- Create_apache_conf
- elif [ ! -e "$web_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" -a -e "$tomcat_install_dir/conf/server.xml" ];then
- Choose_env
- Input_Add_domain
- Create_tomcat_conf
- elif [ -e "$web_install_dir/sbin/nginx" -a -e "`ls $apache_install_dir/modules/libphp?.so 2>/dev/null`" ];then
- Choose_env
- Input_Add_domain
- Nginx_anti_hotlinking
- if [ "$NGX_FLAG" == 'java' ];then
- Nginx_log
- Create_nginx_tomcat_conf
- elif [ "$NGX_FLAG" == 'hhvm' ];then
- Nginx_rewrite
- Nginx_log
- Create_nginx_php-fpm_hhvm_conf
- elif [ "$NGX_FLAG" == 'php' ];then
- #Nginx_rewrite
- Nginx_log
- Apache_log
- Create_nginx_apache_mod-php_conf
- fi
- fi
- }
- Del_NGX_Vhost() {
- if [ -e "$web_install_dir/sbin/nginx" ];then
- [ -d "$web_install_dir/conf/vhost" ] && Domain_List=`ls $web_install_dir/conf/vhost | sed "s@.conf@@g"`
- if [ -n "$Domain_List" ];then
- echo
- echo "Virtualhost list:"
- echo ${CMSG}$Domain_List${CEND}
- while :; do echo
- read -p "Please input a domain you want to delete: " domain
- if [ -z "`echo $domain | grep '.*\..*'`" ]; then
- echo "${CWARNING}input error! ${CEND}"
- else
- if [ -e "$web_install_dir/conf/vhost/${domain}.conf" ];then
- Directory=`grep ^root $web_install_dir/conf/vhost/${domain}.conf | awk -F'[ ;]' '{print $2}'`
- rm -rf $web_install_dir/conf/vhost/${domain}.conf
- $web_install_dir/sbin/nginx -s reload
- while :; do echo
- read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn
- if [[ ! $Del_Vhost_wwwroot_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- if [ "$Del_Vhost_wwwroot_yn" == 'y' ];then
- echo "Press Ctrl+c to cancel or Press any key to continue..."
- char=`get_char`
- rm -rf $Directory
- fi
- echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
- else
- echo "${CWARNING}Virtualhost: $domain was not exist! ${CEND}"
- fi
- break
- fi
- done
- else
- echo "${CWARNING}Virtualhost was not exist! ${CEND}"
- fi
- fi
- }
- Del_Apache_Vhost() {
- if [ -e "$apache_install_dir/conf/httpd.conf" ];then
- if [ -e "$web_install_dir/sbin/nginx" ];then
- rm -rf $apache_install_dir/conf/vhost/${domain}.conf
- /etc/init.d/httpd restart
- else
- Domain_List=`ls $apache_install_dir/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g"`
- if [ -n "$Domain_List" ];then
- echo
- echo "Virtualhost list:"
- echo ${CMSG}$Domain_List${CEND}
- while :; do echo
- read -p "Please input a domain you want to delete: " domain
- if [ -z "`echo $domain | grep '.*\..*'`" ]; then
- echo "${CWARNING}input error! ${CEND}"
- else
- if [ -e "$apache_install_dir/conf/vhost/${domain}.conf" ];then
- Directory=`grep '^<Directory' $apache_install_dir/conf/vhost/${domain}.conf | awk -F'"' '{print $2}'`
- rm -rf $apache_install_dir/conf/vhost/${domain}.conf
- /etc/init.d/httpd restart
- while :; do echo
- read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn
- if [[ ! $Del_Vhost_wwwroot_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- if [ "$Del_Vhost_wwwroot_yn" == 'y' ];then
- echo "Press Ctrl+c to cancel or Press any key to continue..."
- char=`get_char`
- rm -rf $Directory
- fi
- echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
- else
- echo "${CWARNING}Virtualhost: $domain was not exist! ${CEND}"
- fi
- break
- fi
- done
- else
- echo "${CWARNING}Virtualhost was not exist! ${CEND}"
- fi
- fi
- fi
- }
- Del_Tomcat_Vhost() {
- if [ -e "$tomcat_install_dir/conf/server.xml" ];then
- if [ -e "$web_install_dir/sbin/nginx" ];then
- if [ -n "`grep vhost-${domain} $tomcat_install_dir/conf/server.xml`" ];then
- sed -i /vhost-${domain}/d $tomcat_install_dir/conf/server.xml
- rm -rf $tomcat_install_dir/conf/vhost/${domain}.xml
- /etc/init.d/tomcat restart
- fi
- else
- Domain_List=`ls $tomcat_install_dir/conf/vhost | grep -v 'localhost.xml' | sed "s@.xml@@g"`
- if [ -n "$Domain_List" ];then
- echo
- echo "Virtualhost list:"
- echo ${CMSG}$Domain_List${CEND}
- while :; do echo
- read -p "Please input a domain you want to delete: " domain
- if [ -z "`echo $domain | grep '.*\..*'`" ]; then
- echo "${CWARNING}input error! ${CEND}"
- else
- if [ -n "`grep vhost-${domain} $tomcat_install_dir/conf/server.xml`" ];then
- sed -i /vhost-${domain}/d $tomcat_install_dir/conf/server.xml
- rm -rf $tomcat_install_dir/conf/vhost/${domain}.xml
- /etc/init.d/tomcat restart
- while :; do echo
- read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn
- if [[ ! $Del_Vhost_wwwroot_yn =~ ^[y,n]$ ]];then
- echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
- else
- break
- fi
- done
- if [ "$Del_Vhost_wwwroot_yn" == 'y' ];then
- echo "Press Ctrl+c to cancel or Press any key to continue..."
- char=`get_char`
- rm -rf $Directory
- fi
- echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
- else
- echo "${CWARNING}Virtualhost: $domain was not exist! ${CEND}"
- fi
- break
- fi
- done
- else
- echo "${CWARNING}Virtualhost was not exist! ${CEND}"
- fi
- fi
- fi
- }
- if [ $# == 0 ];then
- Add_Vhost
- elif [ $# == 1 ];then
- case $1 in
- add)
- Add_Vhost
- ;;
- del)
- Del_NGX_Vhost
- Del_Apache_Vhost
- Del_Tomcat_Vhost
- ;;
- *)
- Usage
- ;;
- esac
- else
- Usage
- fi
|