Commit b65c173f authored by Pekka Lundstrom's avatar Pekka Lundstrom

[systemd] Notify systemd when booted up. JB#11788

Signed-off-by: default avatarPekka Lundstrom <pekka.lundstrom@jollamobile.com>
parent 3968b792
......@@ -102,6 +102,14 @@ AC_ARG_ENABLE([connman], AS_HELP_STRING([--enable-connman], [Enable connman supp
esac],[connman=false])
AM_CONDITIONAL([CONNMAN], [test x$connman = xtrue])
AC_ARG_ENABLE([systemd], AS_HELP_STRING([--enable-systemd], [Enable systemd notify interface @<:@default=false@:>@]),
[case "${enableval}" in
yes) systemd=true ; CFLAGS="-DSYSTEMD -lsystemd-daemon $CFLAGS" ;;
no) systemd=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-systemd]) ;;
esac],[systemd=false])
AM_CONDITIONAL([SYSTEMD], [test x$systemd = xtrue])
#TODO: Figure out how to check for this depending on the gconf flag
# gconf-2.0 >= 2.16.0
PKG_CHECK_MODULES([USB_MODED], [
......
......@@ -7,11 +7,11 @@ After=local-fs.target dbus.socket systemd-udev-settle.service
Conflicts=shutdown.target
[Service]
Type=simple
RemainAfterExit=no
Type=notify
TimeoutSec=15
EnvironmentFile=-/var/lib/environment/usb-moded/*.conf
EnvironmentFile=-/run/usb-moded/*.conf
ExecStart=/usr/sbin/usb_moded $USB_MODED_ARGS
ExecStart=/usr/sbin/usb_moded --systemd $USB_MODED_ARGS
Restart=always
[Install]
......
......@@ -15,6 +15,7 @@ BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(udev)
BuildRequires: pkgconfig(libkmod)
BuildRequires: doxygen
BuildRequires: pkgconfig(libsystemd-daemon)
Requires: lsof
Requires: usb-moded-configs
......@@ -240,7 +241,7 @@ with the android gadget driver.
%build
%autogen
%configure --enable-app-sync --enable-udev --enable-n900 --enable-meegodevlock --enable-debug --enable-connman
%configure --enable-app-sync --enable-udev --enable-n900 --enable-meegodevlock --enable-debug --enable-connman --enable-systemd
make all doc %{?_smp_mflags}
%install
......
......@@ -34,6 +34,9 @@
#endif
#include <libkmod.h>
#ifdef SYSTEMD
#include <systemd/sd-daemon.h>
#endif
#include "usb_moded.h"
#include "usb_moded-modes.h"
......@@ -68,6 +71,7 @@ gboolean rescue_mode = FALSE;
gboolean diag_mode = FALSE;
gboolean hw_fallback = FALSE;
gboolean charging_mode_set = FALSE;
gboolean systemd_notify = FALSE;
struct usb_mode current_mode;
guint charging_timeout = 0;
......@@ -617,6 +621,7 @@ static void usage(void)
" -d, --diag turn on diag mode\n"
" -h, --help display this help and exit\n"
" -r, --rescue rescue mode\n"
" -n, --systemd notify systemd when started up\n"
" -v, --version output version information and exit\n"
"\n");
}
......@@ -634,6 +639,7 @@ int main(int argc, char* argv[])
{ "diag", no_argument, 0, 'd' },
{ "help", no_argument, 0, 'h' },
{ "rescue", no_argument, 0, 'r' },
{ "systemd", no_argument, 0, 'n' },
{ "version", no_argument, 0, 'v' },
{ 0, 0, 0, 0 }
};
......@@ -641,7 +647,7 @@ int main(int argc, char* argv[])
log_name = basename(*argv);
/* Parse the command-line options */
while ((opt = getopt_long(argc, argv, "fsTDdhrv", options, &opt_idx)) != -1)
while ((opt = getopt_long(argc, argv, "fsTDdhrnv", options, &opt_idx)) != -1)
{
switch (opt)
{
......@@ -672,6 +678,10 @@ int main(int argc, char* argv[])
rescue_mode = TRUE;
break;
case 'n':
systemd_notify = TRUE;
break;
case 'v':
printf("USB mode daemon version: %s\n", VERSION);
exit(0);
......@@ -724,6 +734,15 @@ int main(int argc, char* argv[])
signal(SIGINT, sigint_handler);
signal(SIGHUP, sigint_handler);
#ifdef SYSTEMD
/* Tell systemd that we have started up */
if( systemd_notify )
{
log_debug("notifying systemd\n");
sd_notify(0, "READY=1");
}
#endif /* SYSTEMD */
/* init succesful, run main loop */
result = EXIT_SUCCESS;
g_main_loop_run(mainloop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment