Code

Moved new_ldap_conf
[gosa.git] / gosa-si / client / events / gosaTriggered.pm
1 package gosaTriggered;
2 use Exporter;
3 @ISA = qw(Exporter);
4 my @events = (
5     "get_events",
6     "trigger_action_localboot",
7     "trigger_action_halt",
8     "trigger_action_reboot",
9     "trigger_action_memcheck",
10     "trigger_action_reinstall",
11     "trigger_action_update",
12     "trigger_action_instant_update",
13     "trigger_action_sysinfo",
14     "trigger_action_rescan",
15     );
16 @EXPORT = @events;
18 use strict;
19 use warnings;
22 BEGIN {}
24 END {}
27 sub get_events { return \@events; }
30 sub trigger_action_localboot {
31     my ($msg, $msg_hash) = @_;
32     my $timeout;
34     if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) {
35         $timeout = -1;
36     } 
37     else {
38         $timeout = @{$msg_hash->{timeout}}[0];
39     }
41     # check logged in user
42     my $logged_in_user = 1;
43     if( $logged_in_user ) {
44         # TODO do something
45     }
46     else {
47         $timeout = 0;
48     }
49         
50     # execute function
51     if( $timeout == 0 ) {
52         print STDERR ("shutdown -r +$timeout\n");
53     }
54     elsif( $timeout > 0 ) {
55         print STDERR ("shutdown -r +$timeout\n");
56     }
57     elsif( $timeout < 0 ) {
58         print STDERR "The administrator has sent a signal to reboot this workstation. It will reboot after you've logged out.\n";
59         open(FILE, "> /etc/gosa-si/event");
60         print FILE "trigger_action_localboot\n";
61         close(FILE);
62     }
63     else {
64         # TODO do something, error handling, logging
65     }
67     return;
68 }
71 sub trigger_action_reboot {
72     my ($msg, $msg_hash) = @_;
73     print STDERR "jetzt würde ich trigger_action_reboot ausführen\n";
74     return;
75 }
78 sub trigger_action_halt {
79     my ($msg, $msg_hash) = @_;
80     my $timeout;
82     if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) {
83         $timeout = -1;
84     } 
85     else {
86         $timeout = @{$msg_hash->{timeout}}[0];
87     }
89     # check logged in user
90     my $logged_in_user = 1;
91     if( $logged_in_user ) {
92         # TODO do something
93     }
94     else {
95         $timeout = 0;
96     }
98     # execute function
99     if( $timeout == 0 ) {
100         print STDERR ("shutdown -h +$timeout\n");
101     }
102     elsif( $timeout > 0 ) {
103         print STDERR ("shutdown -h +$timeout\n");
104     }
105     elsif( $timeout < 0 ) {
106         print STDERR "The administrator has sent a signal to shutdown this workstation. It will shutdown after you've logged out.\n";
107         open(FILE, "> /etc/gosa-si/event");
108         print FILE "trigger_action_halt\n";
109         close(FILE);
110     }
111     else {
112         # TODO do something, error handling, logging
113     }
115     return;
119 # TODO
120 sub trigger_action_memcheck {
121     my ($msg, $msg_hash) = @_ ;
122     print STDERR "\n\njetzt würde ich trigger_action_memcheck ausführen\n\n";
123     return;
127 sub trigger_action_reinstall {
128     my ($msg, $msg_hash) = @_;
129     my $timeout;
131     # check timeout
132     if((not exists $msg_hash->{timeout} ) || (1 != @{$msg_hash->{timeout}} ) ) {
133         $timeout = -1;
134     }
135     else {
136         $timeout = @{$msg_hash->{timeout}}[0];
137     }
139     # check logged in user
140     my $logged_in_user = 1;
141     if( $logged_in_user ) {
142         # TODO do something
143     }
144     else {
145         $timeout = 0;
146     }
148     # execute function
149     if( $timeout == 0 ) {
150         print STDERR ("shutdown -r +$timeout\n");
151     }
152     elsif( $timeout > 0 ) {
153         print STDERR ("shutdown -r +$timeout\n");
155     }
156     elsif( $timeout < 0 ) {
157         print STDERR "The administrator has sent a signal to reinstall this workstation. It will reinstall after you've logged out.\n";
158         open(FILE, "> /etc/gosa-si/event");
159         print FILE "trigger_action_reinstall\n";
160         close(FILE);
161     }
162     else {
163         # TODO do something, error handling, logging
164     }
166     return;
170 sub trigger_action_update {
171     my ($msg, $msg_hash) = @_;
173     # execute function
174     open(FILE, "> /etc/gosa-si/event");
175     print FILE "trigger_action_reinstall\n";
176     close(FILE);
178     # check logged in user
179     my $logged_in_user = 1;
180     if( $logged_in_user ) {
181         print STDERR "This system has been sent a signal for an update. The update will take place after you log out.\n";
182     }
183     else {
184         # not jet
185         #system( "DEBIAN_FRONTEND=noninteractive /usr/sbin/fai -N softupdate &" )
186     }
188     return;
192 sub trigger_action_instant_update {
193     my ($msg, $msg_hash) = @_;
195     # check logged in user
196     my $logged_in_user = 1;
197     if( $logged_in_user ) {
198         print STDERR "This system has been sent a signal for an update. The update will take place now.\n";
199     }
201     # not jet
202     #system( "DEBIAN_FRONTEND=noninteractive /usr/sbin/fai -N softupdate &" )
204     return;
208 # TODO
209 sub trigger_action_sysinfo {
210     my ($msg, $msg_hash) = @_;
211     print STDERR "jetzt würde ich trigger_action_sysinfo ausführen\n";
212     return;
215 # TODO
216 sub trigger_action_rescan{
217     my ($msg, $msg_hash) = @_;
218     print STDERR "jetzt würde ich trigger_action_rescan ausführen\n";
219     return;
222 1;