summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 42b9313)
raw | patch | inline | side by side (parent: 42b9313)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 16 Sep 2009 12:49:26 +0000 (12:49 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 16 Sep 2009 12:49:26 +0000 (12:49 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14258 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/client/events/gosaTriggered.pm | patch | blob | history |
index 575a5663a912f3672a53a1c6b102598ac98f4129..93ddbed27131461ad734ca6cfe470c756c8c3a69 100644 (file)
END {}
+### Parameter declarations ###################################################
+my $userNotification;
+my %cfg_defaults = (
+"ClientPackages" => {
+ "user-notification-of-admin-activities" => [\$userNotification, 'enabled'],
+ },
+);
+
+# Read config file
+&read_configfile($main::cfg_file, %cfg_defaults);
+
###############################################################################
=over
my ($msg, $msg_hash) = @_;
my $timeout;
+ # Invalid timeout parameter are set to 0
if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) {
$timeout = -1;
- }
- else {
+ } else {
$timeout = @{$msg_hash->{timeout}}[0];
}
- # check logged in user
- my $logged_in_user = 1;
- if( $logged_in_user ) {
- # TODO do something
- }
- else {
- $timeout = 0;
- }
-
- # execute function
- if( $timeout == 0 ) {
- print STDERR ("shutdown -r +$timeout\n");
- }
- elsif( $timeout > 0 ) {
- print STDERR ("shutdown -r +$timeout\n");
- }
- elsif( $timeout < 0 ) {
- print STDERR "The administrator has sent a signal to reboot this workstation. It will reboot after you've logged out.\n";
- open(FILE, "> /etc/gosa-si/event");
- print FILE "trigger_action_localboot\n";
- close(FILE);
- }
+ # Check if user should be notificated or not
+ if ($userNotification eq "enabled") {
+ # Check logged in user
+ my @user_list = &get_logged_in_users;
+ if( @user_list >= 1 ) {
+ open(FILE, "> /etc/gosa-si/event");
+ print FILE "trigger_action_localboot\n";
+ close(FILE);
+ }
+ }
else {
- # TODO do something, error handling, logging
+ system( "/sbin/shutdown -r +$timeout &" );
}
return;
my ($msg, $msg_hash) = @_;
my $timeout;
+ # Invalid timeout parameter are set to 0
if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) {
$timeout = 0;
}
$timeout = @{$msg_hash->{timeout}}[0];
}
- # check logged in user
- my @user_list = &get_logged_in_users;
- if( @user_list >= 1 ) {
- system( "/usr/bin/goto-notify reboot" );
- open(FILE, "> /etc/gosa-si/event");
- print FILE "reboot\n";
- close(FILE);
- }
+ # Check if user should be notificated or not
+ if ($userNotification eq "enabled") {
+ # Check logged in user
+ my @user_list = &get_logged_in_users;
+ if( @user_list >= 1 ) {
+ system( "/usr/bin/goto-notify reboot" );
+ open(FILE, "> /etc/gosa-si/event");
+ print FILE "reboot\n";
+ close(FILE);
+ }
+ }
else {
system( "/sbin/shutdown -r +$timeout &" );
}
my ($msg, $msg_hash) = @_;
my $timeout;
+ # Invalid timeout parameter are set to 0
if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) {
$timeout = 0;
}
$timeout = @{$msg_hash->{timeout}}[0];
}
- # check logged in user
- my @user_list = &get_logged_in_users;
- if( @user_list >= 1 ) {
- system( "/usr/bin/goto-notify halt" );
- open(FILE, "> /etc/gosa-si/event");
- print FILE "halt\n";
- close(FILE);
- }
- else {
+ # Check if user should be notificated or not
+ if ($userNotification eq "enabled") {
+ # Check logged in user
+ my @user_list = &get_logged_in_users;
+ if( @user_list >= 1 ) {
+ system( "/usr/bin/goto-notify halt" );
+ open(FILE, "> /etc/gosa-si/event");
+ print FILE "halt\n";
+ close(FILE);
+ }
+ } else {
system( "/sbin/shutdown -h +$timeout &" );
}
sub trigger_action_reinstall {
my ($msg, $msg_hash) = @_;
- # check logged in user
- my @user_list = &get_logged_in_users;
- if( @user_list >= 1 ) {
- system( "/usr/bin/goto-notify install" );
- open(FILE, "> /etc/gosa-si/event");
- print FILE "install\n";
- close(FILE);
- }
- else {
- system( "/sbin/shutdown -r now &" );
- }
+ # Check if user should be notificated or not
+ if ($userNotification eq "enabled") {
+ # Check logged in user
+ my @user_list = &get_logged_in_users;
+ if( @user_list >= 1 ) {
+ system( "/usr/bin/goto-notify install" );
+ open(FILE, "> /etc/gosa-si/event");
+ print FILE "install\n";
+ close(FILE);
+ }
+ } else {
+ system( "/sbin/shutdown -r now &" );
+ }
return;
}