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