Ticket #15: lrs_backuppc_admin_tasks.diff

File lrs_backuppc_admin_tasks.diff, 12.1 kB (added by adam.cecile@linbox.com, 1 year ago)

Patch to add admin task delete_from_backuppc and disable_from_backuppc

  • lbs/admin.cgi

    old new  
    109109    <ul><li><a href='rename.cgi?$redir'>$text{'but_rename'}</a> 
    110110    <li><a href='renamemac.cgi?$redir'>$text{'but_renamemac'}</a> 
    111111    <li><a href='delete.cgi?$redir'>$text{'but_delete'}</a> 
     112    <li><a href='disable_backuppc.cgi?$redir'>$text{'but_disable_backuppc'}</a> 
     113    <li><a href='delete_backuppc.cgi?$redir'>$text{'but_delete_backuppc'}</a> 
    112114    </ul> 
    113115EOF 
    114116} else { 
  • lbs/delete_backuppc.cgi

    old new  
     1#!/usr/bin/perl -w 
     2# 
     3# $Id: delete.cgi 4244 2007-04-16 09:10:48Z root $ 
     4# 
     5# Linbox Rescue Server 
     6# Copyright (C) 2005  Linbox FAS 
     7# 
     8# This program is free software; you can redistribute it and/or 
     9# modify it under the terms of the GNU General Public License 
     10# as published by the Free Software Foundation; either version 2 
     11# of the License, or (at your option) any later version. 
     12# 
     13# This program is distributed in the hope that it will be useful, 
     14# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     16# GNU General Public License for more details. 
     17# 
     18# You should have received a copy of the GNU General Public License 
     19# along with this program; if not, write to the Free Software 
     20# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
     21 
     22use strict; 
     23 
     24# rmtree function 
     25use File::Path; 
     26 
     27# get some common functions ... 
     28require "lbs.pl"; 
     29# ... and vars 
     30use vars qw (%access %config %in %text $VERSION); 
     31 
     32lbs_common::init_lbs_conf() or exit(0); 
     33 
     34my %einfo; 
     35my $lbs_home = $lbs_common::lbsconf{'basedir'}; 
     36my $etherfile = $lbs_home . "/etc/ether"; 
     37my ($mac,$name); 
     38my ($mesg, $warning); 
     39my $result; 
     40my @toremove; 
     41 
     42error(text("err_dnf",$lbs_home)) if (not -d $lbs_home); 
     43error(text("err_fnf",$etherfile)) if (not -f $etherfile); 
     44 
     45ReadParse(); 
     46lbs_common::InClean(); 
     47 
     48# Is the user granted to do this action ? 
     49error( $text{'acl_error'} ) if ($access{'modify'}); 
     50 
     51etherLoad($etherfile, \%einfo) or error( lbsGetError() ); 
     52 
     53# Invalid MAC address 
     54if (not exists $in{'mac'}) { 
     55        error($text{'err_invalcgi_nomac'}); 
     56} 
     57# Seems the users clicked on cancel, redirect to index 
     58elsif (exists $in{'cancel'}) { 
     59        redirect("index.cgi"); 
     60} 
     61# Yeah! Finally someone confirmed his choice, let's delete stuff 
     62elsif (exists $in{'apply'}) { 
     63 
     64    $mac = $in{'mac'}; 
     65    $name = etherGetNameByMac(\%einfo, $mac); 
     66         
     67    if (not defined $name) { 
     68        error(text("err_mac_inval",$mac)); 
     69    } 
     70         
     71    # Drop BackupPC config plus old backups 
     72    # BackupPC_nightly will remove old files from cpool at its next run 
     73    my $BACKUPPCCONFDIR="/etc/backuppc";            # FIXME: hardcoded 
     74    my $BACKUPPCFILESDIR="/var/lib/backuppc/pc";    # FIXME: hardcoded 
     75 
     76    # Create an array with all we want to delete 
     77    push @toremove, "$BACKUPPCCONFDIR/$name.pl" if (-e "$BACKUPPCCONFDIR/$name.pl"); 
     78    push @toremove, "$BACKUPPCFILESDIR/$name" if (-e "$BACKUPPCFILESDIR/$name"); 
     79    # And remove it, then 
     80    foreach (@toremove) { 
     81        rmtree($_, 0, 1); 
     82    } 
     83     
     84    # We need to fix /etc/backuppc/hosts too 
     85    `perl -i -ne "print unless m/^$name\\s+[0-9]/i" $BACKUPPCCONFDIR/hosts`; 
     86                 
     87    $mesg = text("msg_delete_ok",$name,$mac); 
     88    lbs_common::print_header( $text{'tit_delete'}, "index", $VERSION); 
     89    lbs_common::print_html_tabs(['list_of_machines', "clients_list"]); 
     90 
     91    print "<h2>$mesg</h2>\n" ; 
     92 
     93    menuEnd(); 
     94    footer("", $text{'index'}) ; 
     95} 
     96 
     97# No confirmation asked yet, let's bother the user 
     98else { 
     99         
     100        $mac = $in{'mac'} ; 
     101        $name = etherGetNameByMac(\%einfo, $mac) ; 
     102 
     103        lbs_common::print_header( $text{'tit_delete'}, "index", $VERSION); 
     104        lbs_common::print_html_tabs(['list_of_machines', "clients_list"]); 
     105 
     106        $mesg = text("msg_delete_confirm_backuppc",$name,$mac); 
     107        $warning = $text{'msg_delete_warn_backuppc'} ; 
     108        print_confirmation_form("delete_backuppc.cgi", "<h2>$mesg<br><font color=#FF0000>$warning</font></h2>", "mac", $mac ) ; 
     109 
     110        # end of tabs 
     111        lbs_common::print_end_menu(); 
     112        lbs_common::print_end_menu(); 
     113 
     114        # end of page 
     115        footer( "", $text{'index'} ); 
     116} 
  • lbs/disable_backuppc.cgi

    old new  
     1#!/usr/bin/perl -w 
     2# 
     3# $Id: delete.cgi 4244 2007-04-16 09:10:48Z root $ 
     4# 
     5# Linbox Rescue Server 
     6# Copyright (C) 2005  Linbox FAS 
     7# 
     8# This program is free software; you can redistribute it and/or 
     9# modify it under the terms of the GNU General Public License 
     10# as published by the Free Software Foundation; either version 2 
     11# of the License, or (at your option) any later version. 
     12# 
     13# This program is distributed in the hope that it will be useful, 
     14# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     16# GNU General Public License for more details. 
     17# 
     18# You should have received a copy of the GNU General Public License 
     19# along with this program; if not, write to the Free Software 
     20# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
     21 
     22use strict; 
     23 
     24# get some common functions ... 
     25require "lbs.pl"; 
     26# ... and vars 
     27use vars qw (%access %config %in %text $VERSION); 
     28 
     29lbs_common::init_lbs_conf() or exit(0); 
     30 
     31my %einfo; 
     32my $lbs_home = $lbs_common::lbsconf{'basedir'}; 
     33my $etherfile = $lbs_home . "/etc/ether"; 
     34my ($mac,$name); 
     35my ($mesg, $warning); 
     36my $result; 
     37 
     38error(text("err_dnf",$lbs_home)) if (not -d $lbs_home); 
     39error(text("err_fnf",$etherfile)) if (not -f $etherfile); 
     40 
     41ReadParse(); 
     42lbs_common::InClean(); 
     43 
     44# Is the user granted to do this action ? 
     45error( $text{'acl_error'} ) if ($access{'modify'}); 
     46 
     47etherLoad($etherfile, \%einfo) or error( lbsGetError() ); 
     48 
     49# Invalid MAC address 
     50if (not exists $in{'mac'}) { 
     51        error($text{'err_invalcgi_nomac'}); 
     52} 
     53# Seems the users clicked on cancel, redirect to index 
     54elsif (exists $in{'cancel'}) { 
     55        redirect("index.cgi"); 
     56} 
     57# Yeah! Finally someone confirmed his choice, let's disable the host 
     58elsif (exists $in{'apply'}) { 
     59 
     60    $mac = $in{'mac'}; 
     61    $name = etherGetNameByMac(\%einfo, $mac); 
     62         
     63    if (not defined $name) { 
     64        error(text("err_mac_inval",$mac)); 
     65    } 
     66         
     67    # Modify host's BackupPC conf file 
     68    my $BACKUPPCCONFDIR="/etc/backuppc";            # FIXME: hardcoded 
     69    my $BACKUPPCCONFFILE="$BACKUPPCCONFDIR/$name.pl"; 
     70 
     71    # Set $Conf{FullPeriod} to -1 
     72        `perl -pi -e 's/\\\$Conf{FullPeriod}.*\$/\\\$Conf{FullPeriod} = -1;/' $BACKUPPCCONFFILE`; 
     73 
     74    $mesg = text("msg_disable_backuppc_ok",$name,$mac); 
     75    lbs_common::print_header( $text{'tit_disable_backuppc'}, "index", $VERSION); 
     76    lbs_common::print_html_tabs(['list_of_machines', "clients_list"]); 
     77 
     78    print "<h2>$mesg</h2>\n"; 
     79     
     80    menuEnd(); 
     81    footer("", $text{'index'}); 
     82} 
     83 
     84# No confirmation asked yet, let's bother the user 
     85else { 
     86         
     87        $mac = $in{'mac'} ; 
     88        $name = etherGetNameByMac(\%einfo, $mac) ; 
     89 
     90        lbs_common::print_header( $text{'tit_disable_backuppc'}, "index", $VERSION); 
     91        lbs_common::print_html_tabs(['list_of_machines', "clients_list"]); 
     92 
     93        $mesg = text("msg_disable_confirm_backuppc",$name,$mac); 
     94        $warning = $text{'msg_disable_warn_backuppc'} ; 
     95        print_confirmation_form("disable_backuppc.cgi", "<h2>$mesg<br><font color=#FF0000>$warning</font></h2>", "mac", $mac ) ; 
     96 
     97        # end of tabs 
     98        lbs_common::print_end_menu(); 
     99        lbs_common::print_end_menu(); 
     100 
     101        # end of page 
     102        footer( "", $text{'index'} ); 
     103} 
  • lbs/lang/en

    old new  
    2020but_return=Return 
    2121but_rm_machine=Remove this client 
    2222but_sync=Synchronize 
     23but_disable_backuppc=Disable files backup 
     24but_delete_backuppc=Delete files backup 
    2325 
    2426err_adminid_mandat=The admin ID is mandatory. 
    2527err_basedirnf=LRS root directory <b>$1</b> not found. You should check <tt>basedir</tt> located into <tt>lbs.conf</tt> . 
     
    166168msg_conf_partcopy=Partition $1, disk $2 ($3) 
    167169msg_conf_ptabs=Disk $1 partition table 
    168170msg_delete_confirm=Remove host <b>$1</b> ($2) ? 
     171msg_delete_confirm_backuppc=Remove host <b>$1</b> ($2) from files backups ? 
    169172msg_delete_ok=Host <b>$1</b> ($2) successfully removed. 
    170173msg_delete_warn=WARNING: All information about this host will be deleted, including backups ! 
     174msg_delete_warn_backuppc=WARNING: All information about this host files backups will be deleted, including backups ! 
    171175msg_delimg_confirm=Remove image <b>$1</b> ? 
    172176msg_delimg_symlink=This image is just a link to one another. Only this link will be deleted. 
    173177msg_delimg_warn=WARNING: All data about this image will be deleted! 
    174178msg_dhcp_addofentry=Add of entry 
    175179msg_dhcp_formdesc=Add a new host entry in the LRS for system backup 
    176180msg_dhcp_nolic=Sorry, you cannot add more clients. License exhausted. 
     181msg_disable_backuppc_ok=Files backups disabled sucessfully for host <b>$1</b> ($2). 
     182msg_disable_confirm_backuppc=Disable files backups for host <b>$1</b> ($2) ? 
     183msg_disable_warn_backuppc=WARNING: No more automatic files backups will be done. Current backups will stay available. 
    177184msg_imgbase_delconfirm=Remove image <b>$1</b> ? 
    178185msg_imgbase_delwarn=WARNING: All data about this image will be deleted! 
    179186msg_index_empty=No registered host. 
     
    206213tit_desc=LRS : Description Edition 
    207214tit_details=LRS : Details 
    208215tit_dhcp=LRS : DHCP 
     216tit_disable_backuppc=LRS: Disable files backup 
    209217tit_error=LRS : Error 
    210218tit_hwinfo=LRS : Hardware Config 
    211219tit_imagesize=Compressed image size (in MB) 
  • lbs/lang/fr

    old new  
    2020but_return=Retour 
    2121but_rm_machine=Effacer cette machine 
    2222but_sync=Synchroniser 
     23but_disable_backuppc=Désactiver la sauvegarde fichiers 
     24but_delete_backuppc=Supprimer de la sauvegarde fichiers 
    2325 
    2426err_adminid_mandat=Le mot de passe d'identification est obligatoire. 
    2527err_basedirnf=Le répertoire racine LRS <b>$1</b> est inaccessible. Veuillez vérifier le paramètre <tt>basedir</tt> dans le fichier <tt>lbs.conf</tt> . 
     
    167169msg_conf_partcopy=Partition $1, disque $2 ($3) 
    168170msg_conf_ptabs=Table de partitions du disque $1 
    169171msg_delete_confirm=Effacer la machine <b>$1</b> ($2) ? 
     172msg_delete_confirm_backuppc=Effacer la machine <b>$1</b> ($2) de la sauvegarde fichiers ? 
    170173msg_delete_ok=Effacement de la machine <b>$1</b> ($2) effectué avec succès. 
    171174msg_delete_warn=ATTENTION: cela effacera toutes les données concernant cette machine. Y compris ses sauvegardes! 
     175msg_delete_warn_backuppc=ATTENTION: cela effacera toutes les données concernant la sauvegarde fichiers de cette machine. Y compris ses sauvegardes! 
    172176msg_delimg_confirm=Effacer l'image <b>$1</b> ? 
    173177msg_delimg_symlink=Cette image est juste un lien vers une autre image. Seul le lien lui-même sera effacé. 
    174178msg_delimg_warn=ATTENTION: cela effacera toutes les données concernant cette image! 
    175179msg_dhcp_addofentry=Ajout de l'entrée 
    176180msg_dhcp_formdesc=Ajout d'une nouveau client LRS pour la sauvegarde système 
    177181msg_dhcp_nolic=Désolé, vous ne pouvez plus ajouter d'autres clients. Pas assez de licences. 
     182msg_disable_backuppc_ok=Sauvegarde fichiers désactivée avec succès pour la machine <b>$1</b> ($2). 
     183msg_disable_confirm_backuppc=Désactiver la sauvegarde fichiers de <b>$1</b> ($2) ? 
     184msg_disable_warn_backuppc=ATTENTION: Plus aucune sauvegarde ne sera effectuée automatiquement. Par contres, les sauvegardes actuelles resteront disponibles. 
    178185msg_imgbase_delconfirm=Effacer l'image <b>$1</b> ? 
    179186msg_imgbase_delwarn=ATTENTION: Cela effacera toutes les données concernant cette image ! 
    180187msg_index_empty=Aucune machine enregistrée 
     
    207214tit_desc=LRS : Edition de description 
    208215tit_details=LRS : Détails 
    209216tit_dhcp=LRS : DHCP 
     217tit_disable_backuppc=LRS: Désactivation sauvegarde fichiers 
    210218tit_error=LRS : Erreur 
    211219tit_hwinfo=LRS : Config matérielle 
    212220tit_imagesize=Taille de l'image compressée (en Mo)