mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
MPFire CGI korrigiert
Backupfunktionen fuer Addons begonnen git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@974 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
@@ -63,6 +63,9 @@ elsif ($ARGV[0] eq 'restore') {
|
||||
elsif ($ARGV[0] eq 'cli') {
|
||||
system("tar -cvzf /var/ipfire/backup/$Jahr$Monat$Monatstag-$Stunden$Minuten-$ARGV[1].ipf --files-from='$ARGV[2]' --exclude-from='$ARGV[3]'");
|
||||
}
|
||||
elsif ($ARGV[0] eq 'addonbackup') {
|
||||
system("tar -cvzf /var/ipfire/backup/addons/backup/$ARGV[1].ipf --files-from='/var/ipfire/backup/addons/includes/$ARGV[1]'");
|
||||
}
|
||||
elsif ($ARGV[0] =~ /ipf$/ ) {
|
||||
system("rm /var/ipfire/backup/$ARGV[0]");
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
/var/ipfire/ppp
|
||||
/var/ipfire/proxy
|
||||
/var/ipfire/qos/*
|
||||
/var/ipfire/time/
|
||||
/var/ipfire/urlfilter
|
||||
/var/ipfire/vpn
|
||||
/var/log/ip-acct/*
|
||||
|
||||
4
config/backup/includes/mpfire
Normal file
4
config/backup/includes/mpfire
Normal file
@@ -0,0 +1,4 @@
|
||||
/var/ipfire/mpfire/db/
|
||||
/var/ipfire/mpfire/mpd.conf
|
||||
/var/ipfire/mpfire/mpd_state
|
||||
/var/ipfire/mpfire/webradio
|
||||
7
config/backup/includes/samba
Normal file
7
config/backup/includes/samba
Normal file
@@ -0,0 +1,7 @@
|
||||
/var/ipfire/samba/global
|
||||
/var/ipfire/samba/pdc
|
||||
/var/ipfire/samba/printer
|
||||
/var/ipfire/samba/private/
|
||||
/var/ipfire/samba/settings
|
||||
/var/ipfire/samba/shares
|
||||
/var/ipfire/samba/smb.conf
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
use strict;
|
||||
# enable only the following on debugging purpose
|
||||
#use warnings;
|
||||
#use CGI::Carp 'fatalsToBrowser';
|
||||
use warnings;
|
||||
use CGI::Carp 'fatalsToBrowser';
|
||||
use File::Copy;
|
||||
|
||||
require '/var/ipfire/general-functions.pl';
|
||||
@@ -35,7 +35,6 @@ my %cgiparams=();
|
||||
my %checked = ();
|
||||
my $message = "";
|
||||
my $errormessage = "";
|
||||
my @backups = `cd /var/ipfire/backup/ && ls *.ipf 2>/dev/null`;
|
||||
|
||||
$a = new CGI;
|
||||
|
||||
@@ -55,23 +54,23 @@ $cgiparams{'BACKUPLOGS'} = '';
|
||||
|
||||
if ( $cgiparams{'ACTION'} eq "download" )
|
||||
{
|
||||
open(DLFILE, "</var/ipfire/backup/$cgiparams{'FILE'}") or die "Unable to open $cgiparams{'FILE'}: $!";
|
||||
my @fileholder = <DLFILE>;
|
||||
print "Content-Type:application/x-download\n";
|
||||
print "Content-Disposition:attachment;filename=$cgiparams{'FILE'}\n\n";
|
||||
print @fileholder;
|
||||
exit (0);
|
||||
open(DLFILE, "</var/ipfire/backup/$cgiparams{'FILE'}") or die "Unable to open $cgiparams{'FILE'}: $!";
|
||||
my @fileholder = <DLFILE>;
|
||||
print "Content-Type:application/x-download\n";
|
||||
print "Content-Disposition:attachment;filename=$cgiparams{'FILE'}\n\n";
|
||||
print @fileholder;
|
||||
exit (0);
|
||||
}
|
||||
elsif ( $cgiparams{'ACTION'} eq "restore" )
|
||||
{
|
||||
my $upload = $a->param("UPLOAD");
|
||||
open UPLOADFILE, ">/tmp/restore.ipf";
|
||||
binmode $upload;
|
||||
while ( <$upload> ) {
|
||||
print UPLOADFILE;
|
||||
}
|
||||
close UPLOADFILE;
|
||||
system("/usr/local/bin/backupctrl restore >/dev/null 2>&1");
|
||||
my $upload = $a->param("UPLOAD");
|
||||
open UPLOADFILE, ">/tmp/restore.ipf";
|
||||
binmode $upload;
|
||||
while ( <$upload> ) {
|
||||
print UPLOADFILE;
|
||||
}
|
||||
close UPLOADFILE;
|
||||
system("/usr/local/bin/backupctrl restore >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
&Header::showhttpheaders();
|
||||
@@ -86,18 +85,20 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' cont
|
||||
|
||||
if ( $cgiparams{'ACTION'} eq "backup" )
|
||||
{
|
||||
if ( $cgiparams{'BACKUPLOGS'} eq "include" ){system("/usr/local/bin/backupctrl include >/dev/null 2>&1");}
|
||||
else {system("/usr/local/bin/backupctrl exclude >/dev/null 2>&1");}
|
||||
refreshpage();
|
||||
if ( $cgiparams{'BACKUPLOGS'} eq "include" ){system("/usr/local/bin/backupctrl include >/dev/null 2>&1");}
|
||||
else {system("/usr/local/bin/backupctrl exclude >/dev/null 2>&1");}
|
||||
}
|
||||
if ( $cgiparams{'ACTION'} eq "addonbackup" )
|
||||
{
|
||||
system("/usr/local/bin/backupctrl addonbackup $cgiparams{'ADDON'}");
|
||||
}
|
||||
elsif ( $cgiparams{'ACTION'} eq "delete" )
|
||||
{
|
||||
system("/usr/local/bin/backupctrl $cgiparams{'FILE'} >/dev/null 2>&1");
|
||||
refreshpage();
|
||||
system("/usr/local/bin/backupctrl $cgiparams{'FILE'} >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
############################################################################################################################
|
||||
########################################### rekursiv nach neuen Mp3s Scannen ##############################################ä
|
||||
############################################ Backups des Systems erstellen #################################################
|
||||
|
||||
if ( $message ne "" ){
|
||||
&Header::openbox('100%','left',$Lang::tr{'error messages'});
|
||||
@@ -105,21 +106,30 @@ if ( $message ne "" ){
|
||||
&Header::closebox();
|
||||
}
|
||||
|
||||
my @backups = `cd /var/ipfire/backup/ && ls *.ipf 2>/dev/null`;
|
||||
|
||||
&Header::openbox('100%', 'center', $Lang::tr{'backup'});
|
||||
|
||||
print <<END
|
||||
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
|
||||
<table width='95%' cellspacing='0'>
|
||||
<tr><td align='left' width='40%'>$Lang::tr{'logs'}</td><td align='left'>include Logfiles <input type='radio' name='BACKUPLOGS' value='include'/>/
|
||||
<input type='radio' name='BACKUPLOGS' value='exclude' checked='checked'/> exclude Logfiles</td></tr>
|
||||
<tr><td align='center' colspan='2'><input type='hidden' name='ACTION' value='backup' />
|
||||
<input type='image' alt='$Lang::tr{'Scan for Files'}' title='$Lang::tr{'Scan for Files'}' src='/images/document-save.png' /></td></tr>
|
||||
<tr><td align='left' width='40%'>$Lang::tr{'logs'}</td><td align='left'>include Logfiles
|
||||
<input type='radio' name='BACKUPLOGS' value='include'/>/
|
||||
<input type='radio' name='BACKUPLOGS' value='exclude' checked='checked'/> exclude Logfiles
|
||||
</td></tr>
|
||||
<tr><td align='center' colspan='2'>
|
||||
<input type='hidden' name='ACTION' value='backup' />
|
||||
<input type='image' alt='$Lang::tr{'backup'}' title='$Lang::tr{'backup'}' src='/images/document-save.png' />
|
||||
</td></tr>
|
||||
</table>
|
||||
</form>
|
||||
END
|
||||
;
|
||||
&Header::closebox();
|
||||
|
||||
############################################################################################################################
|
||||
############################################ Backups des Systems downloaden ################################################
|
||||
|
||||
&Header::openbox('100%', 'center', $Lang::tr{'backups'});
|
||||
|
||||
print <<END
|
||||
@@ -135,12 +145,15 @@ $Size = sprintf("%02d", $Size);
|
||||
print "<tr><td align='center'>$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size KB</td><td width='5'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='download' /><input type='hidden' name='FILE' value='$_' /><input type='image' alt='$Lang::tr{'download'}' title='$Lang::tr{'download'}' src='/images/package-x-generic.png' /></form></td>";
|
||||
print "<td width='5'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='delete' /><input type='hidden' name='FILE' value='$_' /><input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' /></form></td></tr>";
|
||||
}
|
||||
print <<END
|
||||
print <<END
|
||||
</table>
|
||||
END
|
||||
;
|
||||
&Header::closebox();
|
||||
|
||||
############################################################################################################################
|
||||
####################################### Backups des Systems wiederherstellen ###############################################
|
||||
|
||||
&Header::openbox('100%', 'center', $Lang::tr{'restore'});
|
||||
|
||||
print <<END
|
||||
@@ -150,5 +163,56 @@ print <<END
|
||||
END
|
||||
;
|
||||
&Header::closebox();
|
||||
|
||||
############################################################################################################################
|
||||
############################################# Backups von Addons erstellen #################################################
|
||||
|
||||
&Header::openbox('100%', 'center', 'addons');
|
||||
|
||||
my @addonincluds = `ls /var/ipfire/backup/addons/includes/ 2>/dev/null`;
|
||||
|
||||
print "<table width='95%' cellspacing='0'>";
|
||||
foreach (@addonincluds){
|
||||
chomp($_);
|
||||
my $Datei = "/var/ipfire/backup/addons/backup/".$_.".ipf";
|
||||
my @Info = stat($Datei);
|
||||
my $Size = $Info[7] / 1024;
|
||||
$Size = sprintf("%2d", $Size);
|
||||
if ( -e $Datei ){
|
||||
print "<tr><td align='center'>$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size KB $Lang::tr{'date'} ".localtime($Info[9])."</td>";
|
||||
print <<END
|
||||
<td align='right' width='5'>
|
||||
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
|
||||
<input type='hidden' name='ACTION' value='download' />
|
||||
<input type='hidden' name='FILE' value='addons/backup/$_.ipf' />
|
||||
<input type='image' alt='$Lang::tr{'download'}' title='$Lang::tr{'download'}' src='/images/package-x-generic.png' />
|
||||
</form>
|
||||
</td>
|
||||
<td align='right' width='5'>
|
||||
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
|
||||
<input type='hidden' name='ACTION' value='delete' />
|
||||
<input type='hidden' name='FILE' value='addons/backup/$_.ipf' />
|
||||
<input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
|
||||
</form>
|
||||
</td>
|
||||
END
|
||||
;
|
||||
}
|
||||
else{
|
||||
print "<tr><td align='center'>$Lang::tr{'backup from'} $_ </td><td colspan='2' width='10'></td>";
|
||||
}
|
||||
print <<END
|
||||
<td align='right' width='5'>
|
||||
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
|
||||
<input type='hidden' name='ACTION' value='addonbackup' />
|
||||
<input type='hidden' name='ADDON' value='$_' />
|
||||
<input type='image' alt='$Lang::tr{'backup'}' title='$Lang::tr{'backup'}' src='/images/document-save.png' />
|
||||
</form>
|
||||
</td></tr>
|
||||
END
|
||||
;
|
||||
}
|
||||
print "</table>";
|
||||
&Header::closebox();
|
||||
&Header::closebigbox();
|
||||
&Header::closepage();
|
||||
|
||||
@@ -42,11 +42,16 @@ if ( $ENV{'QUERY_STRING'} =~ /title/){
|
||||
my $song = `/usr/local/bin/mpfirectrl song 2>/dev/null`;
|
||||
if ( $song eq "" ){$song = "None";}
|
||||
&Header::showhttpheaders();
|
||||
print"<meta http-equiv='refresh' content='5'>";
|
||||
print <<END
|
||||
<table width='95%' cellspacing='0'>
|
||||
<tr bgcolor='$color{'color20'}'><td align='center' valign='center'><font color='red' face='Verdana' size='2'>-= $song =-</font></td></tr>
|
||||
</table></div>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<meta http-equiv='refresh' content='5'>
|
||||
<head><title>Song</title></head>
|
||||
<body>
|
||||
<table width='95%' cellspacing='0' align='center'>
|
||||
<tr bgcolor='$color{'color20'}'><td align='center'><font color='red' face='Verdana' size='2'>-= $song =-</font></td></tr>
|
||||
</table>
|
||||
</body>
|
||||
END
|
||||
;
|
||||
}
|
||||
@@ -254,13 +259,12 @@ $stats=~s/\\/<br \/>/g
|
||||
|
||||
&Header::openbox('100%', 'center', $Lang::tr{'mpfire controls'});
|
||||
print <<END
|
||||
|
||||
<iframe height='35' width='100%' src='/cgi-bin/mpfire.cgi?title' scrolling='no' frameborder='no' marginheight='0'></iframe>
|
||||
<table width='95%' cellspacing='0'>
|
||||
<iframe height='35' width='100%' src='/cgi-bin/mpfire.cgi?title' scrolling='no' frameborder='no' align='top' marginheight='0'></iframe>
|
||||
END
|
||||
;
|
||||
my $countsongs=`/usr/local/bin/mpfirectrl stats 2>/dev/null`;
|
||||
print "<tr><td colspan='5' align='center'><br/><b>".$countsongs."</b><br/><br/></td></tr>";
|
||||
print "<tr><td colspan='5' align='center'><b>".$countsongs."</b></td></tr>";
|
||||
print <<END
|
||||
<tr>
|
||||
<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='x' /><input type='image' alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/media-playback-stop.png' /></form></td>
|
||||
@@ -418,7 +422,7 @@ print <<END
|
||||
<tr><td align='center' colspan='2' ><textarea cols='100' rows='10' name='playlist' style='font-size:11px;width:650px;' readonly='readonly'>
|
||||
END
|
||||
;
|
||||
foreach (@playlist){print $_;}
|
||||
foreach (@playlist){$_=~s/&/&\;/g;;print $_;}
|
||||
print <<END
|
||||
</textarea></td></tr><tr>
|
||||
<td align='right'>
|
||||
@@ -454,6 +458,7 @@ my $lines=0;
|
||||
foreach (@webradio){
|
||||
my @stream = split(/\|/,$_);
|
||||
$lines++;
|
||||
chomp($stream[2]);
|
||||
if ($lines % 2) {print "<tr bgcolor='$color{'color22'}'>";} else {print "<tr>";}
|
||||
print <<END
|
||||
<td align='left'><a href="$stream[2]" target="_blank">$stream[1]</a></td>
|
||||
@@ -465,9 +470,8 @@ END
|
||||
$lines++;
|
||||
if ($lines % 2) {print "<tr bgcolor='$color{'color22'}'>";} else {print "<tr>";}
|
||||
print <<END
|
||||
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
|
||||
<td align='left'>http://<input type=text name='FILE' value='www.meineradiourl:1234' size='75' /></td>
|
||||
<td align='center'><input type='hidden' name='ACTION' value='playweb' /><input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /></form></td>
|
||||
<td align='left'><form method='post' action='$ENV{'SCRIPT_NAME'}'>http://<input type=text name='FILE' value='www.meineradiourl:1234' size='75' /></form></td>
|
||||
<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='playweb' /><input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /></form></td>
|
||||
</tr>
|
||||
END
|
||||
;
|
||||
|
||||
@@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
|
||||
fprintf (stderr, "Bad Argument!\n");
|
||||
exit (1);
|
||||
}
|
||||
else if (argc > 2){
|
||||
else if (argc > 3){
|
||||
fprintf (stderr, "Too Many Arguments!\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user