first draft to get aliases linked to the servername
This commit is contained in:
parent
942d3c3243
commit
8c44478643
|
@ -257,6 +257,7 @@ else {
|
||||||
|
|
||||||
$domain = $params[1];
|
$domain = $params[1];
|
||||||
$alias_list = array();
|
$alias_list = array();
|
||||||
|
$alias_list2 = array();
|
||||||
|
|
||||||
if ($conf['cluster']) {
|
if ($conf['cluster']) {
|
||||||
if (is_mcluster_mode()) {
|
if (is_mcluster_mode()) {
|
||||||
|
@ -285,6 +286,31 @@ else {
|
||||||
}
|
}
|
||||||
sudoexec($cmd, $data_output, $exec_return);
|
sudoexec($cmd, $data_output, $exec_return);
|
||||||
|
|
||||||
|
$cmd2 = 'web-add.sh list-alias ' . $domain;
|
||||||
|
sudoexec($cmd2, $data_output2, $exec_return2);
|
||||||
|
|
||||||
|
$vhost_detail = array();
|
||||||
|
foreach($data_output2 as $data_line2) {
|
||||||
|
$data_split2 = explode(' ', $data_line2);
|
||||||
|
// var_dump($data_split2);
|
||||||
|
$vhost_detail['servername'] = $data_split2[0];
|
||||||
|
unset($data_split2[0]);
|
||||||
|
|
||||||
|
# si des aliases sont présents
|
||||||
|
if (count($data_split2) > 0) {
|
||||||
|
$vhost_detail['aliases'] = array();
|
||||||
|
foreach($data_split2 as $alias_split2) {
|
||||||
|
array_push($vhost_detail['aliases'], $alias_split2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array_push($alias_list2, $vhost_detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<pre>';
|
||||||
|
var_dump($alias_list2);
|
||||||
|
echo '</pre>';
|
||||||
|
// var_dump($vhost_detail);
|
||||||
|
|
||||||
/* Récupération de cette liste dans le tableau $vhost_list */
|
/* Récupération de cette liste dans le tableau $vhost_list */
|
||||||
$vhost_list = array();
|
$vhost_list = array();
|
||||||
foreach($data_output as $data_line) {
|
foreach($data_output as $data_line) {
|
||||||
|
|
|
@ -756,6 +756,9 @@ arg_processing() {
|
||||||
del-alias)
|
del-alias)
|
||||||
op_aliasdel "$@"
|
op_aliasdel "$@"
|
||||||
;;
|
;;
|
||||||
|
list-alias)
|
||||||
|
op_listalias "$@"
|
||||||
|
;;
|
||||||
list-servername)
|
list-servername)
|
||||||
op_listservername "$@"
|
op_listservername "$@"
|
||||||
;;
|
;;
|
||||||
|
@ -861,6 +864,27 @@ op_aliasdel() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The Holy Grail, do not touch, even if you're Indiana Jones
|
||||||
|
# TODO: ne pas prendre en compte les lignes commentées
|
||||||
|
# ajouter la fonction dans le usage
|
||||||
|
# awk '/^<VirtualHost*/,/^<\/VirtualHost>/{if(/^<\/VirtualHost>/)p=1;if(/ServerName|ServerAlias/)out = out (out?OFS:"") ($2)}p{print out;p=0;out=""}' /etc/apache2/sites-enabled/test.conf
|
||||||
|
op_listalias() {
|
||||||
|
if [ $# -eq 1 ]; then
|
||||||
|
vhost_file="$VHOST_PATH/${1}.conf";
|
||||||
|
|
||||||
|
if [ -f "${vhost_file}" ]; then
|
||||||
|
|
||||||
|
aliases=$(awk '/^<VirtualHost*/,/^<\/VirtualHost>/{if(/^<\/VirtualHost>/)p=1;if(/ServerName|ServerAlias/)out = out (out?OFS:"") ($2)}p{print out;p=0;out=""}' "$vhost_file")
|
||||||
|
echo "$aliases";
|
||||||
|
else
|
||||||
|
echo "VHost file \`${vhost_file}' not found'" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
op_listservername() {
|
op_listservername() {
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
vhost_file="$VHOST_PATH/${1}.conf";
|
vhost_file="$VHOST_PATH/${1}.conf";
|
||||||
|
|
Loading…
Reference in a new issue