3 # quick'n'dirty hack of fs-setup to add radius attributes
7 use FS::UID qw(adminsuidsetup checkeuid getsecrets);
10 die "Not running uid freeside!" unless checkeuid();
13 map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib;
15 my $user = shift or die &usage;
18 my $dbh = adminsuidsetup $user;
22 print "\n\n", <<END, ":";
23 Enter the additional RADIUS check attributes you need to track for
24 each user, separated by whitespace.
26 my @attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; }
30 my($x)=scalar(<STDIN>);
37 my($char_d) = 80; #default maxlength for text fields
41 foreach my $attribute ( @attributes ) {
44 "ALTER TABLE svc_acct ADD COLUMN rc_$attribute varchar($char_d) NULL";
45 my $sth = $dbh->prepare( $statement )
46 or warn "Error preparing $statement: ". $dbh->errstr;
47 my $rc = $sth->execute
48 or warn "Error executing $statement: ". $sth->errstr;
51 "ALTER TABLE h_svc_acct ADD COLUMN rc_$attribute varchar($char_d) NULL";
52 $sth = $dbh->prepare( $statement )
53 or warn "Error preparing $statement: ". $dbh->errstr;
55 or warn "Error executing $statement: ". $sth->errstr;
59 $dbh->commit or die $dbh->errstr;
61 $dbh->disconnect or die $dbh->errstr;
63 print "\n\n", "Now you must run dbdef-create.\n\n";
66 die "Usage:\n fs-radius-add-check user\n";