From ea632a2bedadb6114aa15b3479eecfa84b4fd26e Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 3 Sep 2010 16:57:32 -0400 Subject: Add in basic systemd units. Factor out upstart/systemd/etc. support in the spec properly. --- Makefile | 17 +++++++++++++---- initscripts.spec | 48 +++++++++++++++++++++++++++++++++++++++++------- inittab.systemd | 13 +++++++++++++ systemd/halt.service | 19 +++++++++++++++++++ systemd/killall.service | 18 ++++++++++++++++++ systemd/poweroff.service | 19 +++++++++++++++++++ systemd/prefdm.service | 23 +++++++++++++++++++++++ systemd/rc-local.service | 19 +++++++++++++++++++ systemd/reboot.service | 19 +++++++++++++++++++ systemd/single.service | 28 ++++++++++++++++++++++++++++ systemd/sysinit.service | 19 +++++++++++++++++++ 11 files changed, 231 insertions(+), 11 deletions(-) create mode 100644 inittab.systemd create mode 100644 systemd/halt.service create mode 100644 systemd/killall.service create mode 100644 systemd/poweroff.service create mode 100644 systemd/prefdm.service create mode 100644 systemd/rc-local.service create mode 100644 systemd/reboot.service create mode 100644 systemd/single.service create mode 100644 systemd/sysinit.service diff --git a/Makefile b/Makefile index 6c706b47..7168bc49 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ install: install -m644 inittab.s390 $(ROOT)/etc/inittab.sysv ; \ fi install -m644 inittab.upstart $(ROOT)/etc/inittab.upstart + install -m644 inittab.systemd $(ROOT)/etc/inittab.systemd install -m644 rwtab statetab networks $(ROOT)/etc install -m755 service setsysfont $(ROOT)/sbin install -m644 lang.csh lang.sh $(ROOT)/etc/profile.d @@ -47,6 +48,8 @@ install: install -m644 sysconfig/debug sysconfig/init sysconfig/netconsole sysconfig/readonly-root $(ROOT)/etc/sysconfig/ cp -af sysconfig/network-scripts $(ROOT)/etc/sysconfig/ cp -af ppp NetworkManager init $(ROOT)/etc + mkdir -p $(ROOT)/lib/systemd/system + cp -af systemd/* $(ROOT)/lib/systemd/system mkdir -p $(ROOT)/etc/ppp/peers mkdir -p $(ROOT)/lib cp -af udev $(ROOT)/lib @@ -106,10 +109,16 @@ install: ln -s ../init.d/single $(ROOT)/etc/rc.d/rc1.d/S99single - ln -s ../rc.local $(ROOT)/etc/rc.d/rc2.d/S99local - ln -s ../rc.local $(ROOT)/etc/rc.d/rc3.d/S99local - ln -s ../rc.local $(ROOT)/etc/rc.d/rc4.d/S99local - ln -s ../rc.local $(ROOT)/etc/rc.d/rc5.d/S99local + ln -s ../rc.local $(ROOT)/etc/rc.d/rc2.d/S99rc-local + ln -s ../rc.local $(ROOT)/etc/rc.d/rc3.d/S99rc-local + ln -s ../rc.local $(ROOT)/etc/rc.d/rc4.d/S99rc-local + ln -s ../rc.local $(ROOT)/etc/rc.d/rc5.d/S99rc-local + + ln -s halt $(ROOT)/etc/rc.d/init.d/reboot + + mkdir -p $(ROOT)/etc/systemd/system + ln -s /lib/systemd/system/prefdm.service $(ROOT)/etc/systemd/system/display-manager.service + ln -s /lib/systemd/system/reboot.target $(ROOT)/etc/systemd/system/ctrl-alt-del.target # These are LSB compatibility symlinks. At some point in the future # the actual files will be here instead of symlinks diff --git a/initscripts.spec b/initscripts.spec index 9e8fd38a..62672d5f 100644 --- a/initscripts.spec +++ b/initscripts.spec @@ -1,4 +1,6 @@ -%define with_upstart 1%{nil} +%define _with_upstart 1 +%define _with_systemd 1 +%define _with_sysvinit 0 Summary: The inittab file and the /etc/init.d scripts Name: initscripts @@ -18,9 +20,15 @@ Requires: module-init-tools Requires: util-linux-ng >= 2.16 Requires: bash >= 3.0 Requires: sysvinit-tools >= 2.87 -%if with_upstart -Requires: upstart >= 0.6.0 -%else +Requires: sysvinit-userspace +%if %{_with_upstart} +Conflicts: upstart < 0.6.0 +%endif +%if %{_with_systemd} +Conflicts: systemd < 9-3 +Conflicts: systemd-units < 9-3 +%endif +%if %{_with_sysvinit} Requires: SysVinit >= 2.85-38 %endif Requires: /sbin/ip, /sbin/arping, net-tools, /bin/find @@ -76,12 +84,21 @@ make ROOT=$RPM_BUILD_ROOT SUPERUSER=`id -un` SUPERGROUP=`id -gn` mandir=%{_mandi %find_lang %{name} -%if with_upstart +%ig %{_with_systemd} + mv -f $RPM_BUILD_ROOT/etc/inittab.systemd $RPM_BUILD_ROOT/etc/inittab +%endif +%if %{_with_upstart} mv -f $RPM_BUILD_ROOT/etc/inittab.upstart $RPM_BUILD_ROOT/etc/inittab -%else +%endif +%if %{_with_sysvinit} mv -f $RPM_BUILD_ROOT/etc/inittab.sysv $RPM_BUILD_ROOT/etc/inittab +%endif +%if ! %{_with_upstart} rm -rf $RPM_BUILD_ROOT/etc/init %endif +%if ! %{_with_systemd} + rm -rf $RPM_BUILD_ROOT/etc/systemd $RPM_BUILD_ROOT/lib/systemd +%endif rm -f $RPM_BUILD_ROOT/etc/inittab.* %ifnarch s390 s390x @@ -105,6 +122,11 @@ chmod 600 /var/log/btmp /sbin/chkconfig --add netfs /sbin/chkconfig --add network /sbin/chkconfig --add netconsole +%if %{_with_systemd} +if [ $1 -eq 1 ]; then + /bin/systemctl daemon-reload > /dev/null 2>&1 || : +fi +%endif %preun if [ $1 = 0 ]; then @@ -118,6 +140,14 @@ fi /sbin/chkconfig --del rawdevices exit 0 +%if %{_with_systemd} +%postun +if [ $1 -ge 1 ]; then + /bin/systemctl daemon-reload > /dev/null 2>&1 || : +fi +%endif + + %clean rm -rf $RPM_BUILD_ROOT @@ -178,9 +208,13 @@ rm -rf $RPM_BUILD_ROOT %dir /etc/rwtab.d /etc/statetab %dir /etc/statetab.d -%if with_upstart +%if %{_with_upstart} /etc/init/* %endif +%if %{_with_systemd} +%config(noreplace) /etc/systemd/system/* +/lib/systemd/system/* +%endif %config /etc/X11/prefdm %config(noreplace) /etc/inittab %dir /etc/rc.d diff --git a/inittab.systemd b/inittab.systemd new file mode 100644 index 00000000..8a9eb630 --- /dev/null +++ b/inittab.systemd @@ -0,0 +1,13 @@ +# inittab is no longer used when using systemd. +# +# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM. +# +# System initialization is started by /lib/systemd/system/sysinit.service +# +# Non-SysV tasks for individual runlevels live in /lib/systemd/system/runlevelX.target.wants +# +# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target +# +# To set a default runlevel , run: +# +# ln -s /lib/systemd/system/runlevel.target /etc/systemd/system/default.target diff --git a/systemd/halt.service b/systemd/halt.service new file mode 100644 index 00000000..a1c0e84f --- /dev/null +++ b/systemd/halt.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Halt the system +DefaultDependencies=no +Requires=umount.target killall.service +After=umount.target killall.service + +[Service] +Type=oneshot +RemainAfterExit=yes +Environment=INIT_HALT=HALT RUNLEVEL=0 +ExecStart=/etc/init.d/halt start +StandardOutput=tty diff --git a/systemd/killall.service b/systemd/killall.service new file mode 100644 index 00000000..e03aaba2 --- /dev/null +++ b/systemd/killall.service @@ -0,0 +1,18 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Kill all processes +DefaultDependencies=no +After=shutdown.target +RefuseManualStart=yes + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=-/etc/init.d/killall start +StandardOutput=tty diff --git a/systemd/poweroff.service b/systemd/poweroff.service new file mode 100644 index 00000000..28b4a5f4 --- /dev/null +++ b/systemd/poweroff.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Power down the system +DefaultDependencies=no +Requires=umount.target killall.service +After=umount.target killall.service + +[Service] +Type=oneshot +RemainAfterExit=yes +Environment=RUNLEVEL=0 +ExecStart=/etc/init.d/halt start +StandardOutput=tty diff --git a/systemd/prefdm.service b/systemd/prefdm.service new file mode 100644 index 00000000..bbdf0d37 --- /dev/null +++ b/systemd/prefdm.service @@ -0,0 +1,23 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Display Manager +After=syslog.target livesys-late.service rc-local.service + +# On Fedora gdm/X11 is on tty1. We explicitly cancel the getty here to +# avoid any races around that. +Conflicts=getty@tty1.service plymouth-quit.service + +[Service] +ExecStart=/etc/X11/prefdm -nodaemon +Restart=restart-always +RestartSec=0 + +[Install] +Alias=display-manager.service +WantedBy=graphical.target diff --git a/systemd/rc-local.service b/systemd/rc-local.service new file mode 100644 index 00000000..6be4fcf4 --- /dev/null +++ b/systemd/rc-local.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Local customization + +[Service] +ExecStart=/etc/rc.local start +TimeoutSec=0 +StandardOutput=tty +RemainAfterExit=yes +SysVStartPriority=99 + +[Install] +WantedBy=multi-user.target diff --git a/systemd/reboot.service b/systemd/reboot.service new file mode 100644 index 00000000..622beb58 --- /dev/null +++ b/systemd/reboot.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Reboot the system +DefaultDependencies=no +Requires=umount.target killall.service +After=umount.target killall.service + +[Service] +Type=oneshot +RemainAfterExit=yes +Environment=RUNLEVEL=6 +ExecStart=/etc/init.d/reboot start +StandardOutput=tty diff --git a/systemd/single.service b/systemd/single.service new file mode 100644 index 00000000..18174fb3 --- /dev/null +++ b/systemd/single.service @@ -0,0 +1,28 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# See systemd.special(7) for details + +[Unit] +Description=Rescue Shell +DefaultDependencies=no +Conflicts=multi-user.target +After=sysinit.target +Before=multi-user.target + +[Service] +Type=oneshot +EnvironmentFile=/etc/sysconfig/init +ExecStartPre=-/bin/plymouth --hide-splash +ExecStart=/bin/bash -c "exec $SINGLE" +ExecStartPost=/bin/systemctl default +StandardInput=tty-force +KillMode=process-group + +# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash +# terminates cleanly. +KillSignal=SIGHUP diff --git a/systemd/sysinit.service b/systemd/sysinit.service new file mode 100644 index 00000000..860d3a34 --- /dev/null +++ b/systemd/sysinit.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=System Initialization +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target + +[Service] +ExecStart=/etc/rc.d/rc.sysinit +Type=forking +TimeoutSec=0 +StandardInput=tty +RemainAfterExit=yes -- cgit v1.2.1