~vorlon/ubuntu/raring/upstart/lp.1199778

« back to all changes in this revision

Viewing changes to util/initctl.c

  • Committer: Stéphane Graber
  • Date: 2013-03-07 18:43:01 UTC
  • mfrom: (1182.56.54 upstart)
  • Revision ID: stgraber@ubuntu.com-20130307184301-dlmb1c5bwonqagkw
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* upstart
2
2
 *
3
 
 * Copyright © 2010 Canonical Ltd.
 
3
 * Copyright  2010 Canonical Ltd.
4
4
 * Author: Scott James Remnant <scott@netsplit.com>.
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify
30
30
#include <stdlib.h>
31
31
#include <unistd.h>
32
32
#include <fnmatch.h>
 
33
#include <pwd.h>
 
34
#include <dirent.h>
 
35
#include <ctype.h>
33
36
 
34
37
#include <nih/macros.h>
35
38
#include <nih/alloc.h>
41
44
#include <nih/error.h>
42
45
#include <nih/hash.h>
43
46
#include <nih/tree.h>
 
47
#include <nih/file.h>
44
48
 
45
49
#include <nih-dbus/dbus_error.h>
46
50
#include <nih-dbus/dbus_proxy.h>
53
57
#include "com.ubuntu.Upstart.Job.h"
54
58
#include "com.ubuntu.Upstart.Instance.h"
55
59
 
56
 
#include "../init/events.h"
 
60
#include "init/events.h"
 
61
#include "init/xdg.h"
57
62
#include "initctl.h"
58
63
 
59
64
 
60
65
/* Prototypes for local functions */
61
66
NihDBusProxy *upstart_open (const void *parent)
62
 
        __attribute__ ((warn_unused_result, malloc));
 
67
        __attribute__ ((warn_unused_result));
63
68
char *        job_status   (const void *parent,
64
69
                            NihDBusProxy *job_class, NihDBusProxy *job)
65
 
        __attribute__ ((warn_unused_result, malloc));
 
70
        __attribute__ ((warn_unused_result));
66
71
char *        job_usage    (const void *parent,
67
72
                            NihDBusProxy *job_class)
68
 
        __attribute__ ((warn_unused_result, malloc));
 
73
        __attribute__ ((warn_unused_result));
69
74
 
70
75
/* Prototypes for static functions */
71
76
static void   start_reply_handler (char **job_path, NihDBusMessage *message,
103
108
 
104
109
static int    allow_job (const char *job);
105
110
static int    allow_event (const char *event);
 
111
static char **get_job_details (void)
 
112
        __attribute__ ((warn_unused_result));
106
113
 
107
114
#ifndef TEST
108
115
 
126
133
int check_config_action           (NihCommand *command, char * const *args);
127
134
int usage_action                  (NihCommand *command, char * const *args);
128
135
int notify_disk_writeable_action  (NihCommand *command, char * const *args);
 
136
int get_env_action                (NihCommand *command, char * const *args);
 
137
int set_env_action                (NihCommand *command, char * const *args);
 
138
int list_env_action               (NihCommand *command, char * const *args);
 
139
int unset_env_action              (NihCommand *command, char * const *args);
 
140
int reset_env_action              (NihCommand *command, char * const *args);
 
141
int list_sessions_action          (NihCommand *command, char * const *args);
129
142
 
130
143
/**
131
144
 * use_dbus:
145
158
int dbus_bus_type = -1;
146
159
 
147
160
/**
 
161
 * user_mode:
 
162
 *
 
163
 * If TRUE, talk to Upstart over the private socket defined in UPSTART_SESSION
 
164
 * if UPSTART_SESSION isn't defined, then fallback to the session bus.
 
165
 **/
 
166
int user_mode = FALSE;
 
167
 
 
168
/**
148
169
 * dest_name:
149
170
 *
150
171
 * Name on the D-Bus system bus that the message should be sent to when
177
198
int enumerate_events = FALSE;
178
199
 
179
200
/**
 
201
 * retain_var:
 
202
 *
 
203
 * If FALSE, the set-env command will replace any existing variable of
 
204
 * the same name in the job environment table. If TRUE, the original
 
205
 * value will be retained.
 
206
 **/
 
207
int retain_var = FALSE;
 
208
 
 
209
/**
180
210
 * check_config_mode:
181
211
 *
182
212
 * If TRUE, parse all job configuration files looking for unreachable
200
230
CheckConfigData check_config_data;
201
231
 
202
232
/**
 
233
 * apply_globally:
 
234
 *
 
235
 * If TRUE, make changes to global job environment table rather than the
 
236
 * running jobs instances environment table.
 
237
 **/
 
238
int apply_globally = FALSE;
 
239
 
 
240
/**
203
241
 * NihOption setter function to handle selection of appropriate D-Bus
204
242
 * bus.
205
243
 *
291
329
        DBusError       dbus_error;
292
330
        DBusConnection *connection;
293
331
        NihDBusProxy *  upstart;
294
 
 
295
 
        if (use_dbus < 0)
296
 
                use_dbus = getuid () ? TRUE : FALSE;
297
 
        if (use_dbus >= 0 && dbus_bus_type < 0)
298
 
                dbus_bus_type = DBUS_BUS_SYSTEM;
 
332
        char * user_addr;
 
333
 
 
334
        user_addr = getenv ("UPSTART_SESSION");
 
335
 
 
336
        if (user_addr && dbus_bus_type < 0) {
 
337
                user_mode = TRUE;
 
338
        }
 
339
 
 
340
        if (! user_mode) {
 
341
                if (use_dbus < 0)
 
342
                        use_dbus = getuid () ? TRUE : FALSE;
 
343
                if (use_dbus >= 0 && dbus_bus_type < 0)
 
344
                        dbus_bus_type = DBUS_BUS_SYSTEM;
 
345
        }
 
346
        else {
 
347
                if (! user_addr) {
 
348
                        nih_error ("UPSTART_SESSION isn't set in the environment. "
 
349
                                       "Unable to locate the Upstart instance.");
 
350
                        return NULL;
 
351
                }
 
352
                dest_address = user_addr;
 
353
                use_dbus = FALSE;
 
354
        }
 
355
 
299
356
 
300
357
        dbus_error_init (&dbus_error);
301
358
        if (use_dbus) {
315
372
 
316
373
                dbus_connection_set_exit_on_disconnect (connection, FALSE);
317
374
        } else {
318
 
                if (dest_name) {
 
375
                if (dest_name && ! user_mode) {
319
376
                        fprintf (stderr, _("%s: --dest given without --system\n"),
320
377
                                 program_name);
321
378
                        nih_main_suggest_help ();
1317
1374
}
1318
1375
 
1319
1376
/**
 
1377
 * get_env_action:
 
1378
 * @command: NihCommand invoked,
 
1379
 * @args: command-line arguments.
 
1380
 *
 
1381
 * This function is called for the "get-env" command.
 
1382
 *
 
1383
 * Returns: command exit status.
 
1384
 **/
 
1385
int
 
1386
get_env_action (NihCommand *command, char * const *args)
 
1387
{
 
1388
        nih_local NihDBusProxy  *upstart = NULL;
 
1389
        nih_local char          *envvar = NULL;
 
1390
        nih_local char         **job_details = NULL;
 
1391
        NihError                *err;
 
1392
        char                    *name;
 
1393
 
 
1394
        nih_assert (command != NULL);
 
1395
        nih_assert (args != NULL);
 
1396
 
 
1397
        name = args[0];
 
1398
 
 
1399
        if (! name) {
 
1400
                fprintf (stderr, _("%s: missing variable name\n"), program_name);
 
1401
                nih_main_suggest_help ();
 
1402
                return 1;
 
1403
        }
 
1404
 
 
1405
        job_details = get_job_details ();
 
1406
        if (! job_details)
 
1407
                return 1;
 
1408
 
 
1409
        upstart = upstart_open (NULL);
 
1410
        if (! upstart)
 
1411
                return 1;
 
1412
 
 
1413
        if (upstart_get_env_sync (NULL, upstart, job_details, name, &envvar) < 0)
 
1414
                goto error;
 
1415
 
 
1416
        nih_message ("%s", envvar);
 
1417
 
 
1418
        return 0;
 
1419
 
 
1420
error:
 
1421
        err = nih_error_get ();
 
1422
        nih_error ("%s", err->message);
 
1423
        nih_free (err);
 
1424
 
 
1425
        return 1;
 
1426
}
 
1427
 
 
1428
/**
 
1429
 * set_env_action:
 
1430
 * @command: NihCommand invoked,
 
1431
 * @args: command-line arguments.
 
1432
 *
 
1433
 * This function is called for the "set-env" command.
 
1434
 *
 
1435
 * Returns: command exit status.
 
1436
 **/
 
1437
int
 
1438
set_env_action (NihCommand *command, char * const *args)
 
1439
{
 
1440
        nih_local NihDBusProxy  *upstart = NULL;
 
1441
        NihError                *err;
 
1442
        char                    *envvar;
 
1443
        nih_local char         **job_details = NULL;
 
1444
        int                      ret;
 
1445
 
 
1446
        nih_assert (command != NULL);
 
1447
        nih_assert (args != NULL);
 
1448
 
 
1449
        if (! args[0]) {
 
1450
                fprintf (stderr, _("%s: missing variable value\n"), program_name);
 
1451
                nih_main_suggest_help ();
 
1452
                return 1;
 
1453
        }
 
1454
 
 
1455
        job_details = get_job_details ();
 
1456
        if (! job_details)
 
1457
                return 1;
 
1458
 
 
1459
        envvar = args[0];
 
1460
 
 
1461
        upstart = upstart_open (NULL);
 
1462
        if (! upstart)
 
1463
                return 1;
 
1464
 
 
1465
        ret = upstart_set_env_sync (NULL, upstart, job_details,
 
1466
                        envvar, ! retain_var);
 
1467
 
 
1468
        if (ret < 0)
 
1469
                goto error;
 
1470
 
 
1471
        return 0;
 
1472
error:
 
1473
        err = nih_error_get ();
 
1474
        nih_error ("%s", err->message);
 
1475
        nih_free (err);
 
1476
 
 
1477
        return 1;
 
1478
}
 
1479
 
 
1480
 
 
1481
/**
 
1482
 * unset_env_action:
 
1483
 * @command: NihCommand invoked,
 
1484
 * @args: command-line arguments.
 
1485
 *
 
1486
 * This function is called for the "unset-env" command.
 
1487
 *
 
1488
 * Returns: command exit status.
 
1489
 **/
 
1490
int
 
1491
unset_env_action (NihCommand *command, char * const *args)
 
1492
{
 
1493
        nih_local NihDBusProxy  *upstart = NULL;
 
1494
        NihError                *err;
 
1495
        char                    *name;
 
1496
        nih_local char         **job_details = NULL;
 
1497
 
 
1498
        nih_assert (command != NULL);
 
1499
        nih_assert (args != NULL);
 
1500
 
 
1501
        name = args[0];
 
1502
 
 
1503
        if (! name) {
 
1504
                fprintf (stderr, _("%s: missing variable name\n"), program_name);
 
1505
                nih_main_suggest_help ();
 
1506
                return 1;
 
1507
        }
 
1508
 
 
1509
        job_details = get_job_details ();
 
1510
        if (! job_details)
 
1511
                return 1;
 
1512
 
 
1513
        upstart = upstart_open (NULL);
 
1514
        if (! upstart)
 
1515
                return 1;
 
1516
 
 
1517
        if (upstart_unset_env_sync (NULL, upstart, job_details, name) < 0)
 
1518
                goto error;
 
1519
 
 
1520
        return 0;
 
1521
error:
 
1522
        err = nih_error_get ();
 
1523
        nih_error ("%s", err->message);
 
1524
        nih_free (err);
 
1525
 
 
1526
        return 1;
 
1527
}
 
1528
 
 
1529
/**
 
1530
 * reset_env_action:
 
1531
 * @command: NihCommand invoked,
 
1532
 * @args: command-line arguments.
 
1533
 *
 
1534
 * This function is called for the "reset-env" command.
 
1535
 *
 
1536
 * Returns: command exit status.
 
1537
 **/
 
1538
int
 
1539
reset_env_action (NihCommand *command, char * const *args)
 
1540
{
 
1541
        nih_local NihDBusProxy  *upstart = NULL;
 
1542
        NihError                *err;
 
1543
        nih_local char         **job_details = NULL;
 
1544
 
 
1545
        nih_assert (command != NULL);
 
1546
        nih_assert (args != NULL);
 
1547
 
 
1548
        job_details = get_job_details ();
 
1549
        if (! job_details)
 
1550
                return 1;
 
1551
 
 
1552
        upstart = upstart_open (NULL);
 
1553
        if (! upstart)
 
1554
                return 1;
 
1555
 
 
1556
        if (upstart_reset_env_sync (NULL, upstart, job_details) < 0)
 
1557
                goto error;
 
1558
 
 
1559
        return 0;
 
1560
error:
 
1561
        err = nih_error_get ();
 
1562
        nih_error ("%s", err->message);
 
1563
        nih_free (err);
 
1564
 
 
1565
        return 1;
 
1566
}
 
1567
 
 
1568
/**
 
1569
 * list_env_qsort_compar:
 
1570
 *
 
1571
 * @a: first string to compare,
 
1572
 * @b: second string to compare.
 
1573
 *
 
1574
 * qsort() function to sort environment variables for list_env_action().
 
1575
 **/
 
1576
static int
 
1577
list_env_qsort_compar (const void *a, const void *b) 
 
1578
{
 
1579
                return strcoll (*(char * const *)a, *(char * const *)b);
 
1580
}
 
1581
 
 
1582
/**
 
1583
 * list_env_action:
 
1584
 * @command: NihCommand invoked,
 
1585
 * @args: command-line arguments.
 
1586
 *
 
1587
 * This function is called for the "list-env" command.
 
1588
 *
 
1589
 * Output is in lexicographically sorted order.
 
1590
 *
 
1591
 * Returns: command exit status.
 
1592
 **/
 
1593
int
 
1594
list_env_action (NihCommand *command, char * const *args)
 
1595
{
 
1596
        nih_local NihDBusProxy  *upstart = NULL;
 
1597
        nih_local char         **env = NULL;
 
1598
        char                   **e;
 
1599
        NihError                *err;
 
1600
        size_t                   len;
 
1601
        nih_local char         **job_details = NULL;
 
1602
 
 
1603
        nih_assert (command != NULL);
 
1604
        nih_assert (args != NULL);
 
1605
 
 
1606
        job_details = get_job_details ();
 
1607
        if (! job_details)
 
1608
                return 1;
 
1609
 
 
1610
        upstart = upstart_open (NULL);
 
1611
        if (! upstart)
 
1612
                return 1;
 
1613
 
 
1614
        if (upstart_list_env_sync (NULL, upstart, job_details, &env) < 0)
 
1615
                goto error;
 
1616
 
 
1617
        /* Determine array size */
 
1618
        for (len = 0; env[len]; len++)
 
1619
                ;
 
1620
 
 
1621
        qsort (env, len, sizeof (env[0]), list_env_qsort_compar);
 
1622
 
 
1623
        for (e = env; e && *e; e++)
 
1624
                nih_message ("%s", *e);
 
1625
 
 
1626
        return 0;
 
1627
 
 
1628
error:
 
1629
        err = nih_error_get ();
 
1630
        nih_error ("%s", err->message);
 
1631
        nih_free (err);
 
1632
 
 
1633
        return 1;
 
1634
}
 
1635
 
 
1636
/**
1320
1637
 * usage_action:
1321
1638
 * @command: NihCommand invoked,
1322
1639
 * @args: command-line arguments.
1679
1996
        return 1;
1680
1997
}
1681
1998
 
 
1999
 
 
2000
/**
 
2001
 * list_sessions_action:
 
2002
 * @command: NihCommand invoked,
 
2003
 * @args: command-line arguments.
 
2004
 *
 
2005
 * This function is called for the "list-sessions" command.
 
2006
 *
 
2007
 * Unlike other commands, this does not attempt to connect to Upstart.
 
2008
 *
 
2009
 * Returns: command exit status.
 
2010
 **/
 
2011
int
 
2012
list_sessions_action (NihCommand *command, char * const *args)
 
2013
{
 
2014
        nih_local const char *session_dir = NULL;
 
2015
        DIR                  *dir;
 
2016
        struct dirent        *ent;
 
2017
 
 
2018
        nih_assert (command);
 
2019
        nih_assert (args);
 
2020
        
 
2021
        session_dir = get_session_dir ();
 
2022
 
 
2023
        if (! session_dir) {
 
2024
                nih_error (_("Unable to query session directory"));
 
2025
                return 1;
 
2026
        }
 
2027
 
 
2028
        dir = opendir (session_dir);
 
2029
        if (! dir)
 
2030
                goto error;
 
2031
 
 
2032
        while ((ent = readdir (dir))) {
 
2033
                nih_local char  *contents = NULL;
 
2034
                size_t           len;
 
2035
                nih_local char  *path = NULL;
 
2036
                pid_t            pid;
 
2037
                nih_local char  *name = NULL;
 
2038
                char            *session;
 
2039
                char            *p;
 
2040
                char            *ext;
 
2041
                char            *file;
 
2042
                int              all_digits = TRUE;
 
2043
 
 
2044
                file = ent->d_name;
 
2045
 
 
2046
                if (! strcmp (file, ".") || ! strcmp (file, ".."))
 
2047
                        continue;
 
2048
 
 
2049
                ext = p = strchr (file, '.');
 
2050
 
 
2051
                /* No extension */
 
2052
                if (! ext)
 
2053
                        continue;
 
2054
 
 
2055
                /* Invalid extension */
 
2056
                if (strcmp (ext, ".session"))
 
2057
                        continue;
 
2058
 
 
2059
                NIH_MUST (nih_strncat (&name, NULL, file, (p - file)));
 
2060
 
 
2061
                for (p = name; p && *p; p++) {
 
2062
                        if (! isdigit (*p)) {
 
2063
                                all_digits = FALSE;
 
2064
                                break;
 
2065
                        }
 
2066
                }
 
2067
 
 
2068
                /* Invalid name */
 
2069
                if (! all_digits)
 
2070
                        continue;
 
2071
 
 
2072
                pid = (pid_t) atol (name);
 
2073
 
 
2074
                NIH_MUST (nih_strcat_sprintf (&path, NULL, "%s/%s", session_dir, file));
 
2075
 
 
2076
                if (kill (pid, 0)) {
 
2077
                        nih_info ("%s: %s", _("Ignoring stale session file"), path);
 
2078
                        continue;
 
2079
                }
 
2080
 
 
2081
                contents = nih_file_read (NULL, path, &len);
 
2082
 
 
2083
                if (! contents)
 
2084
                        continue;
 
2085
 
 
2086
                if (contents[len-1] == '\n')
 
2087
                        contents[len-1] = '\0';
 
2088
 
 
2089
                p = strstr (contents, "UPSTART_SESSION" "=");
 
2090
                if (p != contents)
 
2091
                        continue;
 
2092
 
 
2093
                session = p + strlen ("UPSTART_SESSION") + 1;
 
2094
 
 
2095
                if (! session || ! *session)
 
2096
                        continue;
 
2097
 
 
2098
                nih_message ("%d %s", (int)pid, session);
 
2099
        }
 
2100
 
 
2101
        closedir (dir);
 
2102
 
 
2103
        return 0;
 
2104
 
 
2105
error:
 
2106
        nih_error ("unable to determine sessions");
 
2107
        return 1;
 
2108
 
 
2109
}
 
2110
 
 
2111
 
1682
2112
static void
1683
2113
start_reply_handler (char **         job_path,
1684
2114
                     NihDBusMessage *message,
2342
2772
        return TRUE;
2343
2773
}
2344
2774
 
 
2775
/**
 
2776
 * get_job_details:
 
2777
 *
 
2778
 * Determine the job and job instance name that the caller should act
 
2779
 * upon. Used by the job environment commands. The caller can determine
 
2780
 * how to react based on the values in the returned array:
 
2781
 *
 
2782
 * - If user has requested global operation via the command line, return
 
2783
 *   an allocated array with zero elements.
 
2784
 *
 
2785
 * - If user has specified a job name and possible instance value via the
 
2786
 *   command line, return an array containing first the job name, then the
 
2787
 *   instance value.
 
2788
 *
 
2789
 * - If no command-line options have been specified, try to extract the
 
2790
 *   job and instance names from the environment variables set within a
 
2791
 *   jobs environment.
 
2792
 *
 
2793
 * Returns: Newly-allocated array containing job name and job
 
2794
 * instance, or an empty array if job and instance cannot be resolved,
 
2795
 * or NULL on error.
 
2796
 **/
 
2797
char **
 
2798
get_job_details (void)
 
2799
{
 
2800
        char        **details;
 
2801
        const char   *upstart_job = NULL;
 
2802
        const char   *upstart_instance = NULL;
 
2803
 
 
2804
        details = nih_str_array_new (NULL);
 
2805
 
 
2806
        if (! details)
 
2807
                return NULL;
 
2808
 
 
2809
        if (apply_globally) {
 
2810
                upstart_job = upstart_instance = NULL;
 
2811
        } else if ((upstart_job = getenv ("UPSTART_JOB")) != NULL) {
 
2812
                upstart_instance = getenv ("UPSTART_INSTANCE");
 
2813
 
 
2814
                if (! (upstart_job && upstart_instance)) {
 
2815
                        fprintf (stderr, _("%s: missing job name\n"), program_name);
 
2816
                        nih_main_suggest_help ();
 
2817
                        return NULL;
 
2818
                }
 
2819
        } else {
 
2820
                /* Running outside of job implies global */
 
2821
                apply_globally = TRUE;
 
2822
                upstart_job = upstart_instance = NULL;
 
2823
        }
 
2824
 
 
2825
        if (upstart_job) {
 
2826
                NIH_MUST (nih_str_array_add (&details, NULL, NULL, upstart_job));
 
2827
                NIH_MUST (nih_str_array_add (&details, NULL, NULL, upstart_instance));
 
2828
        }
 
2829
 
 
2830
        return details;
 
2831
}
 
2832
 
2345
2833
 
2346
2834
#ifndef TEST
2347
2835
/**
2356
2844
          NULL, NULL, NULL, dbus_bus_type_setter },
2357
2845
        { 0, "dest", N_("destination well-known name on D-Bus bus"),
2358
2846
          NULL, "NAME", &dest_name, NULL },
 
2847
        { 0, "user", N_("run in user mode (as used for user sessions)"),
 
2848
                NULL, NULL, &user_mode, NULL },
2359
2849
 
2360
2850
        NIH_OPTION_LAST
2361
2851
};
2492
2982
};
2493
2983
 
2494
2984
/**
 
2985
 * set_env_options:
 
2986
 *
 
2987
 * Command-line options accepted for the set-env command.
 
2988
 **/
 
2989
NihOption set_env_options[] = {
 
2990
        { 'g', "global", N_("apply to global job environment table"),
 
2991
          NULL, NULL, &apply_globally, NULL },
 
2992
        { 'r', "retain", N_("do not replace the value of the variable if already set"),
 
2993
          NULL, NULL, &retain_var, NULL },
 
2994
        NIH_OPTION_LAST
 
2995
};
 
2996
 
 
2997
/**
 
2998
 * get_env_options:
 
2999
 *
 
3000
 * Command-line options accepted for the get-env command.
 
3001
 **/
 
3002
NihOption get_env_options[] = {
 
3003
        { 'g', "global", N_("apply to global job environment table"),
 
3004
          NULL, NULL, &apply_globally, NULL },
 
3005
        NIH_OPTION_LAST
 
3006
};
 
3007
 
 
3008
/**
 
3009
 * unset_env_options:
 
3010
 *
 
3011
 * Command-line options accepted for the unset-env command.
 
3012
 **/
 
3013
NihOption unset_env_options[] = {
 
3014
        { 'g', "global", N_("apply to global job environment table"),
 
3015
          NULL, NULL, &apply_globally, NULL },
 
3016
        NIH_OPTION_LAST
 
3017
};
 
3018
 
 
3019
/**
 
3020
 * list_env_options:
 
3021
 *
 
3022
 * Command-line options accepted for the list-env command.
 
3023
 **/
 
3024
NihOption list_env_options[] = {
 
3025
        { 'g', "global", N_("apply to global job environment table"),
 
3026
          NULL, NULL, &apply_globally, NULL },
 
3027
        NIH_OPTION_LAST
 
3028
};
 
3029
 
 
3030
/**
 
3031
 * reset_env_options:
 
3032
 *
 
3033
 * Command-line options accepted for the reset-env command.
 
3034
 **/
 
3035
NihOption reset_env_options[] = {
 
3036
        { 'g', "global", N_("apply to global job environment table"),
 
3037
          NULL, NULL, &apply_globally, NULL },
 
3038
        NIH_OPTION_LAST
 
3039
};
 
3040
 
 
3041
/**
2495
3042
 * usage_options:
2496
3043
 *
2497
3044
 * Command-line options accepted for the usage command.
2515
3062
static NihCommandGroup event_commands = { N_("Event") };
2516
3063
 
2517
3064
/**
 
3065
 * env_group:
 
3066
 *
 
3067
 * Group of commands related to Job environment variables.
 
3068
 **/
 
3069
static NihCommandGroup env_group = { N_("Environment") };
 
3070
 
 
3071
/**
2518
3072
 * commands:
2519
3073
 *
2520
3074
 * Commands accepts as the first non-option argument, or program name.
2590
3144
          NULL, version_options, version_action },
2591
3145
        { "log-priority", N_("[PRIORITY]"),
2592
3146
          N_("Change the minimum priority of log messages from the init "
2593
 
             "daemon"),
 
3147
             "daemon."),
2594
3148
          N_("PRIORITY may be one of:\n"
2595
3149
             "  `debug' (messages useful for debugging upstart are logged, "
2596
3150
             "equivalent to --debug on kernel command-line);\n"
2617
3171
        { "check-config", N_("[CONF]"),
2618
3172
          N_("Check for unreachable jobs/event conditions."),
2619
3173
          N_("List all jobs and events which cannot be satisfied by "
2620
 
             "currently available job configuration files"),
 
3174
             "currently available job configuration files."),
2621
3175
          NULL, check_config_options, check_config_action },
2622
3176
 
 
3177
        { "get-env", N_("VARIABLE"),
 
3178
          N_("Retrieve value of a job environment variable."),
 
3179
          N_("Display the value of a variable from the job environment table."),
 
3180
          &env_group, get_env_options, get_env_action },
 
3181
 
 
3182
        { "list-env", NULL,
 
3183
          N_("Show all job environment variables."),
 
3184
          N_("Displays sorted list of variables and their values from the job environment table."),
 
3185
          &env_group, list_env_options, list_env_action },
 
3186
 
 
3187
        { "reset-env", N_("VARIABLE"),
 
3188
          N_("Revert all job environment variable changes."),
 
3189
          N_("Discards all changes make to the job environment table, setting it back to its default value."),
 
3190
          &env_group, reset_env_options, reset_env_action },
 
3191
 
 
3192
        { "set-env", N_("VARIABLE[=VALUE]"),
 
3193
          N_("Set a job environment variable."),
 
3194
          N_("Adds or updates a variable in the job environment table."),
 
3195
          &env_group, set_env_options, set_env_action },
 
3196
 
 
3197
        { "unset-env", N_("VARIABLE"),
 
3198
          N_("Remove a job environment variable."),
 
3199
          N_("Discards the specified variable from the job environment table."),
 
3200
          &env_group, unset_env_options, unset_env_action },
 
3201
 
2623
3202
        { "usage",  N_("JOB"),
2624
3203
          N_("Show job usage message if available."),
2625
3204
          N_("JOB is the name of the job which usage is to be shown.\n" ),
2628
3207
        { "notify-disk-writeable", NULL,
2629
3208
          N_("Inform Upstart that disk is now writeable."),
2630
3209
          N_("Run to ensure output from jobs ending before "
2631
 
                          "disk is writeable are flushed to disk"),
 
3210
                          "disk is writeable are flushed to disk."),
2632
3211
          NULL, NULL, notify_disk_writeable_action },
2633
3212
 
 
3213
        { "list-sessions", NULL,
 
3214
          N_("List all sessions."),
 
3215
          N_("Displays list of running Session Init sessions"),
 
3216
          NULL, NULL, list_sessions_action },
 
3217
 
2634
3218
        NIH_COMMAND_LAST
2635
3219
};
2636
3220