File: UndoBastille

package info (click to toggle)
bastille 1:1.3.0-2.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,576 kB
  • ctags: 397
  • sloc: perl: 8,407; sh: 1,879; ansic: 638; makefile: 203; csh: 17
file content (65 lines) | stat: -rw-r--r-- 1,626 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl

# This script provides undo functionality for Bastille
# Copyright 2000, Jay Beale
# Copyright 2001, Hewlett Packard Corporation

# This script simply runs the undo shell command which was build during the course of the
# Backend run, then removes it.

use Getopt::Long;
use English;
use Cwd;

use lib "/usr/lib";
push (@INC,"/usr/lib/perl5/site_perl/");
push (@INC,"/usr/lib/Bastille");

require Bastille::API;
import Bastille::API;

#use Bastille::API; # To allow us to get rid of hardcoding -RwF

if( ! Getopt::Long::GetOptions(
    "d"     => \$nodisclaim) ) {
    $error = 1; # parse error
} else {
    $error = 0; # no parse error
}

if (( @ARGV ) || ( $error)) { # GetOptions didn't parse all of the args
    &ErrorLog("Error encountered while parsing command line options.");
}

&showDisclaimer($nodisclaim);

### Process command-line arguments...
# getopts("u:",\%options);  ## This is never used

#if ($options{r}) {   # This option was never any use since "backup" is always under "undo"
# by definition in the API.  -u allows you to change where that is... so -r is useless

#    $GLOBAL_PREFIX = $options{r};
#} else {
#    $GLOBAL_PREFIX = "";
#};


# Override undo directory coming in from API
#if ($options{u}) {
#    $GLOBAL_BDIR{"undo"} = $options{u};
#}

my $undo_script=&getGlobal('BFILE', "undo-actions");
my $mv=&getGlobal('BIN','mv');

system($undo_script);  # run undo script

# move script to ensure we don't run it again
if ( -e $undo_script ){
system("$mv $undo_script ${undo_script}.last");
} else {
    &ErrorLog("System is in original state, no action taken.\n");
    exit 1;
}