Commit a98aac62 authored by Philippe De Swert's avatar Philippe De Swert

[upstart] Remove upstart appsync support

Upstart is being obsoleted, so no use to keep this support in.
Systemd is our new evil overlord.

Author: Thomas Perl <m@thp.io>
Signed-off-by: default avatarPhilippe De Swert <philippe.deswert@jollamobile.com>
parent 0d876042
......@@ -56,14 +56,6 @@ AC_ARG_ENABLE([app_sync_dbus], AS_HELP_STRING([--enable-app-sync-dbus], [Enable
esac],[app_sync_dbus=false])
AM_CONDITIONAL([APP_SYNC_DBUS], [test x$app_sync_dbus = xtrue])
AC_ARG_ENABLE([upstart], AS_HELP_STRING([--enable-upstart], [Enable upstart interface for appsync @<:@default=false@:>@]),
[case "${enableval}" in
yes) upstart=true ; CFLAGS="-DUPSTART $CFLAGS" ;;
no) upstart=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-upstart]) ;;
esac],[upstart=false])
AM_CONDITIONAL([UPSTART], [test x$upstart = xtrue])
AC_ARG_ENABLE([connman], AS_HELP_STRING([--enable-connman], [Enable connman support for usb tethering @<:@default=false@:>@]),
[case "${enableval}" in
yes) connman=true ; CFLAGS="-DCONNMAN $CFLAGS" ;;
......
......@@ -209,7 +209,7 @@ Only condition is that it can be activated by dbus and that (preferably) it will
notify usb_moded that it is ready by ready_method call on the session bus.
This ready method call is just calling the regular usb_moded interface, but now
on the session bus, with as argument the program name as defined in the config file.
Systemd and upstart are also supported.
Systemd is also supported.
To achieve this you need to have a config file in /etc/usb-moded/run.
Best practice would be giving it a descriptive name followed by .ini
......@@ -231,14 +231,6 @@ systemd = 1
The name here is the service name used when launching it for example with systemctl
For upstart:
[info]
name = foo
mode = foo_mode
upstart = 1
Here the name is service name used by upstart.
Those files will be read on start and usb_moded will keep a list of apps to launch
for a certain mode. This also means that if you change the files or add/remove some
you need to restart usb_moded. Later when the mode is activated, usb_moded will start
......
......@@ -61,12 +61,6 @@ usb_moded_SOURCES += \
usb_moded-appsync-dbus-private.h
endif
if UPSTART
usb_moded_SOURCES += \
usb_moded-upstart.h \
usb_moded-upstart.c
endif
usb_moded_util_CPPFLAGS = \
$(USB_MODED_CFLAGS)
......
......@@ -38,7 +38,6 @@
#include "usb_moded-appsync-dbus-private.h"
#include "usb_moded-modesetting.h"
#include "usb_moded-log.h"
#include "usb_moded-upstart.h"
#include "usb_moded-systemd.h"
static struct list_elem *read_file(const gchar *filename, int diag);
......@@ -152,8 +151,6 @@ static struct list_elem *read_file(const gchar *filename, int diag)
log_debug("Launch = %s\n", list_item->launch);
list_item->mode = g_key_file_get_string(settingsfile, APP_INFO_ENTRY, APP_INFO_MODE_KEY, NULL);
log_debug("Launch mode = %s\n", list_item->mode);
list_item->upstart = g_key_file_get_integer(settingsfile, APP_INFO_ENTRY, APP_INFO_UPSTART_KEY, NULL);
log_debug("Upstart control = %d\n", list_item->upstart);
list_item->systemd = g_key_file_get_integer(settingsfile, APP_INFO_ENTRY, APP_INFO_SYSTEMD_KEY, NULL);
log_debug("Systemd control = %d\n", list_item->systemd);
list_item->post = g_key_file_get_integer(settingsfile, APP_INFO_ENTRY, APP_INFO_POST, NULL);
......@@ -250,15 +247,6 @@ int activate_sync(const char *mode)
else
goto error;
}
#ifdef UPSTART
else if(data->upstart)
{
if(!upstart_control_job(data->name, UPSTART_START))
mark_active(data->name);
else
goto error;
}
#endif /* UPSTART */
else if(data->launch)
{
/* skipping if dbus session bus is not available,
......@@ -319,13 +307,6 @@ int activate_sync_post(const char *mode)
if(systemd_control_service(data->name, SYSTEMD_START))
goto error;
}
#ifdef UPSTART
else if(data->upstart)
{
if(upstart_control_job(data->name, UPSTART_START))
goto error;
}
#endif /* UPSTART */
else if(data->launch)
{
/* skipping if dbus session bus is not available,
......@@ -432,14 +413,6 @@ int appsync_stop(void)
if(!systemd_control_service(data->name, SYSTEMD_STOP))
log_debug("Failed to stop %s\n", data->name);
}
#ifdef UPSTART
else if(data->upstart)
{
log_debug("Stopping %s\n", data->launch);
if(upstart_control_job(data->name, UPSTART_STOP))
log_debug("Failed to stop %s\n", data->name);
}
#endif /* UPSTART */
}
return(0);
......
......@@ -26,7 +26,6 @@
#define APP_INFO_MODE_KEY "mode"
#define APP_INFO_NAME_KEY "name"
#define APP_INFO_LAUNCH_KEY "launch"
#define APP_INFO_UPSTART_KEY "upstart"
#define APP_INFO_SYSTEMD_KEY "systemd"
#define APP_INFO_POST "post"
......@@ -40,7 +39,6 @@ typedef struct list_elem
char *mode; /* mode in which to launch the app */
char *launch; /* dbus launch command/address */
int active; /* marker to check if the app has started sucessfully */
int upstart; /* marker to know if we start it with upstart or not */
int systemd; /* marker to know if we start it with systemd or not */
int post; /* marker to indicate when to start the app */
/*@}*/
......
......@@ -40,7 +40,6 @@
#include "usb_moded-config.h"
#include "usb_moded-modesetting.h"
#include "usb_moded-network.h"
#include "usb_moded-upstart.h"
#include "usb_moded-android.h"
static void report_mass_storage_blocker(const char *mountpoint, int try);
......
/**
@file usb_moded-upstart.c
Copyright (C) 2012 Nokia Corporation. All rights reserved.
@author: Philippe De Swert <philippe.de-swert@nokia.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include "usb_moded-dbus.h"
#include "usb_moded-dbus-private.h"
#include "usb_moded.h"
#include "usb_moded-log.h"
#define SYSTEM_BUS_ADDRESS "unix:path=/var/run/dbus/system_bus_socket"
#define UPSTART_BUS_ADDRESS "unix:abstract=/com/ubuntu/upstart"
#define UPSTART_SERVICE "com.ubuntu.Upstart"
#define UPSTART_REQUEST_PATH "/com/ubuntu/Upstart"
#define UPSTART_INTERFACE "com.ubuntu.Upstart0_6"
#define UPSTART_JOB_INTERFACE "com.ubuntu.Upstart0_6.Job"
static DBusConnection * get_upstart_dbus_connection(void)
{
DBusError error;
DBusConnection *conn = 0;
dbus_error_init(&error);
conn = dbus_connection_open_private("unix:abstract=/com/ubuntu/upstart", &error);
if (!conn)
{
if (dbus_error_is_set(&error))
log_err("Cannot connect to upstart: %s", error.message);
else
log_err("Cannot connect to upstart");
return 0;
}
return conn;
}
static char *get_upstart_job_by_name(const char *name)
{
DBusError error;
DBusConnection *conn = 0;
DBusMessage *msg = NULL, *reply = NULL;
char *ret = 0;
dbus_error_init(&error);
conn = get_upstart_dbus_connection();
if(!conn)
return NULL;
if ((msg = dbus_message_new_method_call(UPSTART_SERVICE, UPSTART_REQUEST_PATH, UPSTART_INTERFACE, "GetJobByName")) != NULL)
{
dbus_message_append_args (msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID);
if ((reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, NULL)) != NULL)
{
dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &ret, DBUS_TYPE_INVALID);
/* log_debug("got following path from upstart: %s for job name %s\n", ret, name);*/
dbus_message_unref(reply);
}
dbus_message_unref(msg);
}
dbus_connection_close(conn);
return ret;
}
int upstart_control_job(const char *name, const char * action)
{
DBusError error;
DBusConnection *conn = 0;
char *job = 0, *arg = 0;
DBusMessageIter iter, iter2;
DBusMessage *msg = NULL, *reply = NULL;
dbus_bool_t wait = FALSE;
conn = get_upstart_dbus_connection();
if(!conn)
return 1;
job = get_upstart_job_by_name(name);
if(job)
if ((msg = dbus_message_new_method_call(UPSTART_SERVICE, job, UPSTART_JOB_INTERFACE, action)) != NULL)
{
dbus_message_iter_init_append(msg, &iter);
if(!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &iter2))
{
log_err("Could not open dbus container\n");
goto fail;
}
asprintf(&arg, "NAME=%s", name);
if (!dbus_message_iter_append_basic(&iter2, DBUS_TYPE_STRING, &arg))
{
log_err("Could not add string array\n");
dbus_message_iter_abandon_container(&iter, &iter2);
goto fail;
}
if (!dbus_message_iter_close_container(&iter, &iter2))
{
log_err( "Cannot close container");
goto fail;
}
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &wait))
{
log_err("Could not set wait state\n");
goto fail;
}
if ((reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, NULL)) != NULL)
{
dbus_message_unref(reply);
}
dbus_message_unref(msg);
}
else
log_err("No upstart path for %s\n", name);
dbus_connection_close(conn);
return 0;
fail:
dbus_connection_close(conn);
return 1;
}
/**
@file usb_moded-upstart.h
Copyright (C) 2012 Nokia Corporation. All rights reserved.
@author: Philippe De Swert <philippe.de-swert@nokia.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include <stdio.h>
#include <string.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#define UPSTART_START "Start"
#define UPSTART_STOP "Stop"
int upstart_control_job(const char *name, const char * action);
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