-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbtrfsman-lib.pl
executable file
·115 lines (78 loc) · 2.36 KB
/
btrfsman-lib.pl
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
=head1 btrfsman-lib.pl
Functions for managing btrfs
=cut
BEGIN { push(@INC, ".."); };
use WebminCore;
&init_config();
=head1 show_parted
Display GNU parted -l
=cut
sub show_parted{
if (has_command('parted')){
print ui_hidden_table_start($text{'arr_parted_h'}, "width=100%",4,4);
$result = `parted -l 2>&1`;
$result =~ s/^\s+//;
$result =~ s/^\r+//;
$result =~ s/^\n+//;
$result =~ s/\n/<br>/g;
print ui_table_row($result);
print ui_hidden_table_end();
@splitres = split /\/dev\// , $result;
$did=1;
$did=1;
for (1..scalar(@splitres)-1){
@splitres2 = split /:/, @splitres[$did] ;
@devicelist[$did]= '/dev/' . @splitres2[0];
$did++;
}
print $text{'index_youhave1'}, scalar(@devicelist), $text{'index_youhave4'};
$did=1;
for (1..scalar(@devicelist)-1){
print @devicelist[$did], " ";
$did++;
}
return @devicelist;
}else{
print $text{'txt_error'}, $text{'txt_error_noparted'}, $text{'txt_p'};
}
}
=head1 show_fs
Display filesystems - info
=cut
sub show_fs{
$result = `btrfs fi show 2>&1`;
$result =~ s/^\s+//;
$result =~ s/^\r+//;
$result =~ s/^\n+//;
$result =~ s/\n/<br>/g;
print ui_hidden_table_start( $text{'index_btrfsfis'}, "width=100%", 1, 1 );
print ui_table_row( $result);
print ui_hidden_table_end();
#$result =~ s/^\s+//;
@fsa = split /Label/, $result;
print $text{'index_youhave1'}, (scalar (@fsa) - 1), $text{'index_youhave2'};
$did=1;
for (1..scalar(@fsa)-1){
#print $did, "#", @fsa[$did],"<p>";
@splitres = split /\:/, @fsa[$did];
#print "!1", @splitres[1], "<p>!2", @splitres[2], "<p>!3", @splitres[3], "<p>";
print ui_columns_start([$text{'index_fs'} ,""]);
@label[$did] = @splitres[1];
@label[$did] =~ s/uuid//g;
@label[$did] =~ s/[\x27 ]//g;
print ui_columns_row([$text{'index_lb'}, @label[$did] ]);
@uuid[$did] = @splitres[2];
@uuid[$did] =~ s/^\s//;
@uuid[$did] =~ s/<br>(.*)//;
print ui_columns_row([$text{'index_uu'}, @uuid[$did] ]);
@bdevices[$did] = @splitres[2];
@bdevices[$did] =~ s/(.*)Total//;
@bdevices[$did] =~ s/Btrfs(.*)//;
@bdevices[$did] =~ s/<br>$//g;
@bdevices[$did] =~ s/<br>$//g;
print ui_columns_row([$text{'index_dev'}, @bdevices[$did] ]);
print ui_columns_end();
$did++;
}
}
1;