summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-09-28 23:46:37 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-09-28 23:46:37 (GMT)
commit97c41e8f8472e02c379a495065a4432abd941971 (patch)
tree648fae623f8d07ee199bb28431d4fa3612616c43 /utils
parentbcd58fdfc6d8496d5fa250aa8d6e0d0d3a89d49d (diff)
added rd-show
fixed debian package
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rd-group22
-rwxr-xr-xutils/rd-show58
-rwxr-xr-xutils/rd-user6
3 files changed, 72 insertions, 14 deletions
diff --git a/utils/rd-group b/utils/rd-group
index 1717caf..72c39e9 100755
--- a/utils/rd-group
+++ b/utils/rd-group
@@ -46,13 +46,13 @@ my ($dbh, undef, $errorstring) = RHRD::rddb::opendb();
if(defined $dbh) {
if($cmd eq "check") {
(my $result, my $status, $errorstring) = RHRD::rddb::check_group($dbh, $groupname);
- print "$result, $status: $errorstring\n";
+ print STDERR "$result, $status: $errorstring\n";
RHRD::rddb::closedb($dbh);
exit $result;
} elsif($cmd eq "add") {
(my $cnt, undef, $errorstring) = RHRD::rddb::add_group($dbh, $groupname, $ARGV[2]);
unless(defined $cnt) {
- print "$errorstring\n";
+ print STDERR "$errorstring\n";
RHRD::rddb::closedb($dbh);
exit 1;
}
@@ -60,7 +60,7 @@ if(defined $dbh) {
} elsif($cmd eq "remove") {
my @results = RHRD::rddb::remove_group($dbh, $groupname);
if(!defined $results[0] && defined $results[2]) {
- print "$results[2]\n";
+ print STDERR "$results[2]\n";
} else {
for my $href (@results) {
print int($href->{cnt}) . " " . $href->{name} . " deleted\n";
@@ -69,7 +69,7 @@ if(defined $dbh) {
} elsif($cmd eq "get-members") {
my @users = RHRD::rddb::get_group_members($dbh, $groupname);
if(!defined $users[0] && defined $users[1]) {
- print "$users[2]\n";
+ print STDERR "$users[2]\n";
RHRD::rddb::closedb($dbh);
exit 1;
}
@@ -79,7 +79,7 @@ if(defined $dbh) {
} elsif($cmd eq "add-member") {
(my $cnt, undef, $errorstring) = RHRD::rddb::add_group_member($dbh, $groupname, $ARGV[2]);
unless(defined $cnt) {
- print "$errorstring\n";
+ print STDERR "$errorstring\n";
RHRD::rddb::closedb($dbh);
exit 1;
}
@@ -87,7 +87,7 @@ if(defined $dbh) {
} elsif($cmd eq "remove-member") {
(my $cnt, undef, $errorstring) = RHRD::rddb::remove_group_member($dbh, $groupname, $ARGV[2]);
unless(defined $cnt) {
- print "$errorstring\n";
+ print STDERR "$errorstring\n";
RHRD::rddb::closedb($dbh);
exit 1;
}
@@ -96,7 +96,7 @@ if(defined $dbh) {
(my $cnt, undef, $errorstring) = RHRD::rddb::is_group_member($dbh, $groupname, $ARGV[2]);
RHRD::rddb::closedb($dbh);
unless(defined $cnt) {
- print "$errorstring\n";
+ print STDERR "$errorstring\n";
exit 1;
}
print $ARGV[2] . " is" . (($cnt) ? "" : " not") . " a member\n";
@@ -104,7 +104,7 @@ if(defined $dbh) {
} elsif($cmd eq "get-carts") {
my ($low, $high, $type, $enforce_range) = RHRD::rddb::get_group_carts($dbh, $groupname);
unless(defined $low) {
- print "$type\n";
+ print STDERR "$type\n";
RHRD::rddb::closedb($dbh);
exit 1;
}
@@ -112,7 +112,7 @@ if(defined $dbh) {
} elsif($cmd eq "set-carts") {
(my $cnt, undef, $errorstring) = RHRD::rddb::set_group_carts($dbh, $groupname, $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5]);
unless(defined $cnt) {
- print "$errorstring\n";
+ print STDERR "$errorstring\n";
RHRD::rddb::closedb($dbh);
exit 1;
}
@@ -120,7 +120,7 @@ if(defined $dbh) {
} elsif($cmd eq "get-reports") {
my ($nownext, $traffic, $music) = RHRD::rddb::get_group_reports($dbh, $groupname);
unless(defined $nownext) {
- print "$music\n";
+ print STDERR "$music\n";
RHRD::rddb::closedb($dbh);
exit 1;
}
@@ -128,7 +128,7 @@ if(defined $dbh) {
} elsif($cmd eq "set-reports") {
(my $cnt, undef, $errorstring) = RHRD::rddb::set_group_reports($dbh, $groupname, $ARGV[2], $ARGV[3], $ARGV[4]);
unless(defined $cnt) {
- print "$errorstring\n";
+ print STDERR "$errorstring\n";
RHRD::rddb::closedb($dbh);
exit 1;
}
diff --git a/utils/rd-show b/utils/rd-show
new file mode 100755
index 0000000..4fe9def
--- /dev/null
+++ b/utils/rd-show
@@ -0,0 +1,58 @@
+#!/usr/bin/perl -w
+#
+# rhrdlibs
+#
+# Copyright (C) 2015 Christian Pointner <equinox@helsinki.at>
+#
+# This file is part of rhrdlibs.
+#
+# rhrdlibs is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# any later version.
+#
+# rhrdlibs is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with rhrdlibs. If not, see <http://www.gnu.org/licenses/>.
+#
+
+use strict;
+use RHRD::rddb;
+
+# this is ridiculous but makes it a little harder to create/remove users...
+if ($> != 0 ) {
+ print STDERR "this must be run as root!\n";
+ exit 1;
+}
+
+my $num_args = $#ARGV + 1;
+if ($num_args != 2 && $num_args !=3) {
+ print STDERR "Usage: rd-show (add|remove) ??\n";
+ exit 1;
+}
+
+my $cmd = $ARGV[0];
+
+my ($dbh, undef, $errorstring) = RHRD::rddb::opendb();
+if(defined $dbh) {
+ if($cmd eq "add") {
+ # TODO: implement this
+ } elsif($cmd eq "remove") {
+ # TODO: implement this
+ } else {
+ print STDERR "unknown command\n";
+ RHRD::rddb::closedb($dbh);
+ exit 1;
+ }
+
+ RHRD::rddb::closedb($dbh);
+} else {
+ print STDERR "$errorstring\n";
+ exit 1;
+}
+
+exit 0
diff --git a/utils/rd-user b/utils/rd-user
index 5b9d479..6b191be 100755
--- a/utils/rd-user
+++ b/utils/rd-user
@@ -44,14 +44,14 @@ my ($dbh, undef, $errorstring) = RHRD::rddb::opendb();
if(defined $dbh) {
if($cmd eq "check") {
(my $result, my $status, $errorstring) = RHRD::rddb::check_user($dbh, $username);
- print "$result, $status: $errorstring\n";
+ print STDERR "$result, $status: $errorstring\n";
RHRD::rddb::closedb($dbh);
exit $result;
} elsif($cmd eq "add") {
my $token = mkpasswd(-length => 16, -minnum => 3, -minupper => 3, -minspecial => 0);
(my $cnt, undef, $errorstring) = RHRD::rddb::add_user($dbh, $username, $token, $fullname);
unless(defined $cnt) {
- print "$errorstring\n";
+ print STDERR "$errorstring\n";
RHRD::rddb::closedb($dbh);
exit 1;
}
@@ -59,7 +59,7 @@ if(defined $dbh) {
} elsif($cmd eq "remove") {
my @results = RHRD::rddb::remove_user($dbh, $username);
if(!defined $results[0] && defined $results[2]) {
- print "$results[2]\n";
+ print STDERR "$results[2]\n";
} else {
for my $href (@results) {
print int($href->{cnt}) . " " . $href->{name} . " deleted\n";