blob: c6c24e039cdaf0ae3acef748f57d893b211e9a2e (
plain)
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
|
#!/usr/bin/perl -Tw
# quick'n'dirty hack of fs-setup to add radius attributes
# (i'm not sure this even works in the new world of schema changes - everyone
# uses attributes via groups now)
use strict;
use DBI;
use FS::UID qw(adminsuidsetup);
use FS::raddb;
my %attrib2db =
map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib;
my $user = shift or die &usage;
my $dbh = adminsuidsetup $user;
###
print "\n\n", <<END, ":";
Enter the additional RADIUS reply attributes you need to track for
each user, separated by whitespace.
END
my @attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; }
split(" ",&getvalue);
sub getvalue {
my($x)=scalar(<STDIN>);
chop $x;
$x;
}
###
my($char_d) = 80; #default maxlength for text fields
###
foreach my $attribute ( @attributes ) {
my $statement =
"ALTER TABLE svc_acct ADD COLUMN radius_$attribute varchar($char_d) NULL";
my $sth = $dbh->prepare( $statement )
or warn "Error preparing $statement: ". $dbh->errstr;
my $rc = $sth->execute
or warn "Error executing $statement: ". $sth->errstr;
$statement =
"ALTER TABLE h_svc_acct ADD COLUMN radius_$attribute varchar($char_d) NULL";
$sth = $dbh->prepare( $statement )
or warn "Error preparing $statement: ". $dbh->errstr;
$rc = $sth->execute
or warn "Error executing $statement: ". $sth->errstr;
}
$dbh->commit or die $dbh->errstr;
$dbh->disconnect or die $dbh->errstr;
print "\n\n", "Now you must run dbdef-create.\n\n";
sub usage {
die "Usage:\n fs-radius-add-reply user\n";
}
|