summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-12-08 06:16:01 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-12-08 06:16:01 (GMT)
commitf0ea9667eaca528221a87dc455cdd1900f50c4c1 (patch)
tree0b74fed1f209a97d3503f50ba314d34ac5b4cc28 /utils
parent5c1ce65bcb85772cd06d5bef7d2afd8add5c1593 (diff)
ask for confirmation on user/group removal
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rhrd-group24
-rwxr-xr-xutils/rhrd-user24
2 files changed, 40 insertions, 8 deletions
diff --git a/utils/rhrd-group b/utils/rhrd-group
index a66597e..2b12c82 100755
--- a/utils/rhrd-group
+++ b/utils/rhrd-group
@@ -26,8 +26,9 @@ use RHRD::rddb;
sub print_usage
{
print STDERR "Usage: rhrd-group list [ (shows|jingles|pools) ]\n" .
- " rhrd-group (check|remove|get-members|get-carts|get-reports) <groupname>\n" .
+ " rhrd-group (check|get-members|get-carts|get-reports) <groupname>\n" .
" rhrd-group add <groupname> [ <description> ]\n" .
+ " rhrd-group remove [ -f ] <groupname>\n" .
" rhrd-group (add-member|remove-member|is-member) <groupname> <user>\n" .
" rhrd-group set-carts <groupname> <low> <high> [ <type> [ <enforce range> ]]\n" .
" rhrd-group set-reports <groupname> <nownext> <traffic> <music>\n";
@@ -77,7 +78,13 @@ sub add
sub remove
{
- my ($ctx, $groupname) = @_;
+ my ($ctx, $groupname, $force) = @_;
+
+ if(!$force) {
+ return 1 if(!RHRD::utils::cmdline_ask_yn("do you really wan't to delete group '$groupname'"));
+ print("\n");
+ }
+ print("removing user: $groupname\n");
my @carts = RHRD::rddb::get_show_group_carts_used($ctx, $groupname);
if(!defined $carts[0] && defined $carts[1]) {
@@ -329,11 +336,20 @@ if(defined $ctx) {
}
}
elsif($cmd eq "remove") {
- if($num_args != 2) {
+ if($num_args < 2 || $num_args > 3) {
print_usage();
$ret = 1;
} else {
- $ret = remove($ctx, $groupname);
+ if($num_args == 3) {
+ if($ARGV[1] ne '-f') {
+ print_usage();
+ $ret = 1;
+ } else {
+ $ret = remove($ctx, $ARGV[2], 1);
+ }
+ } else {
+ $ret = remove($ctx, $groupname, 0);
+ }
}
}
elsif($cmd eq "get-members") {
diff --git a/utils/rhrd-user b/utils/rhrd-user
index 4d613b6..b6d5ac6 100755
--- a/utils/rhrd-user
+++ b/utils/rhrd-user
@@ -27,8 +27,9 @@ use String::MkPasswd qw(mkpasswd);
sub print_usage
{
print STDERR "Usage: rhrd-user list\n" .
- " rhrd-user (check|remove|groups|is-grids) <username>\n" .
+ " rhrd-user (check|groups|is-grids) <username>\n" .
" rhrd-user add <username> [ <fullname> ]\n" .
+ " rhrd-user remove [ -f ] <username>\n" .
" rhrd-user set-grids <username> (1|0)\n";
}
@@ -72,7 +73,13 @@ sub add
sub remove
{
- my ($ctx, $username) = @_;
+ my ($ctx, $username, $force) = @_;
+
+ if(!$force) {
+ return 1 if(!RHRD::utils::cmdline_ask_yn("do you really want to delete user '$username'"));
+ print("\n");
+ }
+ print("removing user: $username\n");
my @results = RHRD::rddb::remove_user($ctx, $username);
if(!defined $results[0] && defined $results[2]) {
@@ -166,11 +173,20 @@ if(defined $ctx) {
$ret = add($ctx, $username, $ARGV[2]);
}
} elsif($cmd eq "remove") {
- if($num_args != 2) {
+ if($num_args < 2 || $num_args > 3) {
print_usage();
$ret = 1;
} else {
- $ret = remove($ctx, $username);
+ if($num_args == 3) {
+ if($ARGV[1] ne '-f') {
+ print_usage();
+ $ret = 1;
+ } else {
+ $ret = remove($ctx, $ARGV[2], 1);
+ }
+ } else {
+ $ret = remove($ctx, $username, 0);
+ }
}
} elsif($cmd eq "groups") {
if($num_args != 2) {