/[smeserver]/rpms/e-smith-backup/sme10/e-smith-backup-2.6.0-bz9127-add_lock_feature.patch
ViewVC logotype

Diff of /rpms/e-smith-backup/sme10/e-smith-backup-2.6.0-bz9127-add_lock_feature.patch

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

Revision 1.1 by unnilennium, Wed Apr 26 16:33:46 2017 UTC Revision 1.2 by unnilennium, Tue Jul 18 14:37:14 2017 UTC
# Line 177  diff -Nur e-smith-backup-2.6.0/root/usr/ Line 177  diff -Nur e-smith-backup-2.6.0/root/usr/
177       $console->message_page       $console->message_page
178           (           (
179            title => gettext('Backup complete'),            title => gettext('Backup complete'),
180    diff -Nur e-smith-backup-2.6.0/root/sbin/e-smith/do_backupwk e-smith-backup-2.6.0/root/sbin/e-smith/do_backupwk
181    --- e-smith-backup-2.6.0/root/sbin/e-smith/do_backupwk  2013-02-13 16:21:37.000000000 +0100
182    +++ e-smith-backup-2.6.0/root/sbin/e-smith/do_backupwk  2017-04-12 13:54:15.000000000 +0200
183    @@ -21,14 +21,27 @@
184     use strict;
185     use esmith::ConfigDB;
186     use esmith::BackupHistoryDB;
187    +use esmith::Backup;
188    +#use esmith::lockfile;
189    +
190    +# lock file.. see bug 9127
191    +my $backup_lock;
192    
193     $ENV{PATH} = "/sbin/e-smith:/sbin:/bin:/usr/bin";
194    
195     my $conf = esmith::ConfigDB->open || die("Could not open config db\n");
196    +
197    +# set lock.. if not, exit
198    +unless (SetLock()) {
199    +    die "Error: failed to create lock file.. is a backup already running?";
200    +}
201    +
202     my $backup = $conf->get('backupwk');
203     my $status = $backup->prop('status') || 'disabled';
204     my $program = $backup->prop('Program') || 'dar';
205    
206    +
207    +
208     unless ($status eq 'enabled')
209     {
210         print "Backup is disabled\n";
211    @@ -61,6 +74,8 @@
212     $now = time();
213     $backup_rec->set_prop('EndEpochTime', "$now");
214     $backup_rec->set_prop('Result', "$status");
215    +# remove lock
216    +RemoveLock();
217     exit 0;
218    
219     sub bad_exit
220    @@ -71,5 +86,26 @@
221         warn("Backup terminated: $phase failed - status: $status\n");
222         $backup_rec->set_prop('EndEpochTime', "$now");
223         $backup_rec->set_prop('Result', "$phase:$status");
224    +    # remove lock
225    +    RemoveLock();
226         return $status / 256;
227     }
228    +
229    +# subs to set and remove lock on backup
230    +
231    +sub SetLock
232    +{
233    +    print "Setting backup lock file\n";
234    +    $backup_lock = esmith::Backup::set_lock;
235    +    return $backup_lock;
236    +}
237    +
238    +sub RemoveLock
239    +{
240    +    if (defined($backup_lock))
241    +    {
242    +               print "Removing backup lock file\n";
243    +           esmith::Backup::remove_lock($backup_lock);
244    +        $backup_lock = undef;
245    +    }
246    +}


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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