Debian Codegraph @

needrestart-dbus-system

raw
1 #!/usr/bin/perl -T
2
3 # needrestart-session - check for processes need to be restarted in user sessions
4 #
5 # Authors:
6 # Thomas Liske <[email protected]>
7 #
8 # Copyright Holder:
9 # 2014 - 2015 (C) Thomas Liske [http://fiasko-nw.net/~thomas/]
10 #
11 # License:
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this package; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #
26
27 use Net::DBus;
28 use Net::DBus::Service;
29 use Net::DBus::Reactor;
30 use Sys::Syslog qw(:standard :macros);
31
32 use warnings;
33 use strict;
34
35 $0 = q(needrestart-dbus-system);
36
37 BEGIN {
38 openlog(q(needrestart-dbus-system), 'pid', LOG_DAEMON);
39 }
40
41 END {
42 syslog(LOG_INFO, q(terminated));
43 }
44
45 sub WARN_handler {
46 my $signal = shift;
47 syslog(LOG_WARNING, q(%s), $signal);
48 }
49
50 sub DIE_handler {
51 my $signal = shift;
52 syslog(LOG_ERR, q(%s), $signal);
53 exit;
54 }
55
56 $SIG{__WARN__} = q(WARN_handler);
57 $SIG{__DIE__} = q(DIE_handler);
58 $SIG{TERM} = q(DIE_handler);
59
60 syslog(LOG_INFO, q(needrestart-dbus-system %s launched), $NeedRestart::VERSION);
61
62 package NeedRestart::DBus;
63
64 use NeedRestart;
65 use Net::DBus::Exporter qw(net.ibh.NeedRestart.System);
66 use Sys::Syslog qw(:standard :macros);
67 use base qw(Net::DBus::Object);
68
69 sub new {
70 my $class = shift;
71 my $service = shift;
72
73 my $self = $class->SUPER::new($service, q(/net/ibh/NeedRestart/System));
74 bless $self, $class;
75
76 syslog(LOG_INFO, q(new instance));
77
78 return $self;
79 }
80
81 dbus_signal(q(NotifySessions));
82 dbus_method(q(emitNotifySessions));
83 sub emitNotifySessions {
84 my $self = shift;
85
86 syslog(LOG_INFO, q(emit NotifySessions signal));
87
88 return $self->emit_signal(q(NotifySessions));
89 }
90
91
92 package main;
93
94 my $bus = Net::DBus->system;
95 my $service = $bus->export_service('net.ibh.NeedRestart.System');
96 my $object = NeedRestart::DBus->new($service);
97
98 syslog(LOG_INFO, q(entering event loop...));
99 Net::DBus::Reactor->main->run();
100 syslog(LOG_INFO, q(leaving event loop));