-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnapper
executable file
·132 lines (96 loc) · 2.63 KB
/
snapper
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/perl
use Term::ANSIColor; # This allows our code to be bold / coloured in the terminal
#Some Config
require "./config/config.conf"; # This file has a list of Paths used
require "./lib/common_functions.pl"; # Some common functions
$appName = "Snapper"; # The name of this Application
printTitle(); # Print the title
# Check for root level access before proceeding
checkForRoot($appName);
# Check if we're passing the path to snapshot from shell
if ( $ARGV[0] eq "" ) {
print "• Enter the Path you want to Snapshot:\n \$ ";
$_ = <STDIN>;
$path = $_;
$path =~ s/^\s+|\s+$//g;
if ($path eq '~' || $path eq '~/'){
print "\n Use an absolute path Biatch!\n\n";
exit();
}
}
else {
$path = $ARGV[0];
}
# Check if we're running in manual mode
if ( $ARGV[1] eq "-m" ) {
$manual_mode = 1;
}
else {
}
# Check if we're running in Home directory scanning
if ( $ARGV[1] eq "-h" ) {
$home_dir_mode = 1;
}
else {
}
# Remove carrage return from STDIN
# Add forward Slash if Missing
massagePath($path);
# Check to see if Path Exists
checkPathExists($path);
print "• Confirm Snapshot of ";
print color 'bold red';
print "$path";
print color 'reset';
print " [Y/N]:";
$_ = <STDIN>;
$answer = $_;
chomp($answer);
if ( $answer eq "y"
|| $answer eq "Y"
|| $answer eq "Yes"
|| $answer eq "yes"
|| $answer eq "YES"
|| $answer eq '' )
{
print "• Creating Snapshot of $path\n";
$original = time;
`$logger -r $path ./tmp/$original.dat`;
print "• Snapshot complete\n";
}
else {
print "Ok Have it your way Biatch!\n\n";
exit();
}
print color 'bold';
print "• Perform your Installation -";
print color 'reset';
print "\n Please install and configure your software.";
print "\n When you are done, press ";
print color 'bold';
print "ENTER";
print color 'reset';
print " to continue.\n";
print " \$ ";
$_ = <STDIN>;
print "\n Checking $path to see what you've installed... \n";
$newTime = time;
`sudo rm -rf ./tmp/$path`;
`sudo $logger -r $path new.dat ./tmp/$original.dat > changes.txt`;
$path = reverse; chop; $path = reverse;
`sudo $packer ./changes.txt ./tmp/snapshot-$newTime`;
`mv ./changes.txt ./tmp/snapshot-$newTime`;
#`sudo $packer ./changes.txt ./tmp/$path-pkg`;
`cat ./new.dat`;
#remove new.dat
#`rm ./new.dat`;
`sudo $mkdmg ./tmp/snapshot-$newTime $newTime`;
`sudo mv ./tmp/snapshot-$newTime.dmg ./snapshots`;
#`sudo mv ./tmp/snapshot-$newTime_rw.dmg ./snapshots`;
`sudo hdiutil attach -readwrite ./snapshots/snapshot-$newTime.dmg`;
#`sudo rm -rf ./tmp/*`;
`open ./snapshots`;
`chmod 777 ./snapshots`;
if ( $manual_mode == 1 ) {
# `open ./tmp/$path-pkg`;
}