HCoop
/
clinton
/
scripts.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BCC admins@ instead of docelic@ in quota check
[clinton/scripts.git]
/
freeze
diff --git
a/freeze
b/freeze
index
5f0c282
..
660619a
100755
(executable)
--- a/
freeze
+++ b/
freeze
@@
-7,7
+7,7
@@
#
# Display frozen users or details for one user (one user implies -verbose):
# freeze [user], OR
#
# Display frozen users or details for one user (one user implies -verbose):
# freeze [user], OR
-# freeze
--action list [--verbose] | freeze -a l [-v |
user]
+# freeze
[ --action list | -a ] [--verbose | -v] [
user]
#
# Freeze user:
# freeze -a f user
#
# Freeze user:
# freeze -a f user
@@
-56,10
+56,10
@@
# unfreezed.
#
# Module 'record' creates or deletes initial user entry in $$store.
# unfreezed.
#
# Module 'record' creates or deletes initial user entry in $$store.
-# If you create a new module that will use the store
(announce it'
s
+# If you create a new module that will use the store
, announce it
s
# hash key by creating it empty in record().
#
# hash key by creating it empty in record().
#
-# For additional
help
, here's how the stored hash might look like:
+# For additional
detail
, here's how the stored hash might look like:
#
#
# $store = {
#
#
# $store = {
@@
-93,12
+93,12
@@
use Storable qw/lock_nstore lock_retrieve/;
use Getopt::Long qw/GetOptions/;
use constant DEBUG => 1;
use Getopt::Long qw/GetOptions/;
use constant DEBUG => 1;
-use constant DRY =>
1
;
-use constant STORE => "/
tmp/stor
e";
+use constant DRY =>
0
;
+use constant STORE => "/
var/tmp/frozen/cach
e";
use constant DEFAULT_SHELL => '/bin/bash';
use constant FROZEN_SHELL => '/afs/hcoop.net/common/etc/scripts/frozen_shell';
use constant DEFAULT_SHELL => '/bin/bash';
use constant FROZEN_SHELL => '/afs/hcoop.net/common/etc/scripts/frozen_shell';
-use constant PUBLIC_ACCESS =>
[qw/mire/]
;
-use constant RUN_SERVER => '
handgun
';
+use constant PUBLIC_ACCESS =>
(qw/mire/)
;
+use constant RUN_SERVER => '
deleuze
';
my $store = {}; # cached info
my $action = 'list'; # list, freeze, unfreeze
my $store = {}; # cached info
my $action = 'list'; # list, freeze, unfreeze
@@
-121,6
+121,10
@@
unless ( GetOptions (
$user = shift ;
$user = shift ;
+if ( $> == 0 or $< == 0 ) {
+ die "Run script under admin account without sudo.\n";
+}
+
if ( -e STORE ) {
$store = lock_retrieve(STORE);
} else {
if ( -e STORE ) {
$store = lock_retrieve(STORE);
} else {
@@
-188,7
+192,7
@@
lock_nstore $store, STORE;
###########################################################################
# Helpers below
###########################################################################
# Helpers below
-# GETENT:
+# GETENT
(available to modules automatically in @user)
:
# 0 1 2 3 4 5 6
# docelic:x:10235:65534:docelic:/afs/hcoop.net/user/d/do/docelic:/bin/bash
# 0 1 2 3 4 5 6
# docelic:x:10235:65534:docelic:/afs/hcoop.net/user/d/do/docelic:/bin/bash
@@
-264,34
+268,38
@@
sub domtool {
# XXX how to restart services after that?
if ($a =~ /^f/i) {
# XXX how to restart services after that?
if ($a =~ /^f/i) {
- my $domains = `domtool-admin perms
docelic
| grep '^domain: '`;
+ my $domains = `domtool-admin perms
$u
| grep '^domain: '`;
chomp $domains;
my @domains = split / +/, $domains;
for (@domains) {
push @{ $$store{$u}{domains} }, $_;
chomp $domains;
my @domains = split / +/, $domains;
for (@domains) {
push @{ $$store{$u}{domains} }, $_;
- if (!DRY) {
- system("domtool-admin rmdom $_")
- } else {
- warn qq|system("domtool-admin rmdom $_")\n|
- }
+
+ # As per adamc's suggestion, I should not be
+ # running rmdom explicitly.
+ # https://bugzilla.hcoop.net/show_bug.cgi?id=555
+ #if (!DRY) {
+ # system("domtool-admin rmdom $_")
+ #} else {
+ # warn qq|system("domtool-admin rmdom $_")\n|
+ #}
}
}
-
if (!DRY) {
-
system("domtool-rmuser $_
")
-
} else {
-
warn qq|system("domtool-rmuser $_"
\n|
-
}
+ if (!DRY) {
+
system("domtool-rmuser $u
")
+ } else {
+
warn qq|system("domtool-rmuser $u")
\n|
+ }
push @{ $$store{$u}{modules} }, 'domtool';
}
elsif ($a =~ /^u/i) {
push @{ $$store{$u}{modules} }, 'domtool';
}
elsif ($a =~ /^u/i) {
-
if (!DRY) {
-
system("domtool-adduser $_
")
-
} else {
-
warn qq|system("domtool-adduser $_
")\n|
-
}
+ if (!DRY) {
+
system("domtool-adduser $u
")
+ } else {
+
warn qq|system("domtool-adduser $u
")\n|
+ }
for ( @{ $$store{$u}{domains} } ) {
if (!DRY) {
for ( @{ $$store{$u}{domains} } ) {
if (!DRY) {
@@
-346,9
+354,9
@@
sub slay {
if ($a =~ /^f/i) {
for ( PUBLIC_ACCESS ) {
if (!DRY) {
if ($a =~ /^f/i) {
for ( PUBLIC_ACCESS ) {
if (!DRY) {
- qx{ssh -K $_ s
lay $u}; sleep 5; qx{ssh -K $_
slay -9 $u};
+ qx{ssh -K $_ s
udo slay $u}; sleep 5; qx{ssh -K $_ sudo
slay -9 $u};
} else {
} else {
- warn qq|ssh -K $_ s
lay $u; sleep 5; ssh -K $_
slay -9 $u\n|
+ warn qq|ssh -K $_ s
udo slay $u; sleep 5; ssh -K $_ sudo
slay -9 $u\n|
}
}
}
}