/[smeserver]/rpms/e-smith-backup/sme9/e-smith-backup-2.4.0-workstation-WolMail.patch
ViewVC logotype

Contents of /rpms/e-smith-backup/sme9/e-smith-backup-2.4.0-workstation-WolMail.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Sat Feb 8 22:53:55 2014 UTC (10 years, 8 months ago) by wellsi
Branch: MAIN
CVS Tags: e-smith-backup-2_4_0-46_el6_sme, e-smith-backup-2_4_0-28_el6_sme, e-smith-backup-2_4_0-35_el6_sme, e-smith-backup-2_4_0-44_el6_sme, e-smith-backup-2_4_0-37_el6_sme, e-smith-backup-2_4_0-45_el6_sme, e-smith-backup-2_4_0-31_el6_sme, e-smith-backup-2_4_0-30_el6_sme, e-smith-backup-2_4_0-39_el6_sme, e-smith-backup-2_4_0-40_el6_sme, e-smith-backup-2_4_0-43_el6_sme, e-smith-backup-2_4_0-32_el6_sme, e-smith-backup-2_4_0-42_el6_sme, e-smith-backup-2_4_0-34_el6_sme, e-smith-backup-2_4_0-36_el6_sme, e-smith-backup-2_4_0-33_el6_sme, e-smith-backup-2_4_0-26_el6_sme, e-smith-backup-2_4_0-38_el6_sme, e-smith-backup-2_4_0-29_el6_sme, e-smith-backup-2_4_0-27_el6_sme, e-smith-backup-2_4_0-41_el6_sme, HEAD
* Sat Feb 8 2014 Ian Wells <esmith@wellsi.com> 2.4.0-26.sme
- Workstation Backup, Mail and WOL now subroutines [SME: 8193]
- Workstation Backup, remove the need for a temporary directory, updated. [SME: 7767]

1 diff -ruN e-smith-backup-2.4.0.p24/root/etc/e-smith/events/actions/workstation-backup-dar e-smith-backup-2.4.0/root/etc/e-smith/events/actions/workstation-backup-dar
2 --- e-smith-backup-2.4.0.p24/root/etc/e-smith/events/actions/workstation-backup-dar 2014-02-05 16:43:10.000000000 -0800
3 +++ e-smith-backup-2.4.0/root/etc/e-smith/events/actions/workstation-backup-dar 2014-02-08 14:46:56.000000000 -0800
4 @@ -36,21 +36,16 @@
5 sub run_backup;
6
7 my $job = shift || 'DailyBackup';
8 -my $report;
9 -
10 my $confdb = esmith::ConfigDB->open;
11 my $backupwk = $confdb->get('backupwk') or die "No backupwk db entry found\n";
12 -my $internalinterface = $confdb->get('InternalInterface') or die "No internalinterface db entry found\n";
13 -
14 my $bkname = strftime '%Y%m%d%H%M%S', localtime;
15 my $dow = strftime '%w', localtime;
16 +my $ref = "";
17
18 my $id = $backupwk->prop('Id') ||
19 $confdb->get('SystemName')->value . "." . $confdb->get('DomainName')->value;
20 -my $err;
21 -my $ref = "";
22 -
23 -
24 +my $internalinterface = $confdb->get('InternalInterface') or die "No internalinterface db entry found\n";
25 +my $ether = $internalinterface->prop('Name');
26 my $smbhost = $backupwk->prop('SmbHost');
27 my $smbshare = $backupwk->prop('SmbShare');
28 my $smbhostmac = $backupwk->prop('SmbHostMAC');
29 @@ -66,29 +61,21 @@
30 my $VFSType = $backupwk->prop('VFSType') || 'cifs';
31 my $fullday = $backupwk->prop('FullDay'); $fullday = 7 unless defined $fullday;
32 my $mail = $backupwk->prop('MailNotify') || 'yes';
33 -my $mntdir = ($VFSType eq 'usb') ? "\/$smbshare" : $backupwk->prop('Mount') || '/mnt/smb';
34 my $frommail = $backupwk->prop('FromMail') || 'admin-backup';
35 my $tomail = $backupwk->prop('ToMail') || 'admin';
36 +my $mntdir = ($VFSType eq 'usb') ? "\/$smbshare" : $backupwk->prop('Mount') || '/mnt/smb';
37 my $deleteearly = $backupwk->prop('DeleteEarly') || 'false';
38 -my $ether = $internalinterface->prop('Name');
39
40 -
41 -$report .= "From: ".$frommail."\n";
42 +my $report = "From: $frommail\n";
43 $report .= "To: $tomail\n";
44 -$report .= "Subject: Daily Backup Report: ".$id."\n\n";
45 +$report .= "Subject: Daily Backup Report: $id\n\n";
46 $report .= "================================== \n";
47 $report .= "DAILY BACKUP TO WORKSTATION REPORT \n";
48 $report .= "================================== \n";
49 -$report .= "Backup of ".$id." started at " .localtime() . "\n";
50 +$report .= "Backup of $id started at " .localtime() . "\n";
51
52 # ping the SMB Host to see if it is awake
53 -
54 -if (defined($smbhostmac) && (system("ping -c1 $smbhost > /dev/null") != 0)) {
55 - $report .= "$smbhost might be asleep, attempting to wake\n";
56 - system("ether-wake -i $ether $smbhostmac");
57 - $report .= "Waiting $smbhostdelay seconds...\n";
58 - sleep $smbhostdelay;
59 -}
60 +$report .= &wol ($ether,$smbhost,$smbhostmac,$smbhostdelay);
61
62 # verify backup directory not already mounted
63 if (!&checkMount ($mntdir))
64 @@ -102,7 +89,7 @@
65 createTree ($mntdir);
66
67 # mount the backup directory
68 -$err = &dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType);
69 +my $err = &dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType);
70 ldie("Error while mounting <//$smbhost/$smbshare>\n" . $err) if $err;
71
72 # verify $mntdir is mounted
73 @@ -129,8 +116,8 @@
74 }
75
76 # if no set directory, make it
77 -my $setname = "set" . $setnum;
78 -my $setdirname = $mntdir . "/$id/" . $setname;
79 +my $setname = "set$setnum";
80 +my $setdirname = "$mntdir/$id/$setname";
81 &createTree ($setdirname);
82
83 $report .= "Destination //$smbhost/$smbshare/$id/$setname\n";
84 @@ -247,13 +234,8 @@
85
86 $report .= "Backup successfully terminated at ".localtime()."\n";
87
88 -if ($mail eq 'yes')
89 -{
90 - open (MAIL, "|/var/qmail/bin/qmail-inject")
91 - || die "Cannot start mail program: $!\n";
92 - print MAIL $report;
93 - close(MAIL);
94 -}
95 +# Send the Workstation Backup report
96 +if ($mail eq 'yes') {&sendReport ($report);}
97
98 exit (0);
99
100 @@ -265,10 +247,7 @@
101 $report .= $errmsg;
102 if (($mail eq 'yes') || ($mail eq 'error'))
103 {
104 - open (MAIL, "|/var/qmail/bin/qmail-inject")
105 - || die "Cannot start mail program: $!: message was $errmsg\n";
106 - print MAIL $report;
107 - close(MAIL);
108 + &sendReport ($report,$errmsg);
109 }
110 system("/bin/umount", "$mntdir") if (!&checkMount ($mntdir));
111 die($errmsg);
112 @@ -425,6 +404,30 @@
113 }
114 }
115
116 +sub sendReport
117 +{
118 + my $text = shift;
119 + my $error = shift || "";
120 + open (MAIL, "|/var/qmail/bin/qmail-inject")
121 + || die "Cannot start mail program: $! $error\n";
122 + print MAIL $text;
123 + close(MAIL);
124 +}
125 +
126 +sub wol
127 +{
128 + my ($ether,$host,$mac,$delay) = @_;
129 + my $output="";
130 +
131 + if (defined($mac) && (system("ping -c1 $host > /dev/null") != 0)) {
132 + $output .= "$host might be asleep, attempting to wake\n";
133 + system("ether-wake -i $ether $mac");
134 + $output .= "Waiting $delay seconds...\n";
135 + sleep $delay;
136 + }
137 + return $output;
138 +}
139 +
140 sub updateDarCatalog ()
141 {
142 # update dar_manager catalog
143 @@ -467,7 +470,7 @@
144 }
145 }
146 waitpid ($pid, 0);
147 - $err = WEXITSTATUS($?);
148 + my $err = WEXITSTATUS($?);
149 close (DAR_LIST);
150 ldie ("Catalog error : $err") if $err;
151

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed