delete list-servername function

This commit is contained in:
Nicolas Roman 2019-05-16 14:40:30 +02:00
parent c995678003
commit 48168c534e
3 changed files with 19 additions and 49 deletions

View file

@ -193,17 +193,15 @@ if (isset($_GET['edit']) ) {
$alias_list = $bdd->list_serveralias($domain); $alias_list = $bdd->list_serveralias($domain);
} }
else { else {
$cmd = 'web-add.sh list-vhost ' . $domain;
$cmd = 'web-add.sh list-servername ' . $domain;
if(!is_superadmin()) { if(!is_superadmin()) {
$cmd = sprintf('%s %s', $cmd, $_SESSION['user']); $cmd = sprintf('%s %s', $cmd, $_SESSION['user']);
} }
sudoexec($cmd, $data_output, $exec_return); sudoexec($cmd, $data_output, $exec_return);
foreach($data_output as $data_line) { $data_vhost = explode(':', $data_output[0]);
array_push($servername_list, $data_line); $servername = $data_vhost[2];
}
} }
include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/header.tpl.php';

View file

@ -128,30 +128,26 @@ del-alias VHOST ALIAS
Del a ServerAlias from an Apache vhost Del a ServerAlias from an Apache vhost
list-servername LOGIN
List ServerName(s) for user LOGIN
update-servername VHOST SERVERNAME OLD_SERVERNAME update-servername VHOST SERVERNAME OLD_SERVERNAME
Replace the OLD_SERVERNAME with the SERVERNAME for an Apache vhost Replace the OLD_SERVERNAME with the SERVERNAME for an Apache vhost
Also apply to rules Also apply to rewrite rules
check-occurence NAME check-occurence NAME
List all occurences of NAME in vhosts List all occurences of NAME in vhosts
list-user-itk DOMAIN LOGIN list-user-itk LOGIN
List the assigned ITK user for the DOMAIN specified List the assigned ITK user for the LOGIN specified
enable-user-itk DOMAIN LOGIN enable-user-itk LOGIN
Enable the assigned ITK user for the DOMAIN specified Enable the assigned ITK user for the LOGIN specified
disable-user-itk DOMAIN LOGIN disable-user-itk LOGIN
Disable the assigned ITK user for the DOMAIN specified Disable the assigned ITK user for the LOGIN specified
setphpversion LOGIN VERSION setphpversion LOGIN VERSION
@ -828,9 +824,6 @@ arg_processing() {
del-alias) del-alias)
op_aliasdel "$@" op_aliasdel "$@"
;; ;;
list-servername)
op_listservername "$@"
;;
update-servername) update-servername)
op_servernameupdate "$@" op_servernameupdate "$@"
;; ;;
@ -942,25 +935,6 @@ op_aliasdel() {
fi fi
} }
op_listservername() {
if [ $# -eq 1 ]; then
vhost_file="$VHOST_PATH/${1}.conf";
if [ -f "${vhost_file}" ]; then
servernames=$(awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' "$vhost_file" | uniq)
for servername in $servernames; do
echo "$servername";
done
else
echo "VHost file \`${vhost_file}' not found'" >&2
return 1
fi
else
usage
fi
}
op_servernameupdate() { op_servernameupdate() {
if [ $# -eq 3 ]; then if [ $# -eq 3 ]; then
vhost="${1}.conf" vhost="${1}.conf"
@ -968,7 +942,6 @@ op_servernameupdate() {
old_servername=$3 old_servername=$3
vhost_file="${VHOST_PATH}/${vhost}" vhost_file="${VHOST_PATH}/${vhost}"
# Remplacement de toutes les directives ServerName, on assume qu'il s'agit du même pour chaque vhost du fichier
if [ -f "${vhost_file}" ]; then if [ -f "${vhost_file}" ]; then
sed -i "/^ *ServerName/ s/$old_servername/$servername/g" "${vhost_file}" --follow-symlinks sed -i "/^ *ServerName/ s/$old_servername/$servername/g" "${vhost_file}" --follow-symlinks
sed -i "/^ *RewriteCond/ s/$old_servername/$servername/g" "${vhost_file}" --follow-symlinks sed -i "/^ *RewriteCond/ s/$old_servername/$servername/g" "${vhost_file}" --follow-symlinks

View file

@ -17,7 +17,7 @@
<?php <?php
if(count($servername_list) > 0) { ?> if(!empty($servername)) { ?>
<table id="tab-list"> <table id="tab-list">
<thead> <thead>
@ -30,15 +30,14 @@
</thead> </thead>
<tbody> <tbody>
<?php <?php
for ( $i=0; $i < count($servername_list); ++$i ) { print '<tr>';
print '<tr>'; printf('<td>%s</td>',
printf('<td>%s</td>', $servername);
$servername_list[$i]); if (is_superadmin())
if (is_superadmin()) printf('<td><a href="/webadmin/servername/%s?edit=%s">Modifier</a></td>',
printf('<td><a href="/webadmin/servername/%s?edit=%s">Modifier</a></td>', $domain, $servername);
$domain, $servername_list[$i]); print '</tr>';
print '</tr>'; ?>
} ?>
</tbody> </tbody>
</table> </table>
<?php <?php