Initial import
This commit is contained in:
49
convert_vhosts_2.4.sh
Executable file
49
convert_vhosts_2.4.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
#APACHE_CONF_DIR=/usr/local/httpd-2.4.2/conf
|
||||
APACHE_CONF_DIR="/usr/local/httpd-2.4.9_php-5.3.28/conf"
|
||||
VHOST_DIR=${APACHE_CONF_DIR}/vhosts
|
||||
|
||||
|
||||
|
||||
#_conf_files=`find $VHOST_DIR -type f -name *.conf`
|
||||
_conf_files=`find $VHOST_DIR -type f`
|
||||
|
||||
|
||||
for file in $_conf_files ; do
|
||||
|
||||
[ -d "$file" ] && continue
|
||||
[ -h "$file" ] && continue
|
||||
|
||||
echo "convert \"`basename $file`\".."
|
||||
|
||||
## -
|
||||
## - Order deny,allow
|
||||
## - Deny from all --> Require all denied
|
||||
## -
|
||||
## - Order allow,deny
|
||||
## - Allow from all --> Require all granted
|
||||
## -
|
||||
## -
|
||||
sed -i.bak -r -e "s/^(\s*NameVirtualHost.*)$/#\1/g" $file
|
||||
sed -i -r -e "s/^(\s*)(Order\s+[aA]llow\s*,\s*[dD]eny)$/\1#\2/g" $file
|
||||
sed -i -r -e "s/^(\s*)([aA]llow\s+from\s+[aA][lL]{2}\s*)$/\1#\2\n\1Require all granted/g" $file
|
||||
sed -i -r -e "s/^(\s*)([dD]eny\s+from\s+[aA][lL]{2}\s*)$/\1#\2\n\1Require all denied/g" $file
|
||||
sed -i -r -e "s/^(\s*)([dD]eny\s+from\s+[aA][lL]{2}\s*)$/\1#\2\n\1Require all denied/g" $file
|
||||
|
||||
## - Order Deny,Allow
|
||||
## - Deny from all
|
||||
## - Allow from 127.0.0.1 192.168.63.40 --> Require ip 127.0.0.1 192.168.63.40
|
||||
## -
|
||||
sed -i -r -e "s/^(\s*)([aA]llow\s+from)\s+([0-2][0-9]{0,2}\..*)$/\1#\2 \3\n\1Require ip \3/g" $file
|
||||
|
||||
## - Order Deny,Allow
|
||||
## - Deny from all
|
||||
## - Allow from example.org --> Require host example.org
|
||||
## -
|
||||
sed -i -r -e "s/^(\s*)([aA]llow\s+from)\s+(.*)$/\1#\2 \3\n\1Require host \3/g" $file
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user