| 1 |
[[feature-systemd]] |
| 2 |
= systemd |
| 3 |
|
| 4 |
Cockpit uses https://www.freedesktop.org/wiki/Software/systemd/[systemd] |
| 5 |
and the DBus APIs it provides to configure and monitor core aspects of |
| 6 |
the system. Use of alternate system APIs are not currently implemented. |
| 7 |
|
| 8 |
For non root users, systemd controls access to its APIs via |
| 9 |
xref:privileges.adoc[Policy Kit] and a user logged into Cockpit will have |
| 10 |
the same permissions as they do from the command line. |
| 11 |
|
| 12 |
Cockpit retrieves information about the host and changes the hostname |
| 13 |
via the `+hostnamed+` daemon. To perform similar tasks from the command |
| 14 |
line use the |
| 15 |
https://www.freedesktop.org/software/systemd/man/hostnamectl.html[`+hostnamectl+`] |
| 16 |
command: |
| 17 |
|
| 18 |
.... |
| 19 |
$ hostnamectl |
| 20 |
Static hostname: pink.example.com |
| 21 |
Pretty hostname: Pink |
| 22 |
Icon name: computer-desktop |
| 23 |
Chassis: desktop |
| 24 |
Machine ID: ef00b79be229463cbb844c3e715de96c |
| 25 |
Boot ID: 934983d64d34465cb5a8383b5a89ad8c |
| 26 |
Operating System: Fedora 22 (Twenty Two) |
| 27 |
CPE OS Name: cpe:/o:fedoraproject:fedora:22 |
| 28 |
Kernel: Linux 4.0.4-301.fc22.x86_64 |
| 29 |
Architecture: x86-64 |
| 30 |
.... |
| 31 |
|
| 32 |
Cockpit configures the system time and time zone via the `+timedated+` |
| 33 |
daemon. To perform similar tasks from the command line use the |
| 34 |
https://www.freedesktop.org/software/systemd/man/timedatectl.html[`+timedatectl+`] |
| 35 |
command: |
| 36 |
|
| 37 |
.... |
| 38 |
$ timedatectl list-timezones |
| 39 |
Africa/Abidjan |
| 40 |
Africa/Accra |
| 41 |
Africa/Addis_Ababa |
| 42 |
Africa/Algiers |
| 43 |
... |
| 44 |
.... |
| 45 |
|
| 46 |
Cockpit can manage the list of NTP servers used by `+systemd-timesyncd+` |
| 47 |
by putting its own file into `+/etc/systemd/timesyncd.conf.d/+`. Note |
| 48 |
that `+systemd-timesyncd+` is not always enabled, depending on the |
| 49 |
configuration of the machine. In that case, Cockpit disabled the UI for |
| 50 |
managing the list of NTP servers. In some cases use of `+ntpd+` can |
| 51 |
cause the `+timedated+` daemon to behave inconsistently with regards to |
| 52 |
time synchronization. |
| 53 |
|
| 54 |
Cockpit reboots or powers down the machine by using the |
| 55 |
https://www.freedesktop.org/software/systemd/man/shutdown.html[`+shutdown+`] |
| 56 |
command. To perform similar tasks from the command line, run it |
| 57 |
directly: |
| 58 |
|
| 59 |
.... |
| 60 |
$ sudo shutdown +15 |
| 61 |
Shutdown scheduled for Sa 2015-09-26 15:49:40 CEST, use 'shutdown -c' to cancel. |
| 62 |
.... |
| 63 |
|
| 64 |
Cockpit manages system services and sockets via systemd. To perform |
| 65 |
similar tasks from the command line use the |
| 66 |
https://www.freedesktop.org/software/systemd/man/systemctl.html[`+systemctl+`] |
| 67 |
command: |
| 68 |
|
| 69 |
.... |
| 70 |
$ systemctl status cockpit |
| 71 |
● cockpit.service - Cockpit Web Service |
| 72 |
Loaded: loaded (/usr/lib/systemd/system/cockpit.service; static; vendor preset: disabled) |
| 73 |
Drop-In: /etc/systemd/system/cockpit.service.d |
| 74 |
└─debug.conf |
| 75 |
Active: active (running) since Sa 2015-09-26 13:28:02 CEST; 2h 7min ago |
| 76 |
Docs: man:cockpit-ws(8) |
| 77 |
Main PID: 6957 (cockpit-ws) |
| 78 |
Memory: 1.8M |
| 79 |
CGroup: /system.slice/cockpit.service |
| 80 |
├─ 6957 /usr/libexec/cockpit-ws |
| 81 |
└─29598 /usr/bin/ssh-agent |
| 82 |
.... |
| 83 |
|
| 84 |
In order to customize who can perform various actions in system, |
| 85 |
xref:privileges.adoc#privileges-polkit[create polkit rules] with the following actions |
| 86 |
and details: |
| 87 |
|
| 88 |
`+org.freedesktop.systemd1.manage-units+`:: |
| 89 |
Permission to manage system services or other units. Details |
| 90 |
available: `+unit+`, `+verb+` |
| 91 |
`+org.freedesktop.systemd1.manage-unit-files+`:: |
| 92 |
Permission to manage system services or other unit files. |
| 93 |
`+org.freedesktop.systemd1.reload-daemon+`:: |
| 94 |
Permission to reload the systemd state. |
| 95 |
|
| 96 |
For example, placing the following polkit rule to |
| 97 |
`+/etc/polkit-1/rules.d/10-http.rule+` allows all users in the |
| 98 |
`+operators+` group start, stop, and restart the Apache HTTP service: |
| 99 |
|
| 100 |
.... |
| 101 |
polkit.addRule(function(action, subject) { |
| 102 |
if (action.id == "org.freedesktop.systemd1.manage-units") { |
| 103 |
if (subject.isInGroup("operators") && action.lookup("unit") == "httpd.service") { |
| 104 |
var verb = action.lookup("verb"); |
| 105 |
if (verb == "start" || verb == "stop" || verb == "restart") { |
| 106 |
return polkit.Result.YES; |
| 107 |
} |
| 108 |
} |
| 109 |
} |
| 110 |
}); |
| 111 |
.... |