Created
September 5, 2016 12:21
-
-
Save igorhrq/81063304a7f1a31769ac4f6c9cf267f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unalias restrict_http 2> /dev/null | |
restrict_http(){ | |
args=$@ | |
analista=$(echo $args | sed 's/\s.*//') | |
motivo=$(echo $args | sed 's/^[a-zA-Z0-9]\+\s//') | |
# analista=$1 | |
if [[ -z "$analista" ]]; then | |
echo "Erro - Nome do analista nao foi informado corretamente ex: igora" | |
return 1 | |
fi | |
BASEDIR=$(pwd | cut -f2 -d/) | |
if [[ ! ${BASEDIR} =~ home[0-9]* ]]; then | |
echo "Erro - Parece que voce nao esta no diretorio home da conta cPanel ex: /home/conta/public_html" | |
return 1; | |
fi | |
ACCTNAME=$(pwd | cut -f3 -d/) | |
DIRNAME=$(pwd | cut -d/ -f 5-99) | |
# motivo=$2 | |
if [[ -z "$motivo" ]]; then | |
echo "Erro - motivo nao informado" | |
return 1 | |
fi | |
if [[ -f /etc/cpanel/ea4/is_ea4 ]]; then | |
CONFPATH='/etc/apache2/conf.d/' | |
else | |
CONFPATH='/usr/local/apache/conf' | |
fi | |
mkdir -p ${CONFPATH}/userdata/std/2/${ACCTNAME}/ | |
mkdir -p ${CONFPATH}/userdata/ssl/2/${ACCTNAME}/ | |
cat > ${CONFPATH}/userdata/std/2/${ACCTNAME}/restrictaccess.`date +%s`.conf <<neof | |
<Location /${DIRNAME}> | |
order deny,allow | |
deny from all | |
errordocument 403 "Em Manutencao. | |
#" ~$analista em $(date +'%F %T') Motivo - ${motivo} | |
</Location> | |
neof | |
cat > ${CONFPATH}/userdata/ssl/2/${ACCTNAME}/restrictaccess.`date +%s`.conf <<neof | |
<Location /${DIRNAME}> | |
order deny,allow | |
deny from all | |
errordocument 403 "Em Manutencao. | |
# ~$analista em $(date +'%F %T') Motivo - ${motivo} | |
</Location> | |
neof | |
/scripts/rebuildhttpdconf | |
/scripts/restartsrv_httpd | |
unset motivo analista BASEDIR ACCTNAME DIRNAME CONFPATH | |
} | |
export restrict_http |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment