enable username option
This commit is contained in:
parent
3b1ba93156
commit
4343325188
|
@ -12,10 +12,11 @@ help()
|
||||||
thisfilename=$(basename -- "$0")
|
thisfilename=$(basename -- "$0")
|
||||||
echo "Get VirtualHost info."
|
echo "Get VirtualHost info."
|
||||||
echo ""
|
echo ""
|
||||||
echo "usage: $thisfilename [-d <domain>] [-o <mode>] [-c] [-h]"
|
echo "usage: $thisfilename [-d <domain>] [-u <username>] [-o <mode>] [-c] [-h]"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -h Print this help."
|
echo " -h Print this help."
|
||||||
echo " -d <domain> Domain name to get info for. By defual all domains are returned"
|
echo " -d <domain> Domain name to get info for. By default all domains are returned."
|
||||||
|
echo " -u <username> Only return domains owned by specified username."
|
||||||
echo " -o <mode> Type of query. 'virtualhosts' (default), 'redirects', 'aliases'."
|
echo " -o <mode> Type of query. 'virtualhosts' (default), 'redirects', 'aliases'."
|
||||||
echo " -c CVS - Output in cvs format, instead of tabbed table."
|
echo " -c CVS - Output in cvs format, instead of tabbed table."
|
||||||
}
|
}
|
||||||
|
@ -43,11 +44,11 @@ if [[ $option = 'virtualhosts' ]]; then
|
||||||
vhost::set-virtualhostArray
|
vhost::set-virtualhostArray
|
||||||
fi
|
fi
|
||||||
|
|
||||||
output="Virtualhost Username Config Status"
|
output="virtualhost username config status"
|
||||||
|
|
||||||
for v in "${virtualhostArray[@]}"
|
for v in "${virtualhostArray[@]}"
|
||||||
do
|
do
|
||||||
username=$(stat -c '%U' /srv/www/$v)
|
owner=$(stat -c '%U' /srv/www/$v)
|
||||||
if [[ -f /etc/apache2/sites-available/$v.conf ]]; then
|
if [[ -f /etc/apache2/sites-available/$v.conf ]]; then
|
||||||
macro="Custom"
|
macro="Custom"
|
||||||
if head -n 1 /etc/apache2/sites-available/$v.conf |grep --quiet ^Use; then
|
if head -n 1 /etc/apache2/sites-available/$v.conf |grep --quiet ^Use; then
|
||||||
|
@ -61,13 +62,21 @@ if [[ $option = 'virtualhosts' ]]; then
|
||||||
else
|
else
|
||||||
status="Disabled"
|
status="Disabled"
|
||||||
fi
|
fi
|
||||||
output="$output${NL}$v $username $macro $status"
|
if [[ -n $username ]]; then
|
||||||
|
if [[ $username = $owner ]]; then
|
||||||
|
output="$output${NL}$v $owner $macro $status"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
output="$output${NL}$v $owner $macro $status"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
if [[ $output != "virtualhost username config status" ]]; then
|
||||||
if [[ $cvs ]]; then
|
if [[ $cvs ]]; then
|
||||||
echo "$output" | tr " " ","
|
echo "$output" | tr " " ","
|
||||||
else
|
else
|
||||||
echo "$output" | column -t
|
echo "$output" | column -t
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
elif [[ $option = 'redirects' ]]; then
|
elif [[ $option = 'redirects' ]]; then
|
||||||
|
|
||||||
# working dir for redirect configs
|
# working dir for redirect configs
|
||||||
|
@ -89,7 +98,7 @@ elif [[ $option = 'redirects' ]]; then
|
||||||
vhostConfigs=(`ls -1`)
|
vhostConfigs=(`ls -1`)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
output="Virtualhost Config Redirect Status"
|
output="virtualhost config redirect status"
|
||||||
|
|
||||||
for c in "${vhostConfigs[@]}"
|
for c in "${vhostConfigs[@]}"
|
||||||
do
|
do
|
||||||
|
@ -133,21 +142,21 @@ elif [[ $option = 'aliases' ]]; then
|
||||||
vhostConfigs=(`ls -1`)
|
vhostConfigs=(`ls -1`)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
output="Virtualhost Username Macro Alias Status"
|
output="virtualhost username macro alias status"
|
||||||
|
|
||||||
for c in "${vhostConfigs[@]}"
|
for c in "${vhostConfigs[@]}"
|
||||||
do
|
do
|
||||||
if head -n 1 /etc/apache2/sites-available/$c |grep --quiet '^Use VHostAlias'; then
|
if head -n 1 /etc/apache2/sites-available/$c |grep --quiet '^Use VHostAlias'; then
|
||||||
macro=$(head -n 1 /etc/apache2/sites-available/$c |grep '^Use VHostAlias'|cut -d ' ' -f 2)
|
macro=$(head -n 1 /etc/apache2/sites-available/$c |grep '^Use VHostAlias'|cut -d ' ' -f 2)
|
||||||
alias=$(head -n 1 /etc/apache2/sites-available/$c |grep '^Use VHostAlias'|cut -d ' ' -f 3)
|
alias=$(head -n 1 /etc/apache2/sites-available/$c |grep '^Use VHostAlias'|cut -d ' ' -f 3)
|
||||||
username=$(head -n 1 /etc/apache2/sites-available/$c |grep '^Use VHostAlias'|cut -d ' ' -f 4)
|
owner=$(head -n 1 /etc/apache2/sites-available/$c |grep '^Use VHostAlias'|cut -d ' ' -f 4)
|
||||||
virtualhost=$(head -n 1 /etc/apache2/sites-available/$c |grep '^Use VHostAlias'|cut -d ' ' -f 5)
|
virtualhost=$(head -n 1 /etc/apache2/sites-available/$c |grep '^Use VHostAlias'|cut -d ' ' -f 5)
|
||||||
if [[ -f /etc/apache2/sites-enabled/$c ]]; then
|
if [[ -f /etc/apache2/sites-enabled/$c ]]; then
|
||||||
status="Enabled"
|
status="Enabled"
|
||||||
else
|
else
|
||||||
status="Disabled"
|
status="Disabled"
|
||||||
fi
|
fi
|
||||||
output="$output${NL}$alias $username $macro $virtualhost $status"
|
output="$output${NL}$alias $owner $macro $virtualhost $status"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user