X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fclient%2Fevents%2FgosaTriggered.pm;h=789996d3b0577ad6e936608d4dbdf2419f403e77;hb=2e1a7f272ac8f39bc8ebe2e6c33fe7bdd63ab03d;hp=a13b872ce85e50a62a48c6fe58f0bb8fc61b5b1a;hpb=8a776b426c2069293a5bf4d700811b68744b2108;p=gosa.git diff --git a/gosa-si/client/events/gosaTriggered.pm b/gosa-si/client/events/gosaTriggered.pm index a13b872ce..789996d3b 100644 --- a/gosa-si/client/events/gosaTriggered.pm +++ b/gosa-si/client/events/gosaTriggered.pm @@ -3,22 +3,24 @@ use Exporter; @ISA = qw(Exporter); my @events = ( "get_events", + "usr_msg", "trigger_action_localboot", "trigger_action_halt", "trigger_action_faireboot", "trigger_action_reboot", - "trigger_action_memcheck", +# "trigger_action_memcheck", # not yet implemented "trigger_action_reinstall", "trigger_action_update", "trigger_action_instant_update", - "trigger_action_sysinfo", - "trigger_action_rescan", +# "trigger_action_sysinfo", # not yet implemented ); @EXPORT = @events; use strict; use warnings; use GOSA::GosaSupportDaemon; +use Data::Dumper; +use MIME::Base64; BEGIN {} @@ -27,6 +29,20 @@ END {} sub get_events { return \@events; } +sub usr_msg { + my ($msg, $msg_hash) = @_; + + + my $to = @{$msg_hash->{'usr'}}[0]; + my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]); + my $message = &decode_base64(@{$msg_hash->{'message'}}[0]); + system( "/usr/bin/goto-notify user-message '$to' '$subject' '$message'" ); + + # give gosa-si-server feedback, that msg was received + $msg =~ s/
usr_msg<\/header>/
confirm_usr_msg<\/header>/g; + return $msg; +} + sub trigger_action_localboot { my ($msg, $msg_hash) = @_; @@ -71,6 +87,7 @@ sub trigger_action_localboot { sub trigger_action_faireboot { my ($msg, $msg_hash) = @_; + &main::daemon_log("DEBUG: run /usr/sbin/faireboot\n", 7); system("/usr/sbin/faireboot"); return; } @@ -81,7 +98,7 @@ sub trigger_action_reboot { my $timeout; if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) { - $timeout = -1; + $timeout = 0; } else { $timeout = @{$msg_hash->{timeout}}[0]; @@ -90,36 +107,16 @@ sub trigger_action_reboot { # check logged in user my @user_list = &get_logged_in_users; if( @user_list >= 1 ) { - # 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"; + system( "/usr/bin/goto-notify reboot" ); open(FILE, "> /etc/gosa-si/event"); - print FILE "trigger_action_reboot\n"; + print FILE "reboot\n"; close(FILE); } else { - # TODO do something, error handling, logging + system( "/sbin/shutdown -r +$timeout &" ); } return; - - - - - print STDERR "jetzt würde ich trigger_action_reboot ausführen\n"; - return; } @@ -128,146 +125,66 @@ sub trigger_action_halt { my $timeout; if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) { - $timeout = -1; + $timeout = 0; } 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 -h +$timeout\n"); - } - elsif( $timeout > 0 ) { - print STDERR ("shutdown -h +$timeout\n"); - } - elsif( $timeout < 0 ) { - print STDERR "The administrator has sent a signal to shutdown this workstation. It will shutdown after you've logged out.\n"; + 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 "trigger_action_halt\n"; + print FILE "halt\n"; close(FILE); } else { - # TODO do something, error handling, logging + system( "/sbin/shutdown -h +$timeout &" ); } return; } -# TODO -sub trigger_action_memcheck { - my ($msg, $msg_hash) = @_ ; - print STDERR "\n\njetzt würde ich trigger_action_memcheck ausführen\n\n"; - return; -} - - sub trigger_action_reinstall { my ($msg, $msg_hash) = @_; - my $timeout; - - # check timeout - if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) { - $timeout = -1; - } - 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 reinstall this workstation. It will reinstall after you've logged out.\n"; + 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 "trigger_action_reinstall\n"; + print FILE "install\n"; close(FILE); } else { - # TODO do something, error handling, logging + system( "/sbin/shutdown -r now &" ); } return; } +# Backward compatibility sub trigger_action_update { my ($msg, $msg_hash) = @_; - # execute function - open(FILE, "> /etc/gosa-si/event"); - print FILE "trigger_action_reinstall\n"; - close(FILE); - - # check logged in user - my $logged_in_user = 1; - if( $logged_in_user ) { - print STDERR "This system has been sent a signal for an update. The update will take place after you log out.\n"; - } - else { - # not jet - #system( "DEBIAN_FRONTEND=noninteractive /usr/sbin/fai -N softupdate &" ) - } + # Execute update + system( "DEBIAN_FRONTEND=noninteractive /usr/sbin/fai-softupdate &" ); return; } - +# Backward compatibility sub trigger_action_instant_update { my ($msg, $msg_hash) = @_; - # check logged in user - my $logged_in_user = 1; - if( $logged_in_user ) { - print STDERR "This system has been sent a signal for an update. The update will take place now.\n"; - if(stat('/usr/bin/fai-softupdate-notify')) { - system('/usr/bin/fai-softupdate-notify start'); - } - } - - # not jet - #system( "DEBIAN_FRONTEND=noninteractive /usr/sbin/fai -N softupdate &" ) - - return; -} - + # Execute update + system( "DEBIAN_FRONTEND=noninteractive /usr/sbin/fai-softupdate &" ); -# TODO -sub trigger_action_sysinfo { - my ($msg, $msg_hash) = @_; - print STDERR "jetzt würde ich trigger_action_sysinfo ausführen\n"; return; } -# TODO -sub trigger_action_rescan{ - my ($msg, $msg_hash) = @_; - print STDERR "jetzt würde ich trigger_action_rescan ausführen\n"; - return; -} 1;